Commit graph

8510 commits

Author SHA1 Message Date
Manish Goregaokar
0352a2820d
Rollup merge of #89317 - JulianKnodt:precise_errors, r=BoxyUwU
Move generic error message to separate branches

This decomposes an error message in generic constants into more specific branches, for better
readability.

r? ``@lcnr``
2021-10-05 12:52:44 -07:00
Manish Goregaokar
60b9c5d1a9
Rollup merge of #88871 - FabianWolff:issue-88403, r=jackh726
Fix suggestion for nested struct patterns

Fixes #88403, and also a similar problem where the unused binding is in a function parameter pattern.
2021-10-05 12:52:43 -07:00
Manish Goregaokar
960e49e89b
Rollup merge of #88706 - ThePuzzlemaker:issue-88609, r=jackh726
Normalize associated type projections when checking return type of main

This fixes #88609.

Previously, the return type of `fn main()` would not have any associated type projections within normalized before checking if it implements the standard library trait `std::process::Termination`. This commit appears to fix it.

This feels vaguely symptomatic of a problem in the underlying trait solving engine, but I am not sure how I would solve that. I am unsure why the example in #88609 with `assert_impl_termination` and `fn foo()` work, but simply `fn main()` doesn't. The way that I solved this is also probably not the best way to do this, so please let me know if there is a better way to do this.

I have added a build-pass regression test for this issue.
2021-10-05 12:52:41 -07:00
bors
25ec827385 Auto merge of #89363 - oli-obk:in_tracing_we_trust, r=Mark-Simulacrum
Fix performance regression with #[instrument]

linked tracing PR: https://github.com/tokio-rs/tracing/pull/1600

regression introduced by #89048
2021-10-05 12:52:43 +00:00
bors
55111d656f Auto merge of #89266 - cjgillot:session-ich, r=michaelwoerister
Move ICH to rustc_query_system

Based on https://github.com/rust-lang/rust/pull/89183

The StableHashingContext does not need to be in rustc_middle.

This PR moves it to rustc_query_system. This will avoid a dependency between rustc_ast_lowering and rustc_middle in https://github.com/rust-lang/rust/pull/89124.
2021-10-05 09:45:11 +00:00
Manish Goregaokar
bf62c6d710
Rollup merge of #89504 - Aaron1011:rpit-nll-static, r=nikomatsakis
Don't suggest replacing region with 'static in NLL

Fixes #73159

This is similar to #69350 - if the user didn't initially
write out a 'static lifetime, adding 'static in response to
a lifetime error is usually the wrong thing to do.
2021-10-04 23:56:24 -07:00
Manish Goregaokar
04314a6061
Rollup merge of #89482 - hkmatsumoto:patch-diagnostics, r=joshtriplett
Follow the diagnostic output style guide

Detected by #89455.
2021-10-04 23:56:23 -07:00
Manish Goregaokar
87f782ede6
Rollup merge of #89423 - DevinR528:reachable-fields, r=Nadrieril
Fix ICE caused by non_exaustive_omitted_patterns struct lint

fixes #89382

Add check that a list of `Pat`s is non empty to prevent ICE in `FnCtxt::lint_non_exhaustive_omitted_patterns`.

Is related to #89374 and #89105
2021-10-04 23:56:20 -07:00
Jubilee
c9158db1f3
Rollup merge of #89494 - FabianWolff:issue-84075, r=davidtwco
Deny `where` clauses on `auto` traits

Fixes #84075.
2021-10-04 21:12:43 -07:00
Jubilee
90e96f9fc3
Rollup merge of #89487 - FabianWolff:issue-89396, r=petrochenkov
Try to recover from a `=>` -> `=` or `->` typo in a match arm

Fixes #89396.
2021-10-04 21:12:42 -07:00
Jubilee
ec4145510e
Rollup merge of #89478 - zvavybir:master, r=jyn514
Fixed numerus of error message

When there are redundant trait requirements and these are hidden, a message is generated by the following code snippet:
`format!("{} redundant requirements hidden", count)`
But if there is only a single hidden requirement, it will still print this message in plural instead of singular.
2021-10-04 21:12:40 -07:00
Jubilee
c2bfe45e66
Rollup merge of #89473 - FabianWolff:issue-89469, r=joshtriplett
Fix extra `non_snake_case` warning for shorthand field bindings

Fixes #89469. The problem is the innermost `if` condition here:
d14731cb3c/compiler/rustc_lint/src/nonstandard_style.rs (L435-L452)

This code runs for every `PatKind::Binding`, so if a struct has multiple fields, say A and B, and both are bound in a pattern using shorthands, the call to `self.check_snake_case()` will indeed be skipped in the `check_pat()` call for `A`; but when `check_pat()` is called for `B`, the loop will still iterate over `A`, and `field.ident (= A) != ident (= B)` will be true. I have fixed this by only looking at non-shorthand bindings, and only the binding that `check_pat()` was actually called for.
2021-10-04 21:12:38 -07:00
Jubilee
36f173f0a9
Rollup merge of #89466 - Mark-Simulacrum:query-macros, r=oli-obk
Fix bug with query modifier parsing

