]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoAuto merge of #75931 - estebank:suggest-if-let, r=petrochenkov
bors [Tue, 1 Sep 2020 00:26:01 +0000 (00:26 +0000)]
Auto merge of #75931 - estebank:suggest-if-let, r=petrochenkov

Suggest `if let x = y` when encountering `if x = y`

Detect potential cases where `if let` was meant but `let` was left out.

Fix #44990.

3 years agoAuto merge of #76174 - ehuss:update-cargo, r=ehuss
bors [Mon, 31 Aug 2020 21:57:35 +0000 (21:57 +0000)]
Auto merge of #76174 - ehuss:update-cargo, r=ehuss

Update cargo

8 commits in 51b66125ba97d2906f461b3f4e0408f206299bb6..126907a7cfccbe93778530e6a6bbaa3adb6c515c
2020-08-19 20:22:52 +0000 to 2020-08-31 20:42:11 +0000
- Fix flakiness in close_output test (rust-lang/cargo#8668)
- Reload unstable table from config file in `reload_rooted_at` (rust-lang/cargo#8656)
- Bump to 0.49.0, update changelog (rust-lang/cargo#8659)
- Fix LTO with doctests. (rust-lang/cargo#8657)
- Add spaces after -C and -Z flags for consistency (rust-lang/cargo#8648)
- Fix cache_messages::rustdoc test broken on beta. (rust-lang/cargo#8653)
- fix: remove unnecessary allocations (rust-lang/cargo#8641)
- Fixed a spelling and some clippy warnings (rust-lang/cargo#8637)

3 years agoUpdate cargo
Eric Huss [Mon, 31 Aug 2020 17:36:13 +0000 (10:36 -0700)]
Update cargo

3 years agoAuto merge of #75979 - lzutao:seprate-tests, r=Mark-Simulacrum
bors [Mon, 31 Aug 2020 20:03:33 +0000 (20:03 +0000)]
Auto merge of #75979 - lzutao:seprate-tests, r=Mark-Simulacrum

Move `#[cfg(test)]` modules into separate files to save recompiling the `std` crate

Implements an accepted proposal: https://github.com/rust-lang/compiler-team/issues/344

Some notes for reviewers:
* `mod tests` nested in `mod foo` in `mod bar`, I move `foo` to a new file, `tests` is a new file in foo: For example library/std/src/sys/sgx/abi/tls.rs
* `mod test` (not `mod tests`) also is moved.
* `mod benches` are moved.
* `mod tests` is placed before any `use` statements: The topic is discussed in https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Code.20Style.20process
* Some files in cloudabi was changed too. But I notice copyright banners in those files, should we ping cloudabi people?
* I formatted files after moving tests around. I think that may make it easier to review :p .
* Some files don't need `ignore-tidy-filelength` anymore.

3 years agoAuto merge of #76030 - davidtwco:fewer-names-llvm-type-of, r=eddyb
bors [Mon, 31 Aug 2020 18:04:29 +0000 (18:04 +0000)]
Auto merge of #76030 - davidtwco:fewer-names-llvm-type-of, r=eddyb

cg_llvm: `fewer_names` in `uncached_llvm_type`

This PR changes `uncached_llvm_type` so that a named struct type (with an empty name) is always created when the `fewer_names` option is enabled. By skipping the generation of names, we can improve perf. Giving `LLVMStructCreateNamed` an empty name works because LLVM will perform random renames to avoid collisions. Needs a perf run!

cc @eddyb (whom I've discussed this with)

3 years agoAuto merge of #75936 - sdroege:chunks-exact-construction-bounds-check, r=nagisa
bors [Mon, 31 Aug 2020 15:55:13 +0000 (15:55 +0000)]
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.

3 years agoAuto merge of #76159 - matklad:rollup-8jydjg3, r=matklad
bors [Mon, 31 Aug 2020 13:30:13 +0000 (13:30 +0000)]
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

3 years agoRollup merge of #76127 - petrochenkov:lld, r=Mark-Simulacrum
Aleksey Kladov [Mon, 31 Aug 2020 13:22:45 +0000 (15:22 +0200)]
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

3 years agoRollup merge of #76115 - calebcartwright:parser-fn-visibility, r=matklad
Aleksey Kladov [Mon, 31 Aug 2020 13:22:43 +0000 (15:22 +0200)]
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`

https://github.com/rust-lang/rust/blob/db534b3ac286cf45688c3bbae6aa6e77439e52d2/src/librustc_parse/parser/mod.rs#L433-L436

3 years agoRollup merge of #76075 - marmeladema:remove-once-cell-crate, r=matklad
Aleksey Kladov [Mon, 31 Aug 2020 13:22:42 +0000 (15:22 +0200)]
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.

3 years agoRollup merge of #76050 - matklad:pos, r=petrochenkov
Aleksey Kladov [Mon, 31 Aug 2020 13:22:40 +0000 (15:22 +0200)]
Rollup merge of #76050 - matklad:pos, r=petrochenkov

Remove unused function

3 years agoRollup merge of #75938 - Amjad50:min_const_generics-tests-revisions, r=lcnr
Aleksey Kladov [Mon, 31 Aug 2020 13:22:38 +0000 (15:22 +0200)]
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

3 years agoAuto merge of #76153 - matklad:rollup-vlblfup, r=matklad
bors [Mon, 31 Aug 2020 11:01:40 +0000 (11:01 +0000)]
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

3 years agoFix duplicate error messages in const_generics tests
Amjad Alsharafi [Mon, 31 Aug 2020 10:35:04 +0000 (18:35 +0800)]
Fix duplicate error messages in const_generics tests

3 years agoRollup merge of #76134 - CDirkx:patch-1, r=nagisa
Aleksey Kladov [Mon, 31 Aug 2020 10:51:55 +0000 (12:51 +0200)]
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.

3 years agoRollup merge of #76117 - mark-i-m:patch-1, r=petrochenkov
Aleksey Kladov [Mon, 31 Aug 2020 10:51:54 +0000 (12:51 +0200)]
Rollup merge of #76117 - mark-i-m:patch-1, r=petrochenkov

Update README.md

3 years agoRollup merge of #76069 - pickfire:patch-16, r=jyn514
Aleksey Kladov [Mon, 31 Aug 2020 10:51:53 +0000 (12:51 +0200)]
Rollup merge of #76069 - pickfire:patch-16, r=jyn514

Use explicit intra-doc link in path for Vec resize

r? @jyn514

3 years agoRollup merge of #76058 - pickfire:patch-11, r=jyn514
Aleksey Kladov [Mon, 31 Aug 2020 10:51:51 +0000 (12:51 +0200)]
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

3 years agoRollup merge of #76055 - pickfire:patch-9, r=jyn514
Aleksey Kladov [Mon, 31 Aug 2020 10:51:49 +0000 (12:51 +0200)]
Rollup merge of #76055 - pickfire:patch-9, r=jyn514

Keep doc standard for Vec DrainFilter

r? @jyn514

3 years agoRollup merge of #76052 - aszenz:GH-66816_removes_disable_attribute_before_return...
Aleksey Kladov [Mon, 31 Aug 2020 10:51:46 +0000 (12:51 +0200)]
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

3 years agoRollup merge of #76033 - camelid:patch-7, r=Dylan-DPC
Aleksey Kladov [Mon, 31 Aug 2020 10:51:45 +0000 (12:51 +0200)]
Rollup merge of #76033 - camelid:patch-7, r=Dylan-DPC

Add missing hyphen

reference counted pointer -> reference-counted pointer

@rustbot modify labels: T-doc

3 years agoRollup merge of #76023 - pickfire:patch-4, r=jyn514
Aleksey Kladov [Mon, 31 Aug 2020 10:51:42 +0000 (12:51 +0200)]
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

3 years agoRollup merge of #75969 - nixphix:docs/mod, r=jyn514
Aleksey Kladov [Mon, 31 Aug 2020 10:51:40 +0000 (12:51 +0200)]
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
```

3 years agocg_llvm: `fewer_names` in `uncached_llvm_type`
David Wood [Fri, 28 Aug 2020 15:24:52 +0000 (16:24 +0100)]
cg_llvm: `fewer_names` in `uncached_llvm_type`

This commit changes `uncached_llvm_type` so that a named struct type
(with an empty name) is always created when the `fewer_names` option
is enabled. By skipping the generation of names, we can improve perf.
Giving `LLVMStructCreateNamed` an empty name works because LLVM will
perform random renames to avoid collisions.

Signed-off-by: David Wood <david@davidtw.co>
3 years agoAuto merge of #75932 - Amjad50:intra-doc-core-slice, r=jyn514
bors [Mon, 31 Aug 2020 09:09:37 +0000 (09:09 +0000)]
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

3 years agoAuto merge of #75926 - camelid:patch-5, r=jonas-schievink
bors [Mon, 31 Aug 2020 07:17:34 +0000 (07:17 +0000)]
Auto merge of #75926 - camelid:patch-5, r=jonas-schievink

Fix typo in release notes

3 years agoAuto merge of #76027 - davidtwco:issue-61139-remove-obsolete-pretty-printer, r=eddyb
bors [Mon, 31 Aug 2020 05:32:54 +0000 (05:32 +0000)]
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)

3 years agoAuto merge of #75082 - Aaron1011:feature/proc-macro-backtrace, r=petrochenkov
bors [Mon, 31 Aug 2020 03:19:05 +0000 (03:19 +0000)]
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.

3 years agostd: move "mod tests/benches" to separate files
Lzu Tao [Thu, 27 Aug 2020 13:45:01 +0000 (13:45 +0000)]
std: move "mod tests/benches" to separate files

Also doing fmt inplace as requested.

3 years agotidy: add new exceptions and remove std from skip list
Lzu Tao [Thu, 27 Aug 2020 13:36:02 +0000 (13:36 +0000)]
tidy: add new exceptions and remove std from skip list

Also doing fmt inplace as requested.

3 years agoAdd `-Z proc-macro-backtrace` to allow showing proc-macro panics
Aaron Hill [Mon, 31 Aug 2020 02:17:24 +0000 (22:17 -0400)]
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.

3 years agoAuto merge of #75463 - CDirkx:ordering-const, r=CDirkx
bors [Mon, 31 Aug 2020 01:28:42 +0000 (01:28 +0000)]
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

3 years agoUpdate MinGW instructions to include ninja
CDirkx [Sun, 30 Aug 2020 23:22:25 +0000 (01:22 +0200)]
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).

3 years agoAuto merge of #74668 - petrochenkov:noname, r=mark-i-m
bors [Sun, 30 Aug 2020 23:14:05 +0000 (23:14 +0000)]
Auto merge of #74668 - petrochenkov:noname, r=mark-i-m

cleanup: Remove duplicate library names from `Cargo.toml`s

3 years agoSuggest `if let x = y` when encountering `if x = y`
Esteban Küber [Wed, 26 Aug 2020 03:28:25 +0000 (20:28 -0700)]
Suggest `if let x = y` when encountering `if x = y`

Detect potential cases where `if let` was meant but `let` was left out.

Fix #44990.

3 years agoUpdate `since` to correct release
CDirkx [Sun, 30 Aug 2020 21:59:37 +0000 (23:59 +0200)]
Update `since` to correct release

`const_ordering` will stabilize in version 1.48.0

3 years agoStabilize feature `const_ordering`
CDirkx [Sun, 30 Aug 2020 21:48:54 +0000 (23:48 +0200)]
Stabilize feature `const_ordering`

3 years agorustbuild: Remove one LLD workaround
Vadim Petrochenkov [Sun, 30 Aug 2020 14:51:17 +0000 (17:51 +0300)]
rustbuild: Remove one LLD workaround

3 years agoAuto merge of #75779 - scileo:fix-issue-75492, r=petrochenkov
bors [Sun, 30 Aug 2020 21:03:06 +0000 (21:03 +0000)]
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 :)

3 years agoImprove documentation of slice::get_unchecked() / split_at_unchecked()
Sebastian Dröge [Sun, 30 Aug 2020 19:47:05 +0000 (22:47 +0300)]
Improve documentation of slice::get_unchecked() / split_at_unchecked()

Thanks to Ivan Tham, who gave the majority of these suggestions during
their review.

3 years agoGet rid of bounds check in slice::chunks_exact() and related functions during constru...
Sebastian Dröge [Wed, 26 Aug 2020 06:59:04 +0000 (09:59 +0300)]
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.

3 years agoAdd (non-public) slice::split_at_unchecked() and split_at_mut_unchecked()
Sebastian Dröge [Fri, 28 Aug 2020 05:55:41 +0000 (08:55 +0300)]
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 .

3 years agoUse string literal directly when available in format
Sasha [Fri, 28 Aug 2020 21:04:42 +0000 (23:04 +0200)]
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.

3 years agocleanup: Remove duplicate library names from `Cargo.toml`s
Vadim Petrochenkov [Thu, 23 Jul 2020 07:25:49 +0000 (10:25 +0300)]
cleanup: Remove duplicate library names from `Cargo.toml`s

3 years agodatastructures: replace `once_cell` crate with an impl from std
marmeladema [Sat, 29 Aug 2020 18:16:49 +0000 (19:16 +0100)]
datastructures: replace `once_cell` crate with an impl from std

3 years agoUpdate README.md
Who? Me?! [Sun, 30 Aug 2020 18:40:11 +0000 (13:40 -0500)]
Update README.md

3 years agoparser: restore some fn visibility for rustfmt
Caleb Cartwright [Sun, 30 Aug 2020 18:04:36 +0000 (13:04 -0500)]
parser: restore some fn visibility for rustfmt

3 years agoty: remove obsolete printer
David Wood [Fri, 28 Aug 2020 13:31:03 +0000 (14:31 +0100)]
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>
3 years agoRemove unused function
Aleksey Kladov [Sat, 29 Aug 2020 09:00:59 +0000 (11:00 +0200)]
Remove unused function

3 years agoMove lexer unit tests to rustc_lexer
Aleksey Kladov [Sat, 29 Aug 2020 10:10:16 +0000 (12:10 +0200)]
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.

3 years agoAdd unstable `const_ordering` feature, and some tests.
CDirkx [Sun, 30 Aug 2020 17:40:00 +0000 (19:40 +0200)]
Add unstable `const_ordering` feature, and some tests.

3 years agoAuto merge of #74862 - mark-i-m:mv-compiler, r=petrochenkov
bors [Sun, 30 Aug 2020 15:57:57 +0000 (15:57 +0000)]
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.

3 years agomv compiler to compiler/
mark [Fri, 28 Aug 2020 03:58:48 +0000 (22:58 -0500)]
mv compiler to compiler/

3 years agorevert Some(Item) link
Prabakaran Kumaresshan [Sun, 30 Aug 2020 13:49:20 +0000 (19:19 +0530)]
revert Some(Item) link

3 years agoAuto merge of #75176 - jyn514:impl-link, r=GuillaumeGomez,petrochenkov
bors [Sun, 30 Aug 2020 13:16:38 +0000 (13:16 +0000)]
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

3 years agoresolve: Don't speculatively load crates if this is a speculative resolution
Joshua Nelson [Sat, 29 Aug 2020 13:47:39 +0000 (09:47 -0400)]
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.

3 years agorustdoc,metadata: Debugging
Joshua Nelson [Sun, 9 Aug 2020 03:47:07 +0000 (23:47 -0400)]
rustdoc,metadata: Debugging

3 years agoadd i32::MAX link
Prabakaran Kumaresshan [Sun, 30 Aug 2020 11:37:50 +0000 (17:07 +0530)]
add i32::MAX link

3 years agoAuto merge of #75867 - estebank:async-lt-sugg-fix, r=matthewjasper
bors [Sun, 30 Aug 2020 11:25:52 +0000 (11:25 +0000)]
Auto merge of #75867 - estebank:async-lt-sugg-fix, r=matthewjasper

Account for async functions when suggesting new named lifetime

Fix #75850.

3 years agoFix intra-doc path resolution problem in `library/alloc/src/slice.rs`
Amjad Alsharafi [Sun, 30 Aug 2020 07:22:27 +0000 (15:22 +0800)]
Fix intra-doc path resolution problem in `library/alloc/src/slice.rs`

`alloc::slice` uses `core::slice` functions, documentation are copied
from there and the links as well without resolution. `crate::ptr...`
cannot be resolved in `alloc::slice`, but `ptr` itself is imported in
both `alloc::slice` and `core::slice`, so we used that instead.

3 years agoAuto merge of #75919 - rust-lang:jonas-schievink-patch-1, r=ehuss
bors [Sun, 30 Aug 2020 06:32:12 +0000 (06:32 +0000)]
Auto merge of #75919 - rust-lang:jonas-schievink-patch-1, r=ehuss

Fix typo (`thumbv8m.main-none-eabihf` is Mainline)

3 years agoAuto merge of #75901 - GuillaumeGomez:ayu-theme-button-hover-background-color, r...
bors [Sun, 30 Aug 2020 04:43:09 +0000 (04:43 +0000)]
Auto merge of #75901 - GuillaumeGomez:ayu-theme-button-hover-background-color, r=pickfire

Improve theme button hover background color

Fixes #75880.

![Screenshot from 2020-08-25 13-44-01](https://user-images.githubusercontent.com/3050060/91170922-e60b1880-e6d9-11ea-9eb1-61a44cdc28d9.png)
![Screenshot from 2020-08-25 13-43-43](https://user-images.githubusercontent.com/3050060/91170924-e73c4580-e6d9-11ea-969e-616bf4130975.png)

r? @pickfire

3 years agoAuto merge of #76093 - jyn514:prim-assoc-items, r=Manishearth
bors [Sun, 30 Aug 2020 02:36:48 +0000 (02:36 +0000)]
Auto merge of #76093 - jyn514:prim-assoc-items, r=Manishearth

Fix intra-doc links for associated constants

Previously, only associated functions would be resolved. Fixes the issues in https://github.com/rust-lang/rust/pull/75969#discussion_r477898003.

I'm a little uncomfortable hard-coding the string constants, but it looks like that's how it's done elsewhere. I might make a follow-up PR at some point putting it in one place.

Not sure how to test associated types, since AFAIK there aren't any on primitives.

r? @Manishearth

3 years agoFix intra-doc links for associated constants
Joshua Nelson [Sun, 30 Aug 2020 01:21:23 +0000 (21:21 -0400)]
Fix intra-doc links for associated constants

Previously, only associated functions would be resolved.

3 years agoAuto merge of #76090 - Dylan-DPC:rollup-eksndcr, r=Dylan-DPC
bors [Sun, 30 Aug 2020 00:47:37 +0000 (00:47 +0000)]
Auto merge of #76090 - Dylan-DPC:rollup-eksndcr, r=Dylan-DPC

Rollup of 14 pull requests

Successful merges:

 - #75832 (Move to intra-doc links for wasi/ext/fs.rs, os_str_bytes.rs…)
 - #75852 (Switch to intra-doc links in `core::hash`)
 - #75874 (Shorten liballoc doc intra link while readable)
 - #75881 (Expand rustdoc theme chooser x padding)
 - #75885 (Fix another clashing_extern_declarations false positive.)
 - #75892 (Fix typo in TLS Model in Unstable Book)
 - #75910 (Add test for issue #27130)
 - #75917 (Move to intra doc links for core::ptr::non_null)
 - #75975 (Allow --bess ing expect-tests in tools)
 - #75990 (Add __fastfail for Windows on arm/aarch64)
 - #76015 (Fix loading pretty-printers in rust-lldb script)
 - #76022 (Clean up rustdoc front-end source code)
 - #76029 (Move to intra-doc links for library/core/src/sync/atomic.rs)
 - #76057 (Move retokenize hack to save_analysis)

Failed merges:

r? @ghost

3 years agoresolve comments
Prabakaran Kumaresshan [Thu, 27 Aug 2020 03:15:07 +0000 (08:45 +0530)]
resolve comments

3 years agoSwitch to intra-doc links in core/src/{convert,iter}/mod.rs
Prabakaran Kumaresshan [Thu, 27 Aug 2020 01:13:19 +0000 (06:43 +0530)]
Switch to intra-doc links in core/src/{convert,iter}/mod.rs

3 years agoRollup merge of #76057 - matklad:remove-retokenize, r=petrochenkov
Dylan DPC [Sat, 29 Aug 2020 23:44:01 +0000 (01:44 +0200)]
Rollup merge of #76057 - matklad:remove-retokenize, r=petrochenkov

Move retokenize hack to save_analysis

closes #76046

3 years agoRollup merge of #76029 - denisvasilik:intra-doc-links-core-atomic, r=kennytm
Dylan DPC [Sat, 29 Aug 2020 23:43:59 +0000 (01:43 +0200)]
Rollup merge of #76029 - denisvasilik:intra-doc-links-core-atomic, r=kennytm

Move to intra-doc links for library/core/src/sync/atomic.rs

Helps with #75080.

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

Known issues:

* Link from core to std:

    [`Arc`]
[`std::thread::yield_now`]
[`std::thread::sleep`]
[`std::sync::Mutex`]

3 years agoRollup merge of #76022 - GuillaumeGomez:cleanup-rustdoc-front, r=jyn514
Dylan DPC [Sat, 29 Aug 2020 23:43:57 +0000 (01:43 +0200)]
Rollup merge of #76022 - GuillaumeGomez:cleanup-rustdoc-front, r=jyn514

Clean up rustdoc front-end source code

r? @jyn514

3 years agoRollup merge of #76015 - ortem:fix-lldb-script, r=Mark-Simulacrum
Dylan DPC [Sat, 29 Aug 2020 23:43:55 +0000 (01:43 +0200)]
Rollup merge of #76015 - ortem:fix-lldb-script, r=Mark-Simulacrum

Fix loading pretty-printers in rust-lldb script

Pretty-printers loading in `rust-lldb` script was broken in https://github.com/rust-lang/rust/pull/72357

This fixes https://github.com/rust-lang/rust/issues/76006

3 years agoRollup merge of #75990 - rylev:arm-fastfail, r=alexcrichton
Dylan DPC [Sat, 29 Aug 2020 23:43:54 +0000 (01:43 +0200)]
Rollup merge of #75990 - rylev:arm-fastfail, r=alexcrichton

Add __fastfail for Windows on arm/aarch64

Fixes #73215

3 years agoRollup merge of #75975 - matklad:snapshot-tests, r=Mark-Simulacrum
Dylan DPC [Sat, 29 Aug 2020 23:43:52 +0000 (01:43 +0200)]
Rollup merge of #75975 - matklad:snapshot-tests, r=Mark-Simulacrum

Allow --bess ing expect-tests in tools

I haven't tried this, but I think this should do the trick, as `RustdocCrate` is a special step in bootstrap, which uses `tool_caro`

r? @ghost

3 years agoRollup merge of #75917 - poliorcetics:intra-doc-core-nonnull, r=jyn514
Dylan DPC [Sat, 29 Aug 2020 23:43:50 +0000 (01:43 +0200)]
Rollup merge of #75917 - poliorcetics:intra-doc-core-nonnull, r=jyn514

Move to intra doc links for core::ptr::non_null

Helps with #75080.

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

r? @jyn514

3 years agoRollup merge of #75910 - bugadani:testcase, r=oli-obk
Dylan DPC [Sat, 29 Aug 2020 23:43:48 +0000 (01:43 +0200)]
Rollup merge of #75910 - bugadani:testcase, r=oli-obk

Add test for issue #27130

#27130 seems to be fixed by the llvm 11 update. The issue is marked with needs-test, so here it is. As some historical context, the generated code was fine until 1.38, and remained unoptimized from 1.38 up until the current nightly.

I've also added a pattern matching version that was fine on 1.45.2.

3 years agoRollup merge of #75892 - ArekPiekarz:unstable_book_tls_model_typo, r=petrochenkov
Dylan DPC [Sat, 29 Aug 2020 23:43:46 +0000 (01:43 +0200)]
Rollup merge of #75892 - ArekPiekarz:unstable_book_tls_model_typo, r=petrochenkov

Fix typo in TLS Model in Unstable Book

3 years agoRollup merge of #75885 - jumbatm:issue75739-clashing-extern-declarations-transparent...
Dylan DPC [Sat, 29 Aug 2020 23:43:44 +0000 (01:43 +0200)]
Rollup merge of #75885 - jumbatm:issue75739-clashing-extern-declarations-transparent-nonzero, r=lcnr

Fix another clashing_extern_declarations false positive.

Fixes #75739.

Fix another clashing_extern_declarations false positive, this time for transparent newtype with a non-zero member.

r? @lcnr

3 years agoRollup merge of #75881 - pickfire:patch-5, r=GuillaumeGomez
Dylan DPC [Sat, 29 Aug 2020 23:43:42 +0000 (01:43 +0200)]
Rollup merge of #75881 - pickfire:patch-5, r=GuillaumeGomez

Expand rustdoc theme chooser x padding

![image](https://user-images.githubusercontent.com/4687791/91057476-d0eea500-e659-11ea-8c9a-e44db937da89.png)
![image](https://user-images.githubusercontent.com/4687791/91057530-e368de80-e659-11ea-9298-fbb00006d91f.png)

But I still think there is room for improvement considering mdbook.

![image](https://user-images.githubusercontent.com/4687791/91057583-f7acdb80-e659-11ea-9dc5-317caed92bc5.png)

CC @GuillaumeGomez @jyn514

3 years agoRollup merge of #75874 - pickfire:patch-3, r=jyn514
Dylan DPC [Sat, 29 Aug 2020 23:43:41 +0000 (01:43 +0200)]
Rollup merge of #75874 - pickfire:patch-3, r=jyn514

Shorten liballoc doc intra link while readable

r? @jyn514

Do you want to reviews these sort of pull requests in the future? I might send a few of them while reading vec code.

3 years agoRollup merge of #75852 - camelid:patch-3, r=jyn514
Dylan DPC [Sat, 29 Aug 2020 23:43:39 +0000 (01:43 +0200)]
Rollup merge of #75852 - camelid:patch-3, r=jyn514

Switch to intra-doc links in `core::hash`

Part of #75080.

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

3 years agoRollup merge of #75832 - kofls:intradoc-fix, r=jyn514
Dylan DPC [Sat, 29 Aug 2020 23:43:37 +0000 (01:43 +0200)]
Rollup merge of #75832 - kofls:intradoc-fix, r=jyn514

Move to intra-doc links for wasi/ext/fs.rs, os_str_bytes.rs…

…, primitive_docs.rs & poison.rs

Partial fix for #75080

r? @jyn514

3 years agoAuto merge of #75775 - matklad:rustc-lexer-rustdoc-highlight, r=GuillaumeGomez
bors [Sat, 29 Aug 2020 22:42:08 +0000 (22:42 +0000)]
Auto merge of #75775 - matklad:rustc-lexer-rustdoc-highlight, r=GuillaumeGomez

Use rustc_lexer for rustdoc syntax highlighting

r? @ghost

3 years agorustdoc: Fix intra-doc links for cross-crate re-exports of traits
Joshua Nelson [Wed, 5 Aug 2020 04:11:57 +0000 (00:11 -0400)]
rustdoc: Fix intra-doc links for cross-crate re-exports of traits

 #58972 ignored extern_traits because before #65983 was fixed, they
would always fail to resolve, giving spurious warnings.
This 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.

3 years agoAuto merge of #76016 - RalfJung:miri, r=RalfJung
bors [Sat, 29 Aug 2020 20:54:25 +0000 (20:54 +0000)]
Auto merge of #76016 - RalfJung:miri, r=RalfJung

bump Miri

Fixes https://github.com/rust-lang/rust/issues/75970
Cc @rust-lang/miri r? @ghost

3 years agobump Miri
Ralf Jung [Fri, 28 Aug 2020 08:06:15 +0000 (10:06 +0200)]
bump Miri

3 years agoAuto merge of #75713 - mati865:netbsd_zlib, r=Mark-Simulacrum
bors [Sat, 29 Aug 2020 19:04:26 +0000 (19:04 +0000)]
Auto merge of #75713 - mati865:netbsd_zlib, r=Mark-Simulacrum

Enable zlib for NetBSD

NetBSD Docker dist job passed locally.

3 years agoAuto merge of #75754 - joshtriplett:wip-perf-snappy, r=Mark-Simulacrum
bors [Sat, 29 Aug 2020 16:59:39 +0000 (16:59 +0000)]
Auto merge of #75754 - joshtriplett:wip-perf-snappy, r=Mark-Simulacrum

Switch to Snappy compression for metadata

3 years agoRemove empty vec assertion flow distrupt
Ivan Tham [Sat, 29 Aug 2020 15:07:40 +0000 (23:07 +0800)]
Remove empty vec assertion flow distrupt

Co-authored-by: Joshua Nelson <joshua@yottadb.com>
3 years agoReuse description from drain_filter
Ivan Tham [Sat, 29 Aug 2020 14:39:34 +0000 (22:39 +0800)]
Reuse description from drain_filter

Co-authored-by: Joshua Nelson <joshua@yottadb.com>
3 years agoAuto merge of #76034 - flip1995:clippyup, r=Manishearth
bors [Sat, 29 Aug 2020 14:36:46 +0000 (14:36 +0000)]
Auto merge of #76034 - flip1995:clippyup, r=Manishearth

Update Clippy

Bi-weekly Clippy update, as per the [new policy](https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md#syncing-back-changes-in-clippy-to-rust-langrust).

r? @Manishearth

3 years agoUse explicit intra-doc link in path for Vec resize
Ivan Tham [Sat, 29 Aug 2020 12:40:05 +0000 (20:40 +0800)]
Use explicit intra-doc link in path for Vec resize

3 years agoAuto merge of #75370 - simonvandel:optimize-if-condition-on-int-to-switch, r=oli-obk
bors [Sat, 29 Aug 2020 12:31:56 +0000 (12:31 +0000)]
Auto merge of #75370 - simonvandel:optimize-if-condition-on-int-to-switch, r=oli-obk

New pass to optimize `if`conditions on integrals to switches on the integer

Fixes #75144

 Pass to convert `if` conditions on integrals into switches on the integral.
 For an example, it turns something like

 ```
 _3 = Eq(move _4, const 43i32);
 StorageDead(_4);
 switchInt(_3) -> [false: bb2, otherwise: bb3];
 ```

 into:

 ```
 switchInt(_4) -> [43i32: bb3, otherwise: bb2];
 ```

3 years agoNew pass to optimize `if`conditions on integrals to switches on the integer
Simon Vandel Sillesen [Mon, 10 Aug 2020 18:27:41 +0000 (20:27 +0200)]
New pass to optimize `if`conditions on integrals to switches on the integer
Fixes #75144

3 years agoAllow --bess ing expect-tests in tools
Aleksey Kladov [Thu, 27 Aug 2020 11:12:40 +0000 (13:12 +0200)]
Allow --bess ing expect-tests in tools

See #75773 and #75775

3 years agoUse an id instead of a function
Guillaume Gomez [Sat, 29 Aug 2020 10:38:50 +0000 (12:38 +0200)]
Use an id instead of a function

3 years agoUse assertions on Vec doc
Ivan Tham [Sat, 29 Aug 2020 10:38:18 +0000 (18:38 +0800)]
Use assertions on Vec doc

Clarify what the state of Vec after with_capacity on doc.

3 years agoExplicitly look for 'thumb-mode' before using __fastfail on 'arm'
Ryan Levick [Sat, 29 Aug 2020 10:30:49 +0000 (12:30 +0200)]
Explicitly look for 'thumb-mode' before using __fastfail on 'arm'

3 years agoMove retokenize hack to save_analysis
Aleksey Kladov [Sat, 29 Aug 2020 09:38:15 +0000 (11:38 +0200)]
Move retokenize hack to save_analysis

3 years agoRemove brackets in drain filter docs
Ivan Tham [Sat, 29 Aug 2020 10:23:29 +0000 (18:23 +0800)]
Remove brackets in drain filter docs

3 years agoKeep doc standard for Vec DrainFilter
Ivan Tham [Sat, 29 Aug 2020 10:21:47 +0000 (18:21 +0800)]
Keep doc standard for Vec DrainFilter