Commit Graph

126345 Commits

Author SHA1 Message Date
Aleksey Kladov 5716c3e18d Update expect-test to 1.0
The only change is that `expect_file` now uses path relative to the
current file (same as `include!`). Before, it used paths relative to
the workspace root, which makes no sense.
2020-08-31 21:04:09 +02:00
bors 897ef3a0ec Auto merge of #75936 - sdroege:chunks-exact-construction-bounds-check, r=nagisa
Get rid of bounds check in slice::chunks_exact() and related function…

…s during construction

LLVM can't figure out in

    let rem = self.len() % chunk_size;
    let len = self.len() - rem;
    let (fst, snd) = self.split_at(len);

and

    let rem = self.len() % chunk_size;
    let (fst, snd) = self.split_at(rem);

that the index passed to split_at() is smaller than the slice length and
adds a bounds check plus panic for it.

Apart from removing the overhead of the bounds check this also allows
LLVM to optimize code around the ChunksExact iterator better.
2020-08-31 15:55:13 +00:00
bors 1fd8636d24 Auto merge of #76159 - matklad:rollup-8jydjg3, r=matklad
Rollup of 5 pull requests

Successful merges:

 - #75938 (Added some `min_const_generics` revisions into `const_generics` tests)
 - #76050 (Remove unused function)
 - #76075 (datastructures: replace `once_cell` crate with an impl from std)
 - #76115 (Restore public visibility on some parsing functions for rustfmt)
 - #76127 (rustbuild: Remove one LLD workaround)

Failed merges:

r? @ghost
2020-08-31 13:30:13 +00:00
Aleksey Kladov 9caf08f052
Rollup merge of #76127 - petrochenkov:lld, r=Mark-Simulacrum
rustbuild: Remove one LLD workaround

The version of LLD shipped with Rust no longer have this issue.

Closes https://github.com/rust-lang/rust/issues/68647
2020-08-31 15:22:45 +02:00
Aleksey Kladov d8eb30127b
Rollup merge of #76115 - calebcartwright:parser-fn-visibility, r=matklad
Restore public visibility on some parsing functions for rustfmt

In #74826 the visibility of several parsing functions was reduced. However, rustfmt is an external consumer of some of these functions as well and needs the visibility to be public, similar to other elements in rustc_parse such as `parse_ident`

db534b3ac2/src/librustc_parse/parser/mod.rs (L433-L436)
2020-08-31 15:22:43 +02:00
Aleksey Kladov 67f16431aa
Rollup merge of #76075 - marmeladema:remove-once-cell-crate, r=matklad
datastructures: replace `once_cell` crate with an impl from std

Fixes #75700

r? @matklad

We might need a perf run for this change.
2020-08-31 15:22:42 +02:00
Aleksey Kladov 7d2460e5c4
Rollup merge of #76050 - matklad:pos, r=petrochenkov
Remove unused function
2020-08-31 15:22:40 +02:00
Aleksey Kladov 4e2a25d759
Rollup merge of #75938 - Amjad50:min_const_generics-tests-revisions, r=lcnr
Added some `min_const_generics` revisions into `const_generics` tests

Help in #75279. still a lot more to cover though

r? @lcnr
2020-08-31 15:22:38 +02:00
bors 3b4797cb59 Auto merge of #76153 - matklad:rollup-vlblfup, r=matklad
Rollup of 9 pull requests

Successful merges:

 - #75969 (Switch to intra-doc links in core/src/{convert,iter}/mod.rs)
 - #76023 (Liballoc extend use intra doc link)
 - #76033 (Add missing hyphen)
 - #76052 (GH-66816:  Remove disable attr before return)
 - #76055 (Keep doc standard for Vec DrainFilter)
 - #76058 (Use assertions on Vec doc)
 - #76069 (Use explicit intra-doc link in path for Vec resize)
 - #76117 (Update README.md)
 - #76134 (Update MinGW instructions to include ninja)

Failed merges:

r? @ghost
2020-08-31 11:01:40 +00:00
Amjad Alsharafi 668f63d833 Fix duplicate error messages in const_generics tests 2020-08-31 18:52:22 +08:00
Aleksey Kladov bd91b08507
Rollup merge of #76134 - CDirkx:patch-1, r=nagisa
Update MinGW instructions to include ninja

Rust now requires `ninja` to build, so the MinGW build instructions are updated to reflect this.

Like for `python` and `cmake`, the `mingw-w64-x86_64-ninja` package should be used. The default package from the `msys2` subsystem doesn't handle paths correctly on windows.
2020-08-31 12:51:55 +02:00
Aleksey Kladov f8481745aa
Rollup merge of #76117 - mark-i-m:patch-1, r=petrochenkov
Update README.md
2020-08-31 12:51:54 +02:00
Aleksey Kladov 13c4f04561
Rollup merge of #76069 - pickfire:patch-16, r=jyn514
Use explicit intra-doc link in path for Vec resize

