]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoTest that type alias impl trait happens in a submodule
Santiago Pastorino [Thu, 19 Aug 2021 21:18:34 +0000 (18:18 -0300)]
Test that type alias impl trait happens in a submodule

2 years agoAuto merge of #88002 - hermitcore:unbox-mutex, r=dtolnay
bors [Thu, 19 Aug 2021 09:08:11 +0000 (09:08 +0000)]
Auto merge of #88002 - hermitcore:unbox-mutex, r=dtolnay

Unbox mutexes, condvars and rwlocks on hermit

[RustyHermit](https://github.com/hermitcore/rusty-hermit) provides now movable synchronization primitives and we are able to unbox mutexes and condvars.

2 years agoAuto merge of #87986 - Aaron1011:incr-double-panic, r=estebank
bors [Thu, 19 Aug 2021 06:27:17 +0000 (06:27 +0000)]
Auto merge of #87986 - Aaron1011:incr-double-panic, r=estebank

Prevent double panic when handling incremental fingerprint mismatch

When an incremental fingerprint mismatch occurs, we debug-print
our `DepNode` and query result. Unfortunately, the debug printing
process may cause us to run additional queries, which can result
in a re-entrant fingerprint mismatch error.

To avoid a double panic, this commit adds a thread-local variable
to detect re-entrant calls.

2 years agoAuto merge of #88143 - GuillaumeGomez:rollup-sgh318f, r=GuillaumeGomez
bors [Thu, 19 Aug 2021 03:45:50 +0000 (03:45 +0000)]
Auto merge of #88143 - GuillaumeGomez:rollup-sgh318f, r=GuillaumeGomez

Rollup of 10 pull requests

Successful merges:

 - #87818 (Fix anchors display in rustdoc)
 - #87983 (Use more accurate spans when proposing adding lifetime to item)
 - #88012 (Change WASI's `RawFd` from `u32` to `c_int` (`i32`).)
 - #88031 (Make `BuildHasher` object safe)
 - #88036 (Fix dead code warning when inline const is used in pattern)
 - #88082 (Take into account jobs number for rustdoc GUI tests)
 - #88109 (Fix environment variable getter docs)
 - #88111 (Add background-color on clickable definitions in source code)
 - #88129 (Fix dataflow graphviz bug, make dataflow graphviz modules public)
 - #88136 (Move private_unused.rs test to impl-trait)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoAuto merge of #87818 - GuillaumeGomez:anchors-display-rustdoc, r=camelid
bors [Thu, 19 Aug 2021 01:05:03 +0000 (01:05 +0000)]
Auto merge of #87818 - GuillaumeGomez:anchors-display-rustdoc, r=camelid

Fix anchors display in rustdoc

Fixes https://github.com/rust-lang/rust/issues/87611 (it simplifies the positioning and fix the background).

![Screenshot from 2021-08-06 16-47-03](https://user-images.githubusercontent.com/3050060/128531105-61d1c21f-4a4d-4d68-aedf-9bfe0332f8ae.png)
![Screenshot from 2021-08-06 16-47-10](https://user-images.githubusercontent.com/3050060/128531109-b2ea8065-10b0-4400-9507-322122e42e78.png)
![Screenshot from 2021-08-06 16-47-14](https://user-images.githubusercontent.com/3050060/128531111-8a17cbdb-29e8-4baa-a0d6-81aa4f6ac6ed.png)

r? `@camelid`

2 years agoRollup merge of #88136 - spastorino:fix-test-directory, r=oli-obk
Guillaume Gomez [Wed, 18 Aug 2021 17:55:06 +0000 (19:55 +0200)]
Rollup merge of #88136 - spastorino:fix-test-directory, r=oli-obk

Move private_unused.rs test to impl-trait

This test was added to fix this issue #55124 which is about impl traits but not related with type alias impl traits.

r? `@oli-obk`

`@bors` rollup=always

2 years agoRollup merge of #88129 - willcrichton:expose-graphviz-modules, r=ecstatic-morse
Guillaume Gomez [Wed, 18 Aug 2021 17:55:04 +0000 (19:55 +0200)]
Rollup merge of #88129 - willcrichton:expose-graphviz-modules, r=ecstatic-morse

Fix dataflow graphviz bug, make dataflow graphviz modules public

I'm working on a rustc plugin that uses the dataflow framework for MIR analysis. I've found the graphviz utilities extremely helpful for debugging. However, I had to fork the compiler to expose them since they're currently private. I would appreciate if they could be made public so I can build against a nightly instead of a custom fork. Specifically, this PR:

* Makes public the `rustc_mir::dataflow::framework::graphviz` module.
* Makes public the `rustc_mir::util::pretty::write_mir_fn` function.

Here's a concrete example of how I'm using the graphviz module: https://github.com/willcrichton/flowistry/blob/97b843b8b06b4004fbb79b5fcfca3e33c7143bc0/src/slicing/mod.rs#L186-L203

Additionally, this PR fixes a small bug in the diff code that incorrectly shows the updated object as the old object.

r? `@ecstatic-morse`

2 years agoRollup merge of #88111 - GuillaumeGomez:background-color-jump-to-def, r=jhpratt
Guillaume Gomez [Wed, 18 Aug 2021 17:55:03 +0000 (19:55 +0200)]
Rollup merge of #88111 - GuillaumeGomez:background-color-jump-to-def, r=jhpratt

Add background-color on clickable definitions in source code

Someone suggested to add a decoration on clickable elements in the source code pages:

![Screenshot from 2021-08-17 14-49-39](https://user-images.githubusercontent.com/3050060/129728911-def74f9e-50e2-40d2-b512-e23f1b3d0409.png)
![Screenshot from 2021-08-17 14-49-47](https://user-images.githubusercontent.com/3050060/129728925-14aec500-82ff-4336-955a-4173c769deeb.png)
![Screenshot from 2021-08-17 14-49-52](https://user-images.githubusercontent.com/3050060/129728927-a8a89d7a-e837-4ff5-b094-35be23629d14.png)

The idea is to not disturb the reading while telling the reader "you can click on this one", which is why it's not a text decoration.

What do you think `@rust-lang/rustdoc` ?

r? `@Nemo157`

2 years agoRollup merge of #88109 - inquisitivecrystal:env-docs, r=m-ou-se
Guillaume Gomez [Wed, 18 Aug 2021 17:55:02 +0000 (19:55 +0200)]
Rollup merge of #88109 - inquisitivecrystal:env-docs, r=m-ou-se

Fix environment variable getter docs

`@RalfJung` pointed out a number of errors and suboptimal choices I made in my documentation for #86183. This PR should (hopefully) fix the problems they've identified.

2 years agoRollup merge of #88082 - GuillaumeGomez:rustdoc-gui-jobs-opt, r=dns2utf8
Guillaume Gomez [Wed, 18 Aug 2021 17:55:00 +0000 (19:55 +0200)]
Rollup merge of #88082 - GuillaumeGomez:rustdoc-gui-jobs-opt, r=dns2utf8

Take into account jobs number for rustdoc GUI tests

Fixes #88054.

r? `@Mark-Simulacrum`

2 years agoRollup merge of #88036 - nbdd0121:const3, r=petrochenkov
Guillaume Gomez [Wed, 18 Aug 2021 17:54:59 +0000 (19:54 +0200)]
Rollup merge of #88036 - nbdd0121:const3, r=petrochenkov

Fix dead code warning when inline const is used in pattern

Fixes #78171

2 years agoRollup merge of #88031 - ibraheemdev:build-hasher-object-safe, r=m-ou-se
Guillaume Gomez [Wed, 18 Aug 2021 17:54:57 +0000 (19:54 +0200)]
Rollup merge of #88031 - ibraheemdev:build-hasher-object-safe, r=m-ou-se

Make `BuildHasher` object safe

Resolves #87991

2 years agoRollup merge of #88012 - sunfishcode:sunfishcode/wasi-raw-fd-c-int, r=alexcrichton
Guillaume Gomez [Wed, 18 Aug 2021 17:54:56 +0000 (19:54 +0200)]
Rollup merge of #88012 - sunfishcode:sunfishcode/wasi-raw-fd-c-int, r=alexcrichton

Change WASI's `RawFd` from `u32` to `c_int` (`i32`).

WASI previously used `u32` as its `RawFd` type, since its "file descriptors"
are unsigned table indices, and there's no fundamental reason why WASI can't
have more than 2^31 handles.

However, this creates myriad little incompability problems with code
that also supports Unix platforms, where `RawFd` is `c_int`. While WASI
isn't a Unix, it often shares code with Unix, and this difference made
such shared code inconvenient. #87329 is the most recent example of such
code.

So, switch WASI to use `c_int`, which is `i32`. This will mean that code
intending to support WASI should ideally avoid assuming that negative file
descriptors are invalid, even though POSIX itself says that file descriptors
are never negative.

This is a breaking change, but `RawFd` is considerd an experimental
feature in [the documentation].

[the documentation]: https://doc.rust-lang.org/stable/std/os/wasi/io/type.RawFd.html

r? `@alexcrichton`

2 years agoRollup merge of #87983 - estebank:smaller-lt-spans, r=oli-obk
Guillaume Gomez [Wed, 18 Aug 2021 17:54:55 +0000 (19:54 +0200)]
Rollup merge of #87983 - estebank:smaller-lt-spans, r=oli-obk

Use more accurate spans when proposing adding lifetime to item

2 years agoRollup merge of #87818 - GuillaumeGomez:anchors-display-rustdoc, r=camelid
Guillaume Gomez [Wed, 18 Aug 2021 17:54:54 +0000 (19:54 +0200)]
Rollup merge of #87818 - GuillaumeGomez:anchors-display-rustdoc, r=camelid

Fix anchors display in rustdoc

Fixes https://github.com/rust-lang/rust/issues/87611 (it simplifies the positioning and fix the background).

![Screenshot from 2021-08-06 16-47-03](https://user-images.githubusercontent.com/3050060/128531105-61d1c21f-4a4d-4d68-aedf-9bfe0332f8ae.png)
![Screenshot from 2021-08-06 16-47-10](https://user-images.githubusercontent.com/3050060/128531109-b2ea8065-10b0-4400-9507-322122e42e78.png)
![Screenshot from 2021-08-06 16-47-14](https://user-images.githubusercontent.com/3050060/128531111-8a17cbdb-29e8-4baa-a0d6-81aa4f6ac6ed.png)

r? `@camelid`

2 years agoAuto merge of #86700 - lqd:matthews-nll-hrtb-errors, r=nikomatsakis
bors [Wed, 18 Aug 2021 15:54:59 +0000 (15:54 +0000)]
Auto merge of #86700 - lqd:matthews-nll-hrtb-errors, r=nikomatsakis

Matthew's work on improving NLL's "higher-ranked subtype error"s

This PR rebases `@matthewjasper's` [branch](https://github.com/matthewjasper/rust/tree/nll-hrtb-errors) which has great work to fix the obscure higher-ranked subtype errors that are tracked in #57374.

These are a blocker to turning full NLLs on, and doing some internal cleanups to remove some of the old region code.

The goal is so `@nikomatsakis` can take a look at this early, and I'll then do my best to help do the changes and followup work to land this work, and move closer to turning off the migration mode.

I've only updated the branch and made it compile, removed a warning or two.

r? `@nikomatsakis`

(Here's the [zulip topic to discuss this](https://rust-lang.zulipchat.com/#narrow/stream/122657-t-compiler.2Fwg-nll/topic/.2357374.3A.20improving.20higher-ranked.20subtype.20errors.20via.20.2386700) that Niko wanted)

2 years agoreview comment: use newtype to deduplicate logic
Esteban Kuber [Wed, 18 Aug 2021 12:00:07 +0000 (12:00 +0000)]
review comment: use newtype to deduplicate logic

2 years agoAuto merge of #88127 - ehuss:update-cargo, r=ehuss
bors [Wed, 18 Aug 2021 13:24:17 +0000 (13:24 +0000)]
Auto merge of #88127 - ehuss:update-cargo, r=ehuss

Update cargo

8 commits in b51439fd8b505d4800a257acfecf3c69f81e35cf..e96bdb0c3d0a418e7fcd7fbd69be08abf830b4bc
2021-08-09 18:40:05 +0000 to 2021-08-17 22:58:47 +0000
- Support using rustbot to ping the Windows group (rust-lang/cargo#9802)
- Show information about abnormal `fix` errors. (rust-lang/cargo#9799)
- Bump jobserver. (rust-lang/cargo#9798)
- Render build-std web links as hyperlinks (rust-lang/cargo#9795)
- Teach cargo to failfast on recursive/corecursive aliases (rust-lang/cargo#9791)
- Fix value-after-table error with profiles. (rust-lang/cargo#9789)
- Fix plugin registrar change. (rust-lang/cargo#9790)
- Ability to specify the output name for a bin target different from the crate name (rust-lang/cargo#9627)

2 years agoMove private_unused.rs test to impl-trait
Santiago Pastorino [Wed, 18 Aug 2021 12:11:43 +0000 (09:11 -0300)]
Move private_unused.rs test to impl-trait

2 years agoreview comment: reduce duplication
Esteban Kuber [Wed, 18 Aug 2021 11:14:33 +0000 (11:14 +0000)]
review comment: reduce duplication

2 years agoFix anchors display in rustdoc
Guillaume Gomez [Fri, 6 Aug 2021 14:47:35 +0000 (16:47 +0200)]
Fix anchors display in rustdoc

2 years agoAuto merge of #87781 - est31:remove_box, r=oli-obk
bors [Wed, 18 Aug 2021 10:43:27 +0000 (10:43 +0000)]
Auto merge of #87781 - est31:remove_box, r=oli-obk

Remove box syntax from compiler and tools

Removes box syntax from the compiler and tools. In #49733, the future of box syntax is uncertain and the use in the compiler was listed as one of the reasons to keep it. Removal of box syntax [might affect the code generated](https://github.com/rust-lang/rust/pull/49646#issuecomment-379219615) and slow down the compiler so I'd recommend doing a perf run on this.

2 years agoUse more accurate spans when proposing adding lifetime to item
Esteban Kuber [Thu, 12 Aug 2021 18:54:29 +0000 (18:54 +0000)]
Use more accurate spans when proposing adding lifetime to item

2 years agoAuto merge of #87985 - nbdd0121:asm, r=Amanieu
bors [Wed, 18 Aug 2021 08:14:16 +0000 (08:14 +0000)]
Auto merge of #87985 - nbdd0121:asm, r=Amanieu

Forbid `!` from being used in `asm!` output

Fixes #87802

r? `@Amanieu`

2 years agoadd fixme about the `type_op_normalize` query in NLL HRTB diagnostics
Rémy Rakic [Wed, 18 Aug 2021 07:49:32 +0000 (09:49 +0200)]
add fixme about the `type_op_normalize` query in NLL HRTB diagnostics

2 years agoremove box_syntax uses from cranelift and tools
Marcel Hellwig [Fri, 6 Aug 2021 15:14:27 +0000 (17:14 +0200)]
remove box_syntax uses from cranelift and tools

2 years agoRemove box syntax from rustc_lint
est31 [Thu, 5 Aug 2021 03:39:52 +0000 (05:39 +0200)]
Remove box syntax from rustc_lint

2 years agoRemove box syntax from rustc_mir
est31 [Thu, 5 Aug 2021 03:36:38 +0000 (05:36 +0200)]
Remove box syntax from rustc_mir

2 years agoRemove box syntax from rustc_middle
est31 [Thu, 5 Aug 2021 03:14:53 +0000 (05:14 +0200)]
Remove box syntax from rustc_middle

2 years agoRemove box syntax from rustc_parse
est31 [Thu, 5 Aug 2021 02:58:59 +0000 (04:58 +0200)]
Remove box syntax from rustc_parse

2 years agoRemove box syntax from rustc_serialize
est31 [Thu, 5 Aug 2021 02:53:51 +0000 (04:53 +0200)]
Remove box syntax from rustc_serialize

2 years agoRemove box syntax from rustc_typeck
est31 [Thu, 5 Aug 2021 02:50:39 +0000 (04:50 +0200)]
Remove box syntax from rustc_typeck

2 years agoRemove box syntax from rustc_infer
est31 [Thu, 5 Aug 2021 02:43:06 +0000 (04:43 +0200)]
Remove box syntax from rustc_infer

2 years agoRemove box syntax from rustc_builtin_macros
est31 [Thu, 5 Aug 2021 01:53:21 +0000 (03:53 +0200)]
Remove box syntax from rustc_builtin_macros

2 years agoRemove box syntax from rustc_ast
est31 [Thu, 5 Aug 2021 01:48:54 +0000 (03:48 +0200)]
Remove box syntax from rustc_ast

2 years agoRemove box syntax from rustc_mir_build
est31 [Thu, 5 Aug 2021 01:16:19 +0000 (03:16 +0200)]
Remove box syntax from rustc_mir_build

2 years agoAuto merge of #87738 - lqd:polonius-master, r=nikomatsakis
bors [Wed, 18 Aug 2021 05:50:55 +0000 (05:50 +0000)]
Auto merge of #87738 - lqd:polonius-master, r=nikomatsakis

Update `polonius-engine` to 0.13.0

This PR updates the use of `polonius-engine` to the recently released 0.13.0:
- this version renamed a lot of relations to match the current terminology
- "illegal subset relationships errors" (AKA "subset errors" or "universal region errors" in rustc parlance) have been implemented in all variants, and therefore the `Hybrid` variant can be the rustc default once again
- some of the blessed expectations were updated: new tests have been added since the last time I updated the tests, diagnostics have changed, etc.

In particular:
- a few tests had trivial expectations changes such as basic diagnostics changes for the migrate-mode and full NLLs
- others were recursion and lengths limits which emits a file, and under the polonius compare-mode, the folder has a different name
- a few tests were ignored in the NLL compare-mode for reasons that obviously also apply to Polonius
- some diagnostics were unified so that older expectations no longer made sense: the NLL and Polonius outputs were identical.
- in a few cases Polonius gets a chance to emit more errors than NLLs

A few tests in the compare-mode still are super slow and trigger the 60s warning, or OOM rustc during fact generation, and I've detailed these [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/186049-t-compiler.2Fwg-polonius/topic/Challenges.20for.20move.2Finit.2C.20liveness.2C.20and.20.60Location.3A.3AAll.60):
- `src/test/ui/numbers-arithmetic/saturating-float-casts.rs` -> OOM during rustc fact generation
- `src/test/ui/numbers-arithmetic/num-wrapping.rs`
- `src/test/ui/issues/issue-72933-match-stack-overflow.rs`
- `src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs`
- `src/test/ui/repr/repr-no-niche.rs`

In addition, 2 tests don't currently pass and I didn't want to bless them now: they deal with HRTBs and miss errors that NLLs emit. We're currently trying to see if we need chalk to deal with HRTB errors (as we thought we would have to) but during the recent sprint, we discovered that we may be able to detect some of these errors in a way that resembles subset errors:
- `ui/hrtb/hrtb-just-for-static.rs` -> 3 errors in NLL, 2 in polonius: a missing error about HRTB + needing to outlive 'static
- `ui/issues/issue-26217.rs` -> missing HRTB that makes the test compile instead of emitting an error

We'll keep talking about this at the next sprint as well.

cc `@rust-lang/wg-polonius` r? `@nikomatsakis`

2 years agoFix bug in fmt_diff_with
Will Crichton [Wed, 18 Aug 2021 03:55:15 +0000 (20:55 -0700)]
Fix bug in fmt_diff_with

2 years agoAuto merge of #87728 - GuillaumeGomez:doc-test-attr-checks, r=jyn514
bors [Wed, 18 Aug 2021 03:21:12 +0000 (03:21 +0000)]
Auto merge of #87728 - GuillaumeGomez:doc-test-attr-checks, r=jyn514

Add "doc(test(...))" attribute checks

Fixes #82672.

r? `@camelid`

2 years agoAuto merge of #86860 - fee1-dead:stabilize, r=LeSeulArtichaut
bors [Wed, 18 Aug 2021 01:00:17 +0000 (01:00 +0000)]
Auto merge of #86860 - fee1-dead:stabilize, r=LeSeulArtichaut

Stabilize `arbitrary_enum_discriminant`

Closes #60553.

----

## Stabilization Report

_copied from https://github.com/rust-lang/rust/issues/60553#issuecomment-865922311_

### Summary

Enables a user to specify *explicit* discriminants on arbitrary enums.

Previously, this was hard to achieve:

```rust
#[repr(u8)]
enum Foo {
    A(u8) = 0,
    B(i8) = 1,
    C(bool) = 42,
}
```

Someone would need to add 41 hidden variants in between as a workaround with implicit discriminants.

In conjunction with [RFC 2195](https://github.com/rust-lang/rfcs/blob/master/text/2195-really-tagged-unions.md), this feature would provide more flexibility for FFI and unsafe code involving enums.

### Test cases

Most tests are in [`src/test/ui/enum-discriminant`](https://github.com/rust-lang/rust/tree/master/src/test/ui/enum-discriminant), there are two [historical](https://github.com/rust-lang/rust/blob/master/src/test/ui/parser/tag-variant-disr-non-nullary.rs) [tests](https://github.com/rust-lang/rust/blob/master/src/test/ui/parser/issue-17383.rs) that are now covered by the feature (removed by this pr due to them being obsolete).

### Edge cases

The feature is well defined and does not have many edge cases.
One [edge case](https://github.com/rust-lang/rust/issues/70509) was related to another unstable feature named `repr128` and is resolved.

### Previous PRs

The [implementation PR](https://github.com/rust-lang/rust/pull/60732) added documentation to the Unstable Book, https://github.com/rust-lang/reference/pull/1055 was opened as a continuation of https://github.com/rust-lang/reference/pull/639.

### Resolution of unresolved questions

The questions are resolved in https://github.com/rust-lang/rust/issues/60553#issuecomment-511235271.

----

(someone please add `needs-fcp`)

2 years agoUpdate cargo
Eric Huss [Wed, 18 Aug 2021 00:38:07 +0000 (17:38 -0700)]
Update cargo

2 years agoExpose graphviz modules
Will Crichton [Tue, 17 Aug 2021 23:12:11 +0000 (16:12 -0700)]
Expose graphviz modules

2 years agoAuto merge of #86808 - fee1-dead:constify-1, r=oli-obk
bors [Tue, 17 Aug 2021 22:30:09 +0000 (22:30 +0000)]
Auto merge of #86808 - fee1-dead:constify-1, r=oli-obk

constified implementations of `Default`

2 years agoAuto merge of #86977 - vakaras:body_with_borrowck_facts, r=nikomatsakis
bors [Tue, 17 Aug 2021 19:08:31 +0000 (19:08 +0000)]
Auto merge of #86977 - vakaras:body_with_borrowck_facts, r=nikomatsakis

Enable compiler consumers to obtain mir::Body with Polonius facts.

This PR adds a function (``get_body_with_borrowck_facts``) that can be used by compiler consumers to obtain ``mir::Body`` with accompanying borrow checker information.

The most important borrow checker information that [our verifier called Prusti](https://github.com/viperproject/prusti-dev) needs is lifetime constraints. I have not found a reasonable way to compute the lifetime constraints on the Prusti side. In the compiler, the constraints are computed during the borrow checking phase and then dropped. This PR adds an additional parameter to the `do_mir_borrowck` function that tells it to return the computed information instead of dropping it.

The additionally returned information by `do_mir_borrowck` contains a ``mir::Body`` with non-erased lifetime regions and Polonius facts. I have decided to reuse the Polonius facts because this way I needed fewer changes to the compiler and Polonius facts contains other useful information that we otherwise would need to recompute.

Just FYI: up to now, Prusti was obtaining this information by [parsing the compiler logs](https://github.com/viperproject/prusti-dev/blob/b58ced8dfd14ef30582b503d517167ccd771eaff/prusti-interface/src/environment/borrowck/regions.rs#L25-L39). This is not only a hacky approach, but we also reached its limits.

r? `@nikomatsakis`

2 years agoAuto merge of #88083 - m-ou-se:non-fmt-panics-suggest-debug, r=estebank
bors [Tue, 17 Aug 2021 16:43:40 +0000 (16:43 +0000)]
Auto merge of #88083 - m-ou-se:non-fmt-panics-suggest-debug, r=estebank

Improve non_fmt_panics suggestion based on trait impls.

This improves the non_fmt_panics lint suggestions by checking first which trait (Display or Debug) are actually implemented on the type.

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

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

Before:

```
help: add a "{}" format string to Display the message
  |
2 |     panic!("{}", Some(1));
  |            +++++
help: or use std::panic::panic_any instead
  |
2 |     std::panic::panic_any(Some(1));
  |     ~~~~~~~~~~~~~~~~~~~~~
```

After:

```
help: add a "{:?}" format string to use the Debug implementation of `Option<i32>`
  |
2 |     panic!("{:?}", Some(1));
  |            +++++++
help: or use std::panic::panic_any instead
  |
2 |     std::panic::panic_any(Some(1));
  |     ~~~~~~~~~~~~~~~~~~~~~
```

r? `@estebank`

2 years agoAdd background-color on clickable definitions in source code
Guillaume Gomez [Tue, 17 Aug 2021 12:50:21 +0000 (14:50 +0200)]
Add background-color on clickable definitions in source code

2 years agoAuto merge of #88056 - erikdesjardins:revertzst, r=oli-obk
bors [Tue, 17 Aug 2021 14:02:55 +0000 (14:02 +0000)]
Auto merge of #88056 - erikdesjardins:revertzst, r=oli-obk

Revert "Auto merge of #83417 - erikdesjardins:enableremovezsts, r=oli-obk"

This reverts commit 8007b506ac5da629f223b755f5a5391edd5f6d01, reversing changes made to e55c13e1099b78b1a485202fabc9c1b10b1f1d15.

Fixes #88043

r? `@oli-obk`

2 years agoFix obtain-borrowck failure on Windows.
Vytautas Astrauskas [Tue, 17 Aug 2021 11:06:27 +0000 (13:06 +0200)]
Fix obtain-borrowck failure on Windows.

2 years agoFix environment variable getter docs
inquisitivecrystal [Tue, 17 Aug 2021 07:09:58 +0000 (00:09 -0700)]
Fix environment variable getter docs

2 years agoAdd ui test
Deadbeef [Mon, 16 Aug 2021 15:55:35 +0000 (15:55 +0000)]
Add ui test

2 years agoConstified `Default` implementations
Deadbeef [Sat, 14 Aug 2021 16:35:12 +0000 (16:35 +0000)]
Constified `Default` implementations

The libs-api team agrees to allow const_trait_impl to appear in the
standard library as long as stable code cannot be broken (they are
properly gated) this means if the compiler teams thinks it's okay, then
it's okay.

My priority on constifying would be:

1. Non-generic impls (e.g. Default) or generic impls with no
   bounds
2. Generic functions with bounds (that use const impls)
3. Generic impls with bounds
4. Impls for traits with associated types

For people opening constification PRs: please cc me and/or oli-obk.

2 years agoAuto merge of #87668 - estebank:tweak-bound-output, r=oli-obk
bors [Tue, 17 Aug 2021 06:59:49 +0000 (06:59 +0000)]
Auto merge of #87668 - estebank:tweak-bound-output, r=oli-obk

Use note for pointing at bound introducing requirement

Modify output for pointing where a trait bound obligation is introduced in an E0277 from using a span label to using a note in order to always preserve order of the output:

Before:
```
error[E0277]: `<<Self as Case1>::A as Iterator>::Item` doesn't implement `Debug`
  --> $DIR/bounds-on-assoc-in-trait.rs:18:28
   |
LL |     type A: Iterator<Item: Debug>;
   |                            ^^^^^ `<<Self as Case1>::A as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
   |
  ::: $SRC_DIR/core/src/fmt/mod.rs:LL:COL
   |
LL | pub trait Debug {
   | --------------- required by this bound in `Debug`
   |
   = help: the trait `Debug` is not implemented for `<<Self as Case1>::A as Iterator>::Item`
```
After:
```
error[E0277]: `<<Self as Case1>::A as Iterator>::Item` doesn't implement `Debug`
  --> $DIR/bounds-on-assoc-in-trait.rs:18:28
   |
LL |     type A: Iterator<Item: Debug>;
   |                            ^^^^^ `<<Self as Case1>::A as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
   |
   = help: the trait `Debug` is not implemented for `<<Self as Case1>::A as Iterator>::Item`
note: required by a bound in `Debug`
  --> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
   |
LL | pub trait Debug {
   | ^^^^^^^^^^^^^^^ required by this bound in `Debug`
```

2 years agoAuto merge of #87119 - jyn514:rustfmt-doc-private, r=Mark-Simulacrum
bors [Tue, 17 Aug 2021 04:18:55 +0000 (04:18 +0000)]
Auto merge of #87119 - jyn514:rustfmt-doc-private, r=Mark-Simulacrum

Document private items for rustfmt

This is possible now that https://github.com/rust-lang/rust/pull/73936 has been merged.

2 years agoAuto merge of #87990 - Aaron1011:moved-src-dir, r=cjgillot
bors [Tue, 17 Aug 2021 01:32:15 +0000 (01:32 +0000)]
Auto merge of #87990 - Aaron1011:moved-src-dir, r=cjgillot

Include (potentially remapped) working dir in crate hash

Fixes #85019

A `SourceFile` created during compilation may have a relative
path (e.g. if rustc itself is invoked with a relative path).
When we write out crate metadata, we convert all relative paths
to absolute paths using the current working directory.

However, the working directory is not included in the crate hash.
This means that the crate metadata can change while the crate
hash remains the same. Among other problems, this can cause a
fingerprint mismatch ICE, since incremental compilation uses
the crate metadata hash to determine if a foreign query is green.

This commit moves the field holding the working directory from
`Session` to `Options`, including it as part of the crate hash.

cc `@ohsayan`

2 years agoAuto merge of #88094 - m-ou-se:rollup-2fxss0q, r=m-ou-se
bors [Mon, 16 Aug 2021 22:33:36 +0000 (22:33 +0000)]
Auto merge of #88094 - m-ou-se:rollup-2fxss0q, r=m-ou-se

Rollup of 10 pull requests

Successful merges:

 - #87178 ([rustdoc] Copy only item path to clipboard rather than full `use` statement.)
 - #87677 (Adding explicit notice of lack of documentation for Tier 2 Platforms)
 - #87958 (Closure migration multispan suggestions)
 - #87967 (Detect fake spans in non_fmt_panic lint.)
 - #88011 (Enable `--all-targets` for `x.py check` unconditionally)
 - #88030 (Assign FIXMEs to me and remove obsolete ones)
 - #88052 (Update redox_syscall)
 - #88055 (Update RELEASES.md for 1.55.0)
 - #88080 (Skip assert ICE with default_method_body_is_const)
 - #88089 (Rustdoc font test)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #88089 - dns2utf8:rustdoc_font_test, r=GuillaumeGomez
Mara Bos [Mon, 16 Aug 2021 21:37:35 +0000 (23:37 +0200)]
Rollup merge of #88089 - dns2utf8:rustdoc_font_test, r=GuillaumeGomez

Rustdoc font test

 Add a font test based on #85669 fixes #85632.

r? `@jsha` `@GuillaumeGomez`

2 years agoRollup merge of #88080 - fee1-dead:iterator-const, r=oli-obk
Mara Bos [Mon, 16 Aug 2021 21:37:34 +0000 (23:37 +0200)]
Rollup merge of #88080 - fee1-dead:iterator-const, r=oli-obk

Skip assert ICE with default_method_body_is_const

functions marked with #[default_method_body_is_const] would
ICE when being const checked due to it not being a const function:
`tcx.is_const_fn_raw(did)` returns false. We should skip this assert
when it is marked with that attribute.

r? `@oli-obk`

2 years agoRollup merge of #88055 - Mark-Simulacrum:relnotes-1.55, r=Mark-Simulacrum
Mara Bos [Mon, 16 Aug 2021 21:37:33 +0000 (23:37 +0200)]
Rollup merge of #88055 - Mark-Simulacrum:relnotes-1.55, r=Mark-Simulacrum

Update RELEASES.md for 1.55.0

Reopening https://github.com/rust-lang/rust/pull/87624 after some edits and a force-push caused GitHub to close the PR.

2 years agoRollup merge of #88052 - bjorn3:update_redox_syscall, r=Mark-Simulacrum
Mara Bos [Mon, 16 Aug 2021 21:37:31 +0000 (23:37 +0200)]
Rollup merge of #88052 - bjorn3:update_redox_syscall, r=Mark-Simulacrum

Update redox_syscall

The currently pinned version doesn't compile with the latest rustc nightly

cc ``@jackpot51``

2 years agoRollup merge of #88030 - fee1-dead:fixme, r=oli-obk
Mara Bos [Mon, 16 Aug 2021 21:37:30 +0000 (23:37 +0200)]
Rollup merge of #88030 - fee1-dead:fixme, r=oli-obk

Assign FIXMEs to me and remove obsolete ones

Also fixed capitalization of documentation

We also don't need to transform predicates to be non-const since we basically ignore const predicates in non-const contexts.

r? `````@oli-obk`````

2 years agoRollup merge of #88011 - jyn514:check-all-targets, r=Mark-Simulacrum
Mara Bos [Mon, 16 Aug 2021 21:37:29 +0000 (23:37 +0200)]
Rollup merge of #88011 - jyn514:check-all-targets, r=Mark-Simulacrum

Enable `--all-targets` for `x.py check` unconditionally

Now that Cargo deduplicates diagnostics from different targets, this doesn't flood the console with
duplicate errors.

Note that this doesn't add `--all-targets` in `Builder::cargo` directly because `impl Step for Std`
actually wants to omit `--all-targets` the first time while it's still building libtest.

When passed `--all-targets`, this warns that the option isn't needed, but still continues to compile.

Fixes https://github.com/rust-lang/rust/issues/87846.
r? ``@Mark-Simulacrum``

2 years agoRollup merge of #87967 - m-ou-se:non-fmt-panic-detect-fake-spans, r=cjgillot
Mara Bos [Mon, 16 Aug 2021 21:37:28 +0000 (23:37 +0200)]
Rollup merge of #87967 - m-ou-se:non-fmt-panic-detect-fake-spans, r=cjgillot

Detect fake spans in non_fmt_panic lint.

This addresses https://github.com/rust-lang/rust/issues/87621

Some proc_macros claim that the user wrote all of the tokens it outputs, by applying a span from the input to all of the produced tokens. That can result in confusing suggestions, as in #87621. This is a simple patch that avoids suggesting anything for `panic!("{}")` if the span of `"{}"` and `panic!(..)` are identical, which is normally not possible.

2 years agoRollup merge of #87958 - m-ou-se:closure-migration-multispan-suggestions, r=estebank
Mara Bos [Mon, 16 Aug 2021 21:37:27 +0000 (23:37 +0200)]
Rollup merge of #87958 - m-ou-se:closure-migration-multispan-suggestions, r=estebank

Closure migration multispan suggestions

This changes the `rust_2021_incompatible_closure_captures` lint to only suggest inserting the parts that need to be inserted, instead of suggesting to replace the entire closure by an almost identical closure with one statement added.

Before:
```
[...]
help: add a dummy let to cause `a` to be fully captured
   |
5  ~     let _ = || {
6  +         let _ = &a;
7  +         dbg!(a.0);
8  +         println!("1");
9  +         println!("2");
10 +         println!("3");
 ...
   |

[...]
help: add a dummy let to cause `b` to be fully captured
   |
14 |     let _ = || { let _ = &b; dbg!(b.0); };
   |                ~~~~~~~~~~~~~~~~~~~~~~~~~~

[...]
help: add a dummy let to cause `c` to be fully captured
   |
16 |     let _ = || { let _ = &c; dbg!(c.0) };
   |                ~~~~~~~~~~~~~~~~~~~~~~~~~
```

After:
```
[...]
help: add a dummy let to cause `a` to be fully captured
   |
5  ~     let _ = || {
6  +         let _ = &a;
   |

[...]
help: add a dummy let to cause `b` to be fully captured
   |
14 |     let _ = || { let _ = &b; dbg!(b.0); };
   |                  +++++++++++

[...]
help: add a dummy let to cause `c` to be fully captured
   |
16 |     let _ = || { let _ = &c; dbg!(c.0) };
   |                +++++++++++++           +
```

2 years agoRollup merge of #87677 - amalik18:issue-2788-fix, r=pietroalbini
Mara Bos [Mon, 16 Aug 2021 21:37:26 +0000 (23:37 +0200)]
Rollup merge of #87677 - amalik18:issue-2788-fix, r=pietroalbini

Adding explicit notice of lack of documentation for Tier 2 Platforms

Fixing: https://github.com/rust-lang/rustup/issues/2788

2 years agoRollup merge of #87178 - moxian:rd-use, r=jyn514
Mara Bos [Mon, 16 Aug 2021 21:37:25 +0000 (23:37 +0200)]
Rollup merge of #87178 - moxian:rd-use, r=jyn514

[rustdoc] Copy only item path to clipboard rather than full `use` statement.

The (somewhat) recent addition of the "copy item import to clipboard" button is extremely nice.

However, i tend to write my code with fully qualified paths wherever feasible and only resort to `use` statements as a refactoring pass. This makes the "copy to clipboard" workflow awkward to use, as i would be copy-pasting that as, say

```rust
impl use std::ops::Add; for MyType {
```

and then go back  and remove the `use ` and `;`.

This PR removes the `use ;` decorations, making it much nicer to use for fully-qualified items. I argue, however, that this does not noticeably degrade experience for those who prefer to import items, since the hard part about those is getting the path right, and writing the `use ;` decoration can be done by hand with little effort.

2 years agoMove working checks into separate test files
Guillaume Gomez [Sat, 7 Aug 2021 12:49:34 +0000 (14:49 +0200)]
Move working checks into separate test files

2 years agoAdd UI tests for doc(test(...)) attribute checks
Guillaume Gomez [Tue, 3 Aug 2021 12:04:55 +0000 (14:04 +0200)]
Add UI tests for doc(test(...)) attribute checks

2 years agoAdd check for doc(test(...)) attribute
Guillaume Gomez [Tue, 3 Aug 2021 12:04:27 +0000 (14:04 +0200)]
Add check for doc(test(...)) attribute

2 years agoMerge the two test files as they are testing the same features
Stefan Schindler [Mon, 16 Aug 2021 19:38:30 +0000 (21:38 +0200)]
Merge the two test files as they are testing the same features

2 years agoAdd a font test based on #85669
Stefan Schindler [Mon, 16 Aug 2021 18:41:15 +0000 (20:41 +0200)]
Add a font test based on #85669

2 years agoFix double output of the summary line
Stefan Schindler [Mon, 16 Aug 2021 18:40:23 +0000 (20:40 +0200)]
Fix double output of the summary line

2 years agoUse note to point at bound introducing requirement
Esteban Küber [Sat, 31 Jul 2021 16:26:55 +0000 (09:26 -0700)]
Use note to point at bound introducing requirement

2 years agoTake into account jobs number for rustdoc gui tests
Guillaume Gomez [Mon, 16 Aug 2021 15:01:33 +0000 (17:01 +0200)]
Take into account jobs number for rustdoc gui tests

2 years agoShow correct macro name in non_fmt_panics message.
Mara Bos [Mon, 16 Aug 2021 15:39:50 +0000 (17:39 +0200)]
Show correct macro name in non_fmt_panics message.

2 years agoAuto merge of #87050 - jyn514:no-doc-primitive, r=manishearth
bors [Mon, 16 Aug 2021 15:36:44 +0000 (15:36 +0000)]
Auto merge of #87050 - jyn514:no-doc-primitive, r=manishearth

Add future-incompat lint for `doc(primitive)`

## What is `doc(primitive)`?

`doc(primitive)` is an attribute recognized by rustdoc which adds documentation for the built-in primitive types, such as `usize` and `()`. It has been stable since Rust 1.0.

## Why change anything?

`doc(primitive)` is useless for anyone outside the standard library. Since rustdoc provides no way to combine the documentation on two different primitive items, you can only replace the docs, and since the standard library already provides extensive documentation there is no reason to do so.

While fixing rustdoc's handling of primitive items (https://github.com/rust-lang/rust/pull/87073) I discovered that even rustdoc's existing handling of primitive items was broken if you had more than two crates using it (it would pick randomly between them). That meant both:
- Keeping rustdoc's existing treatment was nigh-impossible, because it was random.
- doc(primitive) was even more useless than it would otherwise be.

The only use-case for this outside the standard library is for no-std libraries which want to link to primitives (https://github.com/rust-lang/rust/issues/73423) which is being fixed in https://github.com/rust-lang/rust/pull/87073.

https://github.com/rust-lang/rust/pull/87073 makes various breaking changes to `doc(primitive)` (breaking in the sense that they change the semantics, not in that they cause code to fail to compile). It's not possible to avoid these and still fix rustdoc's issues.

## What can we do about it?

As shown by the crater run (https://github.com/rust-lang/rust/pull/87050#issuecomment-886166706), no one is actually using doc(primitive), there wasn't a single true regression in the whole run. We can either:
1. Feature gate it completely, breaking anyone who crater missed. They can easily fix the breakage just by removing the attribute.
2. add it to the `INVALID_DOC_ATTRIBUTES` future-incompat lint, and at the same time make it a no-op unless you add a feature gate. That would mean rustdoc has to look at the features of dependent crates, because it needs to know where primitives are defined in order to link to them.
3. add it to `INVALID_DOC_ATTRIBUTES`, but still use it to determine where primitives come from
4. do nothing; the behavior will silently change in https://github.com/rust-lang/rust/pull/87073.

My preference is for 2, but I would also be happy with 1 or 3. I don't think we should silently change the behavior.

This PR currently implements 3.

2 years agoAdd more assert!() tests for non_fmt_panics.
Mara Bos [Mon, 16 Aug 2021 15:35:49 +0000 (17:35 +0200)]
Add more assert!() tests for non_fmt_panics.

2 years agoAdd tests for non_fmt_panics in generic functions.
Mara Bos [Mon, 16 Aug 2021 15:33:42 +0000 (17:33 +0200)]
Add tests for non_fmt_panics in generic functions.

2 years agoUpdate non_fmt_panics test.
Mara Bos [Mon, 16 Aug 2021 15:26:08 +0000 (17:26 +0200)]
Update non_fmt_panics test.

2 years agoImprove non_fmt_panics suggestion based on trait impls.
Mara Bos [Mon, 16 Aug 2021 15:25:35 +0000 (17:25 +0200)]
Improve non_fmt_panics suggestion based on trait impls.

2 years agoAdd ui test
Deadbeef [Mon, 16 Aug 2021 14:46:08 +0000 (14:46 +0000)]
Add ui test

2 years agoSkip assert ICE with default_method_body_is_const
Deadbeef [Mon, 16 Aug 2021 11:29:05 +0000 (11:29 +0000)]
Skip assert ICE with default_method_body_is_const

functions marked with #[default_method_body_is_const] would
ICE when being const checked due to it not being a const function:
`tcx.is_const_fn_raw(did)` returns false. We should skip this assert
when it is marked with that attribute.

2 years agoUpdate test output.
Mara Bos [Thu, 12 Aug 2021 10:17:35 +0000 (12:17 +0200)]
Update test output.

2 years agoUse multi span suggestions for closure migrations.
Mara Bos [Thu, 12 Aug 2021 10:17:25 +0000 (12:17 +0200)]
Use multi span suggestions for closure migrations.

2 years agoAuto merge of #88032 - hyd-dev:no-mangle-method, r=petrochenkov
bors [Mon, 16 Aug 2021 09:38:18 +0000 (09:38 +0000)]
Auto merge of #88032 - hyd-dev:no-mangle-method, r=petrochenkov

Fix `reachable_set` for non-function items in non-library crates

I unintentionally changed `reachable_set` to ignore non-function items when `!self.any_library` in https://github.com/rust-lang/rust/pull/86492, which can lead to "undefined reference" errors in non-library (`cdylib`/`staticlib`/`bin`) crates, for example: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=6bb2c5065a9be7e40943d0541e161b5a

This PR restores the behavior of `reachable_set` for non-function items.

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

<details>
<summary>The modified test will fail with this output without the `reachable_set` change</summary>

```
---- [codegen] codegen/external-no-mangle-statics.rs#staticlib stdout ----

error in revision `staticlib`: verification with 'FileCheck' failed
status: exit status: 1
command: "/checkout/build/x86_64-unknown-linux-gnu/ci-llvm/bin/FileCheck" "--input-file" "/checkout/build/x86_64-unknown-linux-gnu/test/codegen/external-no-mangle-statics.staticlib/external-no-mangle-statics.ll" "/checkout/src/test/codegen/external-no-mangle-statics.rs" "--check-prefixes" "CHECK,NONMSVC,staticlib"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
/checkout/src/test/codegen/external-no-mangle-statics.rs:10:11: error: CHECK: expected string not found in input
// CHECK: `@A` = local_unnamed_addr constant
          ^
/checkout/build/x86_64-unknown-linux-gnu/test/codegen/external-no-mangle-statics.staticlib/external-no-mangle-statics.ll:1:1: note: scanning from here
; ModuleID = 'external_no_mangle_statics.b50529d3-cgu.0'
^
/checkout/build/x86_64-unknown-linux-gnu/test/codegen/external-no-mangle-statics.staticlib/external-no-mangle-statics.ll:1:6: note: possible intended match here
; ModuleID = 'external_no_mangle_statics.b50529d3-cgu.0'
     ^

Input file: /checkout/build/x86_64-unknown-linux-gnu/test/codegen/external-no-mangle-statics.staticlib/external-no-mangle-statics.ll
Check file: /checkout/src/test/codegen/external-no-mangle-statics.rs

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: ; ModuleID = 'external_no_mangle_statics.b50529d3-cgu.0'
check:10'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:10'1          ?                                                   possible intended match
            2: source_filename = "external_no_mangle_statics.b50529d3-cgu.0"
check:10'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            3: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
check:10'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            4: target triple = "x86_64-unknown-linux-gnu"
check:10'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            5:
check:10'0     ~
            6: !llvm.module.flags = !{!0, !1}
check:10'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            .
            .
            .
>>>>>>

------------------------------------------

failures:
    [codegen] codegen/external-no-mangle-statics.rs#staticlib
```
</details>

2 years agofix typo in bound_region_errors.rs
Rémy Rakic [Mon, 16 Aug 2021 07:07:42 +0000 (09:07 +0200)]
fix typo in bound_region_errors.rs

Co-authored-by: matthewjasper <20113453+matthewjasper@users.noreply.github.com>
2 years agoAuto merge of #84039 - jyn514:uplift-atomic-ordering, r=wesleywiser
bors [Mon, 16 Aug 2021 06:36:13 +0000 (06:36 +0000)]
Auto merge of #84039 - jyn514:uplift-atomic-ordering, r=wesleywiser

Uplift the invalid_atomic_ordering lint from clippy to rustc

This is mostly just a rebase of https://github.com/rust-lang/rust/pull/79654; I've copy/pasted the text from that PR below.

r? `@lcnr` since you reviewed the last one, but feel free to reassign.

---

This is an implementation of https://github.com/rust-lang/compiler-team/issues/390.

As mentioned, in general this turns an unconditional runtime panic into a (compile time) lint failure. It has no false positives, and the only false negatives I'm aware of are if `Ordering` isn't specified directly and is comes from an argument/constant/whatever.

As a result of it having no false positives, and the alternative always being strictly wrong, it's on as deny by default. This seems right.

In the [zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Uplift.20the.20.60invalid_atomic_ordering.60.20lint.20from.20clippy/near/218483957) `@joshtriplett` suggested that lang team should FCP this before landing it. Perhaps libs team cares too?

---

Some notes on the code for reviewers / others below

## Changes from clippy

The code is changed from [the implementation in clippy](https://github.com/rust-lang/rust-clippy/blob/68cf94f6a66e47234e3adefc6dfbe806cd6ad164/clippy_lints/src/atomic_ordering.rs) in the following ways:

1. Uses `Symbols` and `rustc_diagnostic_item`s instead of string literals.
    - It's possible I should have just invoked Symbol::intern for some of these instead? Seems better to use symbol, but it did require adding several.
2. The functions are moved to static methods inside the lint struct, as a way to namespace them.
    - There's a lot of other code in that file — which I picked as the location for this lint because `@jyn514` told me that seemed reasonable.
3. Supports unstable AtomicU128/AtomicI128.
    - I did this because it was almost easier to support them than not — not supporting them would have (ideally) required finding a way not to give them a `rustc_diagnostic_item`, which would have complicated an already big macro.
    - These don't have tests since I wasn't sure if/how I should make tests conditional on whether or not the target has the atomic... This is to a certain extent an issue of 64bit atomics too, but 128-bit atomics are much less common. Regardless, the existing tests should be *more* than thorough enough here.
4. Minor changes like:
    - grammar tweaks ("loads cannot have `Release` **and** `AcqRel` ordering" => "loads cannot have `Release` **or** `AcqRel` ordering")
    - function renames (`match_ordering_def_path` => `matches_ordering_def_path`),
    - avoiding clippy-specific helper methods that don't exist in rustc_lint and didn't seem worth adding for this case (for example `cx.struct_span_lint` vs clippy's `span_lint_and_help` helper).

## Potential issues

(This is just about the code in this PR, not conceptual issues with the lint or anything)

1. I'm not sure if I should have used a diagnostic item for `Ordering` and its variants (I couldn't figure out how really, so if I should do this some pointers would be appreciated).
    - It seems possible that failing to do this might possibly mean there are more cases this lint would miss, but I don't really know how `match_def_path` works and if it has any pitfalls like that, so maybe not.

2. I *think* I deprecated the lint in clippy (CC `@flip1995` who asked to be notified about clippy changes in the future in [this comment](https://github.com/rust-lang/rust/pull/75671#issuecomment-718731659)) but I'm not sure if I need to do anything else there.
    - I'm kind of hoping CI will catch if I missed anything, since `x.py test src/tools/clippy` fails with a lot of errors with and without my changes (and is probably a nonsense command regardless). Running `cargo test` from src/tools/clippy also fails with unrelated errors that seem like refactorings that didnt update clippy? So, honestly no clue.

3. I wasn't sure if the description/example I gave good. Hopefully it is. The example is less thorough than the one from clippy here: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_atomic_ordering. Let me know if/how I should change it if it needs changing.

4. It pulls in the `if_chain` crate. This crate was already used in clippy, and seems like it's used elsewhere in rustc, but I'm willing to rewrite it to not use this if needed (I'd prefer not to, all things being equal).

2 years agofeature gate doc(primitive)
Joshua Nelson [Sun, 11 Jul 2021 02:06:10 +0000 (22:06 -0400)]
feature gate doc(primitive)

2 years agoOnly run expensive calculations if the method name is recognized
Joshua Nelson [Wed, 14 Jul 2021 00:18:43 +0000 (20:18 -0400)]
Only run expensive calculations if the method name is recognized

2 years agoUplift the `invalid_atomic_ordering` lint from clippy to rustc
Thom Chiovoloni [Wed, 2 Dec 2020 23:16:12 +0000 (15:16 -0800)]
Uplift the `invalid_atomic_ordering` lint from clippy to rustc

- Deprecate clippy::invalid_atomic_ordering
- Use rustc_diagnostic_item for the orderings in the invalid_atomic_ordering lint
- Reduce code duplication
- Give up on making enum variants diagnostic items and just look for
`Ordering` instead

  I ran into tons of trouble with this because apparently the change to
  store HIR attrs in a side table also gave the DefIds of the
  constructor instead of the variant itself. So I had to change
  `matches_ordering` to also check the grandparent of the defid as well.

- Rename `atomic_ordering_x` symbols to just the name of the variant
- Fix typos in checks - there were a few places that said "may not be
  Release" in the diagnostic but actually checked for SeqCst in the lint.
- Make constant items const
- Use fewer diagnostic items
- Only look at arguments after making sure the method matches

  This prevents an ICE when there aren't enough arguments.

- Ignore trait methods
- Only check Ctors instead of going through `qpath_res`

  The functions take values, so this couldn't ever be anything else.

- Add if_chain to allowed dependencies
- Fix grammar
- Remove unnecessary allow

2 years agoAuto merge of #87696 - ssomers:btree_lazy_iterator_cleanup, r=Mark-Simulacrum
bors [Mon, 16 Aug 2021 03:45:26 +0000 (03:45 +0000)]
Auto merge of #87696 - ssomers:btree_lazy_iterator_cleanup, r=Mark-Simulacrum

BTree: merge the complication introduced by #81486 and #86031

Also:
- Deallocate the last few tree nodes as soon as an `into_iter` iterator steps beyond the end, instead of waiting around for the drop of the iterator (just to share more code).
- Symmetric code for backward iteration.
- Mark unsafe the methods on dying handles, modelling dying handles after raw pointers: it's the caller's responsibility to use them safely.

r? `@Mark-Simulacrum`

2 years agoadd regression test
Erik Desjardins [Sun, 15 Aug 2021 18:26:14 +0000 (14:26 -0400)]
add regression test

2 years agoRevert "Auto merge of #83417 - erikdesjardins:enableremovezsts, r=oli-obk"
Erik Desjardins [Sun, 15 Aug 2021 17:25:17 +0000 (13:25 -0400)]
Revert "Auto merge of #83417 - erikdesjardins:enableremovezsts, r=oli-obk"

This reverts commit 8007b506ac5da629f223b755f5a5391edd5f6d01, reversing
changes made to e55c13e1099b78b1a485202fabc9c1b10b1f1d15.

2 years agoDocument private items for rustfmt
Joshua Nelson [Wed, 14 Jul 2021 01:09:03 +0000 (21:09 -0400)]
Document private items for rustfmt

This is possible now that rustdoc allows passing
`--document-private-items` more than once.

2 years agoAuto merge of #80357 - c410-f3r:new-hir-let, r=matthewjasper
bors [Mon, 16 Aug 2021 00:31:42 +0000 (00:31 +0000)]
Auto merge of #80357 - c410-f3r:new-hir-let, r=matthewjasper

Introduce `hir::ExprKind::Let` - Take 2

Builds on #68577 and depends on #79328.

cc #53667

2 years agoAdd `--target` flag to `issue-85019-moved-src-dir`
Aaron Hill [Sun, 15 Aug 2021 22:37:26 +0000 (17:37 -0500)]
Add `--target` flag to `issue-85019-moved-src-dir`

2 years agoAuto merge of #87590 - Amanieu:deprecate_llvm_asm, r=nagisa
bors [Sun, 15 Aug 2021 21:22:02 +0000 (21:22 +0000)]
Auto merge of #87590 - Amanieu:deprecate_llvm_asm, r=nagisa

Deprecate llvm_asm!

We would like to remove `llvm_asm!` from the compiler once `asm!` is stabilized. This PR deprecates `llvm_asm!` to encourage any remaining users to migrate to `asm!` (or if `asm!` is not supported for their target, to add this support to rustc).

The only remaining user of `llvm_asm!` in the standard library was `black_box`, which has been rewritten to use volatile operations when `asm!` is not available on the current target.

cc `@rust-lang/wg-inline-asm`

cc `@RalfJung` for the changes to `black_box` which might affect Miri.

r? `@nagisa`

2 years agoCopy over run-make ignores from issue-83112-incr-test-moved-file
Aaron Hill [Sun, 15 Aug 2021 20:19:41 +0000 (15:19 -0500)]
Copy over run-make ignores from issue-83112-incr-test-moved-file

2 years agoUpdate rustc_codegen_cratelift for working_dir change
Aaron Hill [Thu, 12 Aug 2021 21:46:58 +0000 (16:46 -0500)]
Update rustc_codegen_cratelift for working_dir change

2 years agoInclude (potentially remapped) working dir in crate hash
Aaron Hill [Thu, 12 Aug 2021 20:30:40 +0000 (15:30 -0500)]
Include (potentially remapped) working dir in crate hash

Fixes #85019

A `SourceFile` created during compilation may have a relative
path (e.g. if rustc itself is invoked with a relative path).
When we write out crate metadata, we convert all relative paths
to absolute paths using the current working direction.

However, the working directory is not included in the crate hash.
This means that the crate metadata can change while the crate
hash remains the same. Among other problems, this can cause a
fingerprint mismatch ICE, since incremental compilation uses
the crate metadata hash to determine if a foreign query is green.

This commit moves the field holding the working directory from
`Session` to `Options`, including it as part of the crate hash.

2 years agoIntroduce hir::ExprKind::Let - Take 2
Caio [Sun, 8 Aug 2021 14:49:13 +0000 (11:49 -0300)]
Introduce hir::ExprKind::Let - Take 2