Commit Graph

12843 Commits

Author SHA1 Message Date
Nicholas Nethercote
481a4461ae Rename visit_interpolated as visit_nonterminal.
Because `Nonterminal` is the type it visits.
2022-04-29 15:00:32 +10:00
Nicholas Nethercote
5a05b614bf Tweak print_attr_item.
This commit rearranges the `match`. The new code avoids testing for
`MacArgs::Eq` twice, at the cost of repeating the `self.print_path()`
call. I think this is worthwhile because it puts the `match` in a more
standard and readable form.
2022-04-29 15:00:32 +10:00
Dylan DPC
0cbf3b2b30
Rollup merge of #96433 - petrochenkov:delim, r=nnethercote
rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`

Compiler cannot reuse `proc_macro::Delimiter` directly due to extra impls, but can at least use the same naming.

After this PR the only difference between these two enums is that `proc_macro::Delimiter::None` is turned into `token::Delimiter::Invisible`.
It's my mistake that the invisible delimiter is called `None` on stable, during the stabilization I audited the naming and wrote the docs, but missed the fact that the `None` naming gives a wrong and confusing impression about what this thing is.

cc https://github.com/rust-lang/rust/pull/96421
r? ``@nnethercote``
2022-04-28 20:13:02 +02:00
Dylan DPC
cbfbc3be7d
Rollup merge of #96409 - marmeladema:fix-nll-introduce-named-lifetime-suggestion, r=jackh726
Recover suggestions to introduce named lifetime under NLL

Fixes #96157

r? ```@jackh726```

Built on top of #96385 so only the second commit is relevant
2022-04-28 20:13:01 +02:00
Dylan DPC
b3329f84f4
Rollup merge of #96405 - pvdrz:ambiguous-plus-diagnostic, r=davidtwco
Migrate ambiguous plus diagnostic to the new derive macro

r? ````@davidtwco```` ````@jyn514````
2022-04-28 20:12:59 +02:00
bors
b2c2a32870 Auto merge of #95976 - b-naber:valtree-constval-conversion, r=oli-obk
Implement Valtree to ConstValue conversion

Once we start to use `ValTree`s in the type system we will need to be able to convert them into `ConstValue` instances, which we want to continue to use after MIR construction.

r? `@oli-obk`

cc `@RalfJung`
2022-04-28 13:18:22 +00:00
Vadim Petrochenkov
2733ec1be3 rustc_ast: Harmonize delimiter naming with proc_macro::Delimiter 2022-04-28 10:04:29 +03:00
bors
0e7915d11f Auto merge of #96085 - jsgf:deny-unused-deps, r=compiler-errors
Make sure `-Dunused-crate-dependencies --json unused-externs` makes rustc exit with error status

This PR:
- fixes compiletest to understand unused extern notifications
- adds tests for `--json unused-externs`
- makes sure that deny-level unused externs notifications are treated as compile errors
  - refactors the `emit_unused_externs` callstack to plumb through the level as an enum as a string, and adds `Level::is_error`

Update: adds `--json unused-externs-silent` with the original behaviour since Cargo needs it. Should address `@est31's` concerns.

Fixes: https://github.com/rust-lang/rust/issues/96068
2022-04-28 04:17:52 +00:00
bors
81799cd8fd Auto merge of #96495 - Dylan-DPC:rollup-9lm4tpp, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #96377 (make `fn() -> _ { .. }` suggestion MachineApplicable)
 - #96397 (Make EncodeWide implement FusedIterator)
 - #96421 (Less `NoDelim`)
 - #96432 (not need `Option` for `dbg_scope`)
 - #96466 (Better error messages when collecting into `[T; n]`)
 - #96471 (replace let else with `?`)
 - #96483 (Add missing `target_feature` to the list of well known cfg names)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-28 01:37:03 +00:00
Dylan DPC
89db345859
Rollup merge of #96483 - Urgau:check-cfg-target_feature, r=petrochenkov
Add missing `target_feature` to the list of well known cfg names