The previous macro_rules! parsers failed when an additional modifier was added
with ambiguity errors. The error is pretty unclear as to what exactly the cause
here is, but this change simplifies the argument parsing code such that the
error is avoided.

Extracted from other work, and somewhat duplicates 0358edeb5 from #85830, but
this approach seems a little simpler to me. Not technically currently necessary but seems
like a good cleanup.
2021-10-04 21:12:37 -07:00
Jubilee
05b4cd6789
Rollup merge of #89413 - matthewjasper:spec-marker-fix, r=nikomatsakis
Correctly handle supertraits for min_specialization

Supertraits of specialization markers could circumvent checks for
min_specialization. Elaborating predicates prevents this.

r? ````@nikomatsakis````
2021-10-04 21:12:35 -07:00
Jubilee
4f6afee4e5
Rollup merge of #88090 - nbdd0121:inference, r=nikomatsakis
Perform type inference in range pattern

Fix #88074
2021-10-04 21:12:33 -07:00
Jubilee
99e6e3ff07
Rollup merge of #87993 - kornelski:try_reserve_stable, r=joshtriplett
Stabilize try_reserve

Stabilization PR for the [`try_reserve` feature](https://github.com/rust-lang/rust/issues/48043#issuecomment-898040475).
2021-10-04 21:12:33 -07:00
Jubilee
9866b090f4
Rollup merge of #89508 - jhpratt:stabilize-const_panic, r=joshtriplett
Stabilize `const_panic`

Closes #51999

FCP completed in #89006

```@rustbot``` label +A-const-eval +A-const-fn +T-lang

cc ```@oli-obk``` for review (not `r?`'ing as not on lang team)
2021-10-04 13:58:17 -07:00
Jubilee
3d4467dfcc
Rollup merge of #89500 - FabianWolff:issue-87308, r=petrochenkov
Fix ICE with buffered lint referring to AST node deleted by everybody_loops

Fixes #87308. Note the following comment:
08759c691e/compiler/rustc_lint/src/early.rs (L415-L417)

As it turns out, this is not _always_ a bug, because `-Zunpretty=everybody_loops` causes a lot of AST nodes to be deleted, and thus some buffered lints will refer to non-existent node ids. To fix this, my changes simply ignore buffered lints if `-Zunpretty=everybody_loops` is enabled, which, from my understanding, shouldn't be a big issue because it only affects pretty-printing. Of course, a more elegant solution would only ignore buffered lints that actually point at deleted node ids, but I haven't figured out an easy way of achieving this.

For the concrete example in #87308, the buffered lint is created [here](08759c691e/compiler/rustc_expand/src/mbe/macro_rules.rs (L145-L151)) with the `lint_node_id` from [here](08759c691e/compiler/rustc_expand/src/mbe/macro_rules.rs (L319)), i.e. it points at the macro _expansion_, which then gets deleted by `ReplaceBodyWithLoop` [here](08759c691e/compiler/rustc_interface/src/passes.rs (L377)).
2021-10-04 13:58:16 -07:00
Jubilee
5352e17df3
Rollup merge of #89483 - hkmatsumoto:patch-diagnostics-2, r=estebank
Practice diagnostic message convention

Detected by #89455.

r? ```@estebank```
2021-10-04 13:58:15 -07:00
Jubilee
2bc89ce0bf
Rollup merge of #89453 - waywardmonkeys:consistent-supertrait-usage, r=nagisa
Consistently use 'supertrait'.

A subset of places referred to 'super-trait', so this changes them
to all use 'supertrait'. This matches 'supertype' and some other
usages. An exception is 'auto-trait' which is consistently used
in that manner.
2021-10-04 13:58:14 -07:00
Jubilee
08dd4148f1
Rollup merge of #89447 - FabianWolff:issue-89388, r=davidtwco
Improve error message for missing angle brackets in `[_]::method`

Fixes #89388.
2021-10-04 13:58:13 -07:00
Jubilee
9381d7a898
Rollup merge of #89407 - pierwill:recommend-clean-E0514, r=davidtwco
Recommend running `cargo clean` in E0514 output

This suggestion has worked for me before. Seems to me it could help others.
2021-10-04 13:58:10 -07:00
Jubilee
a2c6075dff
Rollup merge of #88451 - theo-lw:issue-87771, r=jackh726
Fix an ICE caused by type mismatch errors being ignored

This PR fixes #87771. It turns out that the check on `compiler/rustc_typeck/src/check/demand.rs:148` leads to the ICE. I removed it because the early return in [`check_expr_assign`](dec7fc3ced/compiler/rustc_typeck/src/check/expr.rs (L928)) already prevents unnecessary error messages from the call to `check_expr_coercable_to_type`.
2021-10-04 13:58:07 -07:00
Jubilee
4e9cf04c98
Rollup merge of #83655 - sebpop:arm64-outline-atomics, r=workingjubilee
[aarch64] add target feature outline-atomics

Enable outline-atomics by default as enabled in clang by the following commit
https://reviews.llvm.org/rGc5e7e649d537067dec7111f3de1430d0fc8a4d11

Performance improves by several orders of magnitude when using the LSE instructions
instead of the ARMv8.0 compatible load/store exclusive instructions.

Tested on Graviton2 aarch64-linux with
x.py build && x.py install && x.py test
2021-10-04 13:58:06 -07:00
Fabian Wolff
079c075f24 Use TokenKind::similar_tokens() 2021-10-04 22:13:00 +02:00
bors
a4797664ba Auto merge of #89489 - FabianWolff:issue-89485, r=oli-obk
Fix unsound optimization with explicit variant discriminants

Fixes #89485.
2021-10-04 10:09:04 +00:00
Kornel
00152d8977 Stabilize try_reserve 2021-10-04 10:29:46 +01:00
kadmin
9cb30f465e Move generic error message to separate branches
This decomposes an error message in generic constants into more specific branches, for better
readability.
2021-10-04 06:49:49 +00:00
Jacob Pratt
bce8621983
Stabilize const_panic 2021-10-04 02:33:33 -04:00
Manish Goregaokar
5215b855b0
Rollup merge of #88481 - bjorn3:remove_feature_gates, r=cjgillot
Remove some feature gates

The first commit removes various feature gates that are unused. The second commit replaces some `Fn` implementations with `Iterator` implementations, which is much cleaner IMO. The third commit replaces an unboxed_closures feature gate with min_specialization. For some reason the unboxed_closures feature gate suppresses the min_specialization feature gate from triggering on an `TrustedStep` impl. The last comment just turns a regular comment into a doc comment as drive by cleanup. I can move it to a separate PR if preferred.
2021-10-03 23:13:20 -07:00
Aaron Hill
fdd8a0dde5
Don't suggest replacing region with 'static in NLL
Fixes #73159

This is similar to #69350 - if the user didn't initially
write out a 'static lifetime, adding 'static in response to
a lifetime error is usually the wrong thing to do.
2021-10-03 21:53:48 -05:00
bors
e737694a4d Auto merge of #88175 - camsteffen:let-desugar-span, r=Manishearth
Add expansion to while desugar spans

In the same vein as #88163, this reverts a change in Clippy behavior as a result of #80357 (and reverts some `#[allow]`s): This changes `clippy::blocks_in_if_conditions` to not fire on `while` loops. Though we might actually want Clippy to lint those cases, we should introduce the change purposefully, with tests, and possibly under a different lint name.

The actual change here is to add a desugaring expansion to the spans when lowering a `while` loop.

r? `@Manishearth`
2021-10-03 21:44:10 +00:00
Fabian Wolff
dd9b4763a4 Disable SimplifyBranchSame optimization for now 2021-10-03 22:58:24 +02:00
Fabian Wolff
20489eaca2 Update comments 2021-10-03 21:06:49 +02:00
Fabian Wolff
a28a78f247 Fix ICE with buffered lint referring to AST node deleted by everybody_loops 2021-10-03 21:04:36 +02:00
Fabian Wolff
e34fd54611 Deny where clauses on auto traits 2021-10-03 18:06:21 +02:00
bjorn3
9f4cb862ca Replace Fn impls with RPIT impls in rustc_index
This is cleaner and removes an unstable feature usage
2021-10-03 17:50:53 +02:00
Camille GILLOT
b2ed9c4007 Add some inlining. 2021-10-03 16:08:57 +02:00
Camille GILLOT
fedd7785fe Access StableHashingContext in rustc_query_system. 2021-10-03 16:08:55 +02:00
Camille GILLOT
471cb5c149 Fully remove rustc_middle::ich. 2021-10-03 16:08:55 +02:00
Camille GILLOT
02025d86ac Remove re-export. 2021-10-03 16:08:54 +02:00
Camille GILLOT
c355b2e5cd Move ICH to rustc_query_system. 2021-10-03 16:08:53 +02:00
Camille GILLOT
2d38c53767 Remove StableHashProvider. 2021-10-03 16:08:52 +02:00
Camille GILLOT
8961616e60 Move rustc_middle::middle::cstore to rustc_session. 2021-10-03 16:08:51 +02:00
Camille GILLOT
b66dfaaa64 Move some HashStable impls. 2021-10-03 16:08:50 +02:00
Fabian Wolff
529c35331b Fix unsound optimization with explicit variant discriminants 2021-10-03 16:04:38 +02:00
Fabian Wolff
9626f2bd84 Fix extra non_snake_case warning for shorthand field bindings 2021-10-03 14:33:14 +02:00
Fabian Wolff
cf19131cb3 Try to recover from a => -> = or -> typo in a match arm 2021-10-03 14:14:35 +02:00
Matthias Kaak
d6a7e74c81 Combined 4 commits into 1
Fixed numerus of error message

Removed superfluous argument

Using pluralize!() instead of code duplication

Adjusted a test
2021-10-03 11:53:12 +00:00
Hirochika Matsumoto
3818981ca1 Practice diagnostic message convention 2021-10-03 16:16:28 +09:00