r? @jyn514
2020-08-31 12:51:53 +02:00
Aleksey Kladov d829a5bcb1
Rollup merge of #76058 - pickfire:patch-11, r=jyn514
Use assertions on Vec doc

Clarify what the state of Vec after with_capacity on doc.

r? @jyn514
2020-08-31 12:51:51 +02:00
Aleksey Kladov af1f46cf99
Rollup merge of #76055 - pickfire:patch-9, r=jyn514
Keep doc standard for Vec DrainFilter

r? @jyn514
2020-08-31 12:51:49 +02:00
Aleksey Kladov 300d7f661a
Rollup merge of #76052 - aszenz:GH-66816_removes_disable_attribute_before_return, r=GuillaumeGomez
GH-66816:  Remove disable attr before return

Passing --disable-per-crate-search removes the create search inputs so moved code around so that the search input is enabled
first before the function returns.

Fixes #66816
2020-08-31 12:51:46 +02:00
Aleksey Kladov 6ce3243995
Rollup merge of #76033 - camelid:patch-7, r=Dylan-DPC
Add missing hyphen

reference counted pointer -> reference-counted pointer

@rustbot modify labels: T-doc
2020-08-31 12:51:45 +02:00
Aleksey Kladov e59eb4e0fa
Rollup merge of #76023 - pickfire:patch-4, r=jyn514
Liballoc extend use intra doc link

Superseeds https://github.com/rust-lang/rust/pull/75729/commits

r? @jyn514
2020-08-31 12:51:42 +02:00
Aleksey Kladov c6017142a3
Rollup merge of #75969 - nixphix:docs/mod, r=jyn514
Switch to intra-doc links in core/src/{convert,iter}/mod.rs

Partial fix for #75080

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc

r? @jyn514

couldn't fix these

```rust
     ../../std/string/struct.String.html
     ../../std/primitive.never.html
     ../../std/sync/mpsc/struct.TryIter.html
```
2020-08-31 12:51:40 +02:00
bors 8bfe289886 Auto merge of #75932 - Amjad50:intra-doc-core-slice, r=jyn514
Use intra-doc links for `core/src/slice.mod.rs`

partial help in #75080

r? @jyn514

- most are using primitive types links, which cannot be used with intra links at the moment
- also `std` cannot be referenced in any link, `std::ptr::NonNull` and `std::slice` could not be referenced
2020-08-31 09:09:37 +00:00
bors 6c44bcc4ff Auto merge of #75926 - camelid:patch-5, r=jonas-schievink
Fix typo in release notes
2020-08-31 07:17:34 +00:00
bors 8ed5cb56b5 Auto merge of #76027 - davidtwco:issue-61139-remove-obsolete-pretty-printer, r=eddyb
ty: remove obsolete pretty printer

Fixes #61139.

This PR removes the obsolete printer and replaces all uses of it with `FmtPrinter`. Of the replaced uses, all but one use was in `debug!` logging, two cases were notable:

- `MonoItem::to_string` is used in `-Z print-mono-items` and therefore affects the output of all codegen-units tests (which have been updated).
- `DefPathBasedNames` was used in `librustc_codegen_llvm/type_of.rs` with `LLVMStructCreateNamed` and that'll now get different values, but nothing will break as a result of this.