This PR adds the missing `target_feature` cfg name to the list of well known cfg names.

It was notice missing in https://github.com/rust-lang/rust/issues/96472 thanks to `@bjorn3,` the reason being that `--check-cfg=names()` automatically inherit the names passed by `--cfg` (or internal to `rustc`) and is seems that the vast majority of targets have at least one target feature leading to `target_feature` being a well known name in most target but it should always be a well known name so this PR add it unconditionally to list.

r? `@petrochenkov`
2022-04-28 02:40:37 +02:00
Dylan DPC
4c628bbb1c
Rollup merge of #96471 - BoxyUwU:let_else_considered_harmful, r=lcnr
replace let else with `?`

r? `@oli-obk`
2022-04-28 02:40:36 +02:00
Dylan DPC
6f6fe3e651
Rollup merge of #96466 - compiler-errors:error-collect-array, r=davidtwco
Better error messages when collecting into `[T; n]`

Fixes #96461
2022-04-28 02:40:35 +02:00
Dylan DPC
d956d014f2
Rollup merge of #96432 - SparrowLii:dbg_scope, r=davidtwco
not need `Option` for `dbg_scope`

This PR fixes a few FIXME about not using `Option` in `dbg_scope` field of `DebugScope`, during `create_function_debug_context` func in codegen parts.
Added a `BitSet<SourceScope>` parameter to `make_mir_scope` to indicate whether the `DebugScope` has been instantiated.
cc ````@eddyb````
2022-04-28 02:40:34 +02:00
Dylan DPC
80045d65e1
Rollup merge of #96421 - nnethercote:less-NoDelim, r=petrochenkov
Less `NoDelim`

Currently there are several places where `NoDelim` (which really means "implicit delimiter" or "invisible delimiter") is used to mean "no delimiter". The name `NoDelim` is a bit misleading, and may be a cause.

This PR changes these places, e.g. by changing a `DelimToken` to `Option<DelimToken>` and then using `None` to mean "no delimiter". As a result, the *only* place where `NoDelim` values are now produced is within:
- `Delimiter::to_internal()`, when converting from `Delimiter::None`.
- `FlattenNonterminals::process_token()`, when converting `TokenKind::Interpolated`.

r? ````@petrochenkov````
2022-04-28 02:40:34 +02:00
Dylan DPC
4a7483c905
Rollup merge of #96377 - compiler-errors:infer-rustfix, r=petrochenkov
make `fn() -> _ { .. }` suggestion MachineApplicable

This might not be valid, but it would be nice to promote this to `MachineApplicable` so people can use rustfix here.

Also de65fcf009d07019689cfad7f327667e390a325d is to [restore the suggestion for `issue-77179.rs`](de65fcf009 (diff-12e43fb5d6d12ec7cb5c6b48204a18d113cf5de0e12eb71a358b639bd9aadaf0R8)). (though in this case, the code in that issue still doesn't compile, so it's not marked with rustfix).
2022-04-28 02:40:32 +02:00
bors
c95346b8ac Auto merge of #91557 - cjgillot:ast-lifetimes-named, r=petrochenkov
Perform lifetime resolution on the AST for lowering

Lifetime resolution is currently implemented several times. Once during lowering in order to introduce in-band lifetimes, and once in the resolve_lifetimes query. However, due to the global nature of lifetime resolution and how it interferes with hygiene, it is better suited on the AST.

This PR implements a first draft of lifetime resolution on the AST. For now, we specifically target named lifetimes and everything we need to remove lifetime resolution from lowering. Some diagnostics have already been ported, and sometimes made more precise using available hygiene information. Follow-up PRs will address in particular the resolution of anonymous lifetimes on the AST.

We reuse the rib design of the current resolution framework. Specific `LifetimeRib` and `LifetimeRibKind` types are introduced. The most important variant is `LifetimeRibKind::Generics`, which happens each time we encounter something which may introduce generic lifetime parameters. It can be an item or a `for<...>` binder. The `LifetimeBinderKind` specifies how this rib behaves with respect to in-band lifetimes.

r? `@petrochenkov`
2022-04-27 23:13:28 +00:00
marmeladema
2c94218238 Recover suggestions to introduce named lifetime under NLL 2022-04-27 22:36:40 +02:00
Camille GILLOT
21b6d23890 Collect extra lifetime parameters during late resolution. 2022-04-27 22:03:26 +02:00
Camille GILLOT
b590e3062c Refactor generic collection. 2022-04-27 22:03:19 +02:00
Camille GILLOT
6857a8d14e Create a specific struct for lifetime capture. 2022-04-27 22:03:12 +02:00
Camille GILLOT
f901df3739 Handle TAIT. 2022-04-27 22:00:44 +02:00
Camille GILLOT
f385f856cd Use LifetimeRes during lowering. 2022-04-27 22:00:15 +02:00
Camille GILLOT
69985f0175 Do not resolve elided lifetimes in path twice. 2022-04-27 21:59:47 +02:00
Camille GILLOT
38a4c2cc44 Update comment. 2022-04-27 21:59:47 +02:00
Loïc BRANSTETT
beb4e16f05 Add missing target_feature to the list of well known cfg names 2022-04-27 19:11:56 +02:00
Jeremy Fitzhardinge
c6bafa7322 Add --json unused-externs-silent with original behaviour
Since Cargo wants to do its own fatal error handling for unused
dependencies, add the option `--json unused-externs-silent` which
has the original behaviour of not indicating non-zero exit status for
`deny`/`forbid`-level unused dependencies.
2022-04-27 10:04:25 -07:00
Jeremy Fitzhardinge
0529a13b5d Plumb through rustc_lint_defs::Level as enum rather than string. 2022-04-27 10:04:25 -07:00
Jeremy Fitzhardinge
39f2f18463 Make --json unused-extern deny/forbid level messages cause exit with error status
Closes: https://github.com/rust-lang/rust/issues/96068
2022-04-27 10:04:25 -07:00
b-naber
ef5f07256c combine all unsized types and add another recursive call to process nested unsized types correctly 2022-04-27 16:58:16 +02:00
Christian Poveda
e7ae9eb3f2
rename sum_with_parens 2022-04-27 12:03:16 +02:00
Ellen
f697955c1e tut tut tut 2022-04-27 08:51:33 +01:00
Michael Goulet
83d701e569 Better error messages when collecting into [T; n] 2022-04-26 21:37:10 -07:00
Michael Goulet
f9e7489f87 TAITs are suggestable 2022-04-26 18:55:55 -07:00
Michael Goulet
ae42f22ba0 make fn() -> _ {} suggestion MachineApplicable 2022-04-26 18:50:46 -07:00
bors
99b70ee230 Auto merge of #96459 - Dylan-DPC:rollup-de6ud9d, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #92569 (Improve Error Messaging for Unconstructed Structs and Enum Variants in Generic Contexts)
 - #96370 (Cleanup `report_method_error` a bit)
 - #96383 (Fix erased region escaping into wfcheck due to #95395)
 - #96385 (Recover most `impl Trait` and `dyn Trait` lifetime bound suggestions under NLL)
 - #96410 (rustdoc: do not write `{{root}}` in `pub use ::foo` docs)
 - #96430 (Fix handling of `!` in rustdoc search)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-27 01:01:58 +00:00
Dylan DPC
dc1f98c655
Rollup merge of #96385 - marmeladema:nll-fix-trait-lifetime-bound-suggestions, r=jackh726
Recover most `impl Trait` and `dyn Trait` lifetime bound suggestions under NLL

This is done by replacing the duplicated (and very partial) implementation from borrowck with one inspsired from `NiceRegionError::try_report_static_impl_trait` and by re-using `suggest_new_region_bound`.

Fixes #96277

r? ```@jackh726```
2022-04-27 02:47:11 +02:00
Dylan DPC
5645732b04
Rollup merge of #96383 - compiler-errors:issue-96381, r=estebank
Fix erased region escaping into wfcheck due to #95395