cc @eddyb (whom I've discussed this with)
2020-08-31 05:32:54 +00:00
bors e98f0632bb Auto merge of #75082 - Aaron1011:feature/proc-macro-backtrace, r=petrochenkov
Add `-Z proc-macro-backtrace` to allow showing proc-macro panics

Fixes #75050

Previously, we would unconditionally suppress the panic hook during
proc-macro execution. This commit adds a new flag
`-Z proc-macro-backtrace`, which allows running the panic hook for
easier debugging.
2020-08-31 03:19:05 +00:00
Aaron Hill d9208665b5
Add `-Z proc-macro-backtrace` to allow showing proc-macro panics
Fixes #75050

Previously, we would unconditionally suppress the panic hook during
proc-macro execution. This commit adds a new flag
-Z proc-macro-backtrace, which allows running the panic hook for
easier debugging.
2020-08-30 22:17:24 -04:00
bors 92290d1631 Auto merge of #75463 - CDirkx:ordering-const, r=CDirkx
Make some Ordering methods const

Constify the following methods of `core::cmp::Ordering`:
 - `reverse`
 - `then`

Possible because of #49146 (Allow `if` and `match` in constants).

Tracking issue:  #76113
2020-08-31 01:28:42 +00:00
CDirkx 00d459a93f
Update MinGW instructions to include ninja
Added the `mingw-w64-x86_64-ninja` package to the build guide for MinGW, as well as a note not to use the `ninja` package from the `msys2` subsystem (doesn't handle paths correctly on windows).
2020-08-31 01:22:25 +02:00
bors 022e1fe235 Auto merge of #74668 - petrochenkov:noname, r=mark-i-m
cleanup: Remove duplicate library names from `Cargo.toml`s
2020-08-30 23:14:05 +00:00
CDirkx 12f4624f71 Update `since` to correct release
`const_ordering` will stabilize in version 1.48.0
2020-08-30 23:59:37 +02:00
CDirkx 89fc3fb93b Stabilize feature `const_ordering` 2020-08-30 23:48:54 +02:00
Vadim Petrochenkov 21c624a230 rustbuild: Remove one LLD workaround 2020-08-31 00:26:07 +03:00
bors 36b0d7e257 Auto merge of #75779 - scileo:fix-issue-75492, r=petrochenkov
Improve error message when typo is made in format!

The expansion of the format! built-in macro is roughly done in two steps:
  - the format expression is parsed, the arguments are parsed,
  - the format expression is checked to be a string literal, code is expanded.

The problem is that the expression parser can eat too much tokens, which invalidates the parsing of the next format arguments. As the format expression check happens next, the error emitted concerns the format arguments, whereas the problem is about the format expression.

This PR contains two commits. The first one actually checks that the formatting expression is a string literal before raising any error about the formatting arguments, and the second one contains some simple heuristics which allow to suggest, when the format expression is followed by a dot instead of a comma, to suggest to replace the dot with a comma.

This pull request should fix #75492.

Note: this is my first non-doc contribution to the rust ecosystem. Feel free to make any comment about my code, or whatever. I'll be very happy to fix it :)
2020-08-30 21:03:06 +00:00
Sebastian Dröge 8d3cf9237d Improve documentation of slice::get_unchecked() / split_at_unchecked()
Thanks to Ivan Tham, who gave the majority of these suggestions during
their review.
2020-08-30 23:13:47 +03:00
Sebastian Dröge d08996ac54 Get rid of bounds check in slice::chunks_exact() and related functions during construction
LLVM can't figure out in

    let rem = self.len() % chunk_size;
    let len = self.len() - rem;
    let (fst, snd) = self.split_at(len);

and

    let rem = self.len() % chunk_size;
    let (fst, snd) = self.split_at(rem);

that the index passed to split_at() is smaller than the slice length and
adds a bounds check plus panic for it.

Apart from removing the overhead of the bounds check this also allows
LLVM to optimize code around the ChunksExact iterator better.
2020-08-30 23:13:47 +03:00
Sebastian Dröge 30dc32b10e Add (non-public) slice::split_at_unchecked() and split_at_mut_unchecked()
These are unsafe variants of the non-unchecked functions and don't do
any bounds checking.

For the time being these are not public and only a preparation for the
following commit. Making it public and stabilization can follow later
and be discussed in https://github.com/rust-lang/rust/issues/76014 .
2020-08-30 23:13:46 +03:00
Sasha f6d18db402 Use string literal directly when available in format
Previous implementation used the `Parser::parse_expr` function in order
to extract the format expression. If the first comma following the
format expression was mistakenly replaced with a dot, then the next
format expression was eaten by the function, because it looked as a
syntactically valid expression, which resulted in incorrectly spanned
error messages.

The way the format expression is exctracted is changed: we first look at
the first available token in the first argument supplied to the
`format!` macro call. If it is a string literal, then it is promoted as
a format expression immediatly, otherwise we fall back to the original
`parse_expr`-related method.

This allows us to ensure that the parser won't consume too much tokens
when a typo is made.

A test has been created so that it is ensured that the issue is properly
fixed.
2020-08-30 22:09:58 +02:00
Vadim Petrochenkov 7dfbf59f10 cleanup: Remove duplicate library names from `Cargo.toml`s 2020-08-30 22:57:54 +03:00
marmeladema 68500ffacb datastructures: replace `once_cell` crate with an impl from std 2020-08-30 20:06:14 +01:00
Who? Me?! 0175c437e2
Update README.md 2020-08-30 13:40:11 -05:00
Caleb Cartwright 883b1e7592 parser: restore some fn visibility for rustfmt 2020-08-30 13:04:36 -05:00
David Wood 6ff471b1cf
ty: remove obsolete printer
This commit removes the obsolete printer and replaces all uses of it
with `FmtPrinter`. Of the replaced uses, all but one use was in `debug!`
logging, two cases were notable:

- `MonoItem::to_string` is used in `-Z print-mono-items` and therefore
  affects the output of all codegen-units tests.
- `DefPathBasedNames` was used in `librustc_codegen_llvm/type_of.rs`
  with `LLVMStructCreateNamed` and that'll now get different values, but
  this should result in no functional change.

Signed-off-by: David Wood <david@davidtw.co>
2020-08-30 18:59:07 +01:00
Aleksey Kladov 518cac9190 Remove unused function 2020-08-30 19:54:45 +02:00
Aleksey Kladov ccffea5b6b Move lexer unit tests to rustc_lexer
StringReader is an intornal abstraction which at the moment changes a
lot, so these unit tests cause quite a bit of friction.

Moving them to rustc_lexer and more ingerated-testing style should
make them much less annoying, hopefully without decreasing their
usefulness much.

Note that coloncolon tests are removed (it's unclear what those are
testing).

\r\n tests are removed as well, as we normalize line endings even
before lexing.
2020-08-30 19:53:36 +02:00
CDirkx 5fac991bf6 Add unstable `const_ordering` feature, and some tests. 2020-08-30 19:40:00 +02:00
bors 85fbf49ce0 Auto merge of #74862 - mark-i-m:mv-compiler, r=petrochenkov
Move almost all compiler crates to compiler/

This PR implements https://github.com/rust-lang/compiler-team/issues/336 and moves all `rustc_*` crates from `src` to the new `compiler` directory.

`librustc_foo` directories are renamed to `rustc_foo`.
`src` directories are introduced inside `rustc_*` directories to mirror the scheme already use for `library` crates.
2020-08-30 15:57:57 +00:00
mark 9e5f7d5631 mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
Prabakaran Kumaresshan 523fea4d14 revert Some(Item) link 2020-08-30 19:19:20 +05:30
bors db534b3ac2 Auto merge of #75176 - jyn514:impl-link, r=GuillaumeGomez,petrochenkov
Fix intra-doc links for cross-crate re-exports of default trait methods

The original fix for this was very simple: https://github.com/rust-lang/rust/pull/58972 ignored `extern_traits` because before https://github.com/rust-lang/rust/issues/65983 was fixed, they would always fail to resolve, giving spurious warnings. So the first commit just undoes that change, so extern traits are now seen by the `collect_intra_doc_links` pass. There are also some minor changes in `librustdoc/fold.rs` to avoid borrowing the `extern_traits` RefCell more than once at a time.

However, that brought up a much more thorny problem. `rustc_resolve` started giving 'error: cannot find a built-in macro with name `cfg`' when documenting `libproc_macro` (I still haven't been able to reproduce on anything smaller than the full standard library). The chain of events looked like this (thanks @eddyb for the help debugging!):

0. `x.py build --stage 1` builds the standard library and creates a sysroot
1. `cargo doc` does something like `cargo check` to create `rmeta`s for all the crates (unrelated to what was built above)
2. the `cargo check`-like `libcore-*.rmeta` is loaded as a transitive dependency *and claims ownership* of builtin macros
3. `rustdoc` later tries to resolve some path in a doc link
4. suggestion logic fires and loads "extern prelude" crates by name
5. the sysroot `libcore-*.rlib` is loaded and *fails to claim ownership* of builtin macros

`rustc_resolve` gives the error after step 5. However, `rustdoc` doesn't need suggestions at all - `resolve_str_path_error` completely discards the `ResolutionError`! The fix implemented in this PR is to skip the suggestion logic for `resolve_ast_path`: pass `record_used: false` and skip `lookup_import_candidates` when `record_used` isn't set.

It's possible that if/when https://github.com/rust-lang/rust/issues/74207 is implemented this will need a more in-depth fix which returns a `ResolutionError` from `compile_macro`, to allow rustdoc to reuse the suggestions from rustc_resolve. However, that's a much larger change and there's no need for it yet, so I haven't implemented it here.

Fixes https://github.com/rust-lang/rust/issues/73829.

r? @GuillaumeGomez
2020-08-30 13:16:38 +00:00
Joshua Nelson 9131d23cc0 resolve: Don't speculatively load crates if this is a speculative resolution
This avoids a rare rustdoc bug where loading `core` twice caused a
'cannot find a built-in macro' error:

1. `x.py build --stage 1` builds the standard library and creates a sysroot
2. `cargo doc` does something like `cargo check` to create `rmeta`s for all the crates (unrelated to what was built above)
3. the `cargo check`-like `libcore-*.rmeta` is loaded as a transitive dependency *and claims ownership* of builtin macros
4. `rustdoc` later tries to resolve some path in a doc link
5. suggestion logic fires and loads "extern prelude" crates by name
6. the sysroot `libcore-*.rlib` is loaded and *fails to claim ownership* of builtin macros

This fixes step 5. by not running suggestion logic if this is a
speculative resolution. Additionally, it marks `resolve_ast_path` as a
speculative resolution.
2020-08-30 08:15:08 -04:00
Joshua Nelson a1c71a1709 rustdoc,metadata: Debugging 2020-08-30 08:14:55 -04:00
Prabakaran Kumaresshan 7ea4c28af2 add i32::MAX link 2020-08-30 17:07:50 +05:30