We can just use `liberate_late_bound_regions` instead of `erase_late_bound_regions`... This gives us `ReEarlyBound` instead of `ReErased`, the former being something typeck actually knows how to deal with...

Fixes #96381

Side-note: We only actually get far enough in the compiler pipeline to cause this ICE when we're invoking rustdoc. We actually abort rustc right before wfcheck because of the error that we emit (having `_` in the type signature). Why does rustdoc keep going even though we raise an error?
2022-04-27 02:47:10 +02:00
Dylan DPC
e63da0ba00
Rollup merge of #96370 - compiler-errors:cleanup-report_method_error, r=estebank
Cleanup `report_method_error` a bit

1. Remove an unnecessary indentation level
2. Split out a couple of large functions from this humongo function body
2022-04-27 02:47:07 +02:00
Nicholas Nethercote
9665da35cc Avoid producing NoDelim values in FrameData. 2022-04-27 10:35:29 +10:00
bors
a7197189cd Auto merge of #96425 - oli-obk:fix_incremental_regression_unsafety_checking, r=compiler-errors
Fix incremental perf regression unsafety checking

Perf regression introduced in #96294

We will simply avoid emitting the name of the unsafe function in MIR unsafeck, since we're moving to THIR unsafeck anyway.
2022-04-26 22:35:40 +00:00
Nicholas Nethercote
a8e862cb7d Avoid producing NoDelim values in Frame.
The code currently ignores the actual delimiter on the RHS and fakes up
a `NoDelim`/`DelimSpan::dummy()` one. This commit changes it to use the
actual delimiter.

The commit also reorders the fields for the `Delimited` variant to match
the `Sequence` variant.
2022-04-27 08:25:22 +10:00
Nicholas Nethercote
6b367a0532 Avoid producing NoDelim values in MacArgs::delim(). 2022-04-27 08:15:12 +10:00
Nicholas Nethercote
f0bbc782ac Avoid producing NoDelim values in TokenCursorFrame. 2022-04-27 08:15:05 +10:00
George
14a127be3e Add new diagnostic 2022-04-26 17:04:44 -04:00
b-naber
bfefb4d74c account for custom DSTs in valtree -> constvalue conversion 2022-04-26 18:40:15 +02:00
Oli Scherer
3568bdc6cd Revert "add DefId to unsafety violations and display function path in E0133"
This reverts commit 8b8f6653cf.
2022-04-26 14:49:28 +00:00
SparrowLii
843e8d19ec not need Option for dbg_scope 2022-04-26 21:00:19 +08:00
Guillaume Gomez
223f107b48
Rollup merge of #96415 - ehuss:git-io, r=bjorn3
Remove references to git.io

The git.io service is shutting down soon (see https://github.blog/changelog/2022-04-25-git-io-deprecation/). This removes the references of those short links with the actual destination.
2022-04-26 13:22:31 +02:00
Guillaume Gomez
f908391136
Rollup merge of #96400 - JakobDegen:shallow-init-docs, r=Dylan-DPC
Correct documentation for `Rvalue::ShallowInitBox`

As a part of the big MIR docs PR, I had added a comment indicating that `Rvalue::ShallowInitBox` is disallowed after drop elaboration, but this is not true (no idea why I thought it was). Codegen has support for it, and trying to enforce this rule in the validator causes compiling core to ICE on the very first `box` statement.

That being said, this `Rvalue` probably *should* be banned after drop elaboration - it doesn't seem like it's still useful for much. However, I do not have time right now to actually go investigate how difficult a change that is to make, so in the meantime fixing the docs to reflect the current situation seems like the right step.

r? rust-lang/mir-opt
2022-04-26 13:22:30 +02:00
Guillaume Gomez
a818173e63
Rollup merge of #96386 - SparrowLii:des_field, r=jackh726
simplify `describe_field` func in borrowck's diagnostics part

This PR simplify the `describe_field` func in borrowck's diagnostics part, besides fix the FIXME in it.
2022-04-26 13:22:29 +02:00