about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src
AgeCommit message (Collapse)AuthorLines
2024-01-17Stop using track_errors for some forever unstable rustc_attr analysesOli Scherer-18/+21
2024-01-17Auto merge of #119922 - nnethercote:fix-Diag-code-is_lint, r=oli-obkbors-12/+10
Rework how diagnostic lints are stored. `Diagnostic::code` has the type `DiagnosticId`, which has `Error` and `Lint` variants. Plus `Diagnostic::is_lint` is a bool, which should be redundant w.r.t. `Diagnostic::code`. Seems simple. Except it's possible for a lint to have an error code, in which case its `code` field is recorded as `Error`, and `is_lint` is required to indicate that it's a lint. This is what happens with `derive(LintDiagnostic)` lints. Which means those lints don't have a lint name or a `has_future_breakage` field because those are stored in the `DiagnosticId::Lint`. It's all a bit messy and confused and seems unintentional. This commit: - removes `DiagnosticId`; - changes `Diagnostic::code` to `Option<String>`, which means both errors and lints can straightforwardly have an error code; - changes `Diagnostic::is_lint` to `Option<IsLint>`, where `IsLint` is a new type containing a lint name and a `has_future_breakage` bool, so all lints can have those, error code or not. r? `@oli-obk`
2024-01-17Add `PatKind::Err`Lieselotte-1/+2
2024-01-16Don't ICE if TAIT-defining fn contains a closure with `_` in return typeLukas Markeffsky-12/+19
2024-01-15Rollup merge of #119971 - compiler-errors:zip-eq, r=nnethercoteMatthias Krüger-1/+2
Use `zip_eq` to enforce that things being zipped have equal sizes Some `zip`s are best enforced to be equal, since size mismatches suggest deeper bugs in the compiler.
2024-01-14Use zip_eq to enforce that things being zipped have equal sizesMichael Goulet-1/+2
2024-01-14Rework how diagnostic lints are stored.Nicholas Nethercote-12/+10
`Diagnostic::code` has the type `DiagnosticId`, which has `Error` and `Lint` variants. Plus `Diagnostic::is_lint` is a bool, which should be redundant w.r.t. `Diagnostic::code`. Seems simple. Except it's possible for a lint to have an error code, in which case its `code` field is recorded as `Error`, and `is_lint` is required to indicate that it's a lint. This is what happens with `derive(LintDiagnostic)` lints. Which means those lints don't have a lint name or a `has_future_breakage` field because those are stored in the `DiagnosticId::Lint`. It's all a bit messy and confused and seems unintentional. This commit: - removes `DiagnosticId`; - changes `Diagnostic::code` to `Option<String>`, which means both errors and lints can straightforwardly have an error code; - changes `Diagnostic::is_lint` to `Option<IsLint>`, where `IsLint` is a new type containing a lint name and a `has_future_breakage` bool, so all lints can have those, error code or not.
2024-01-13Auto merge of #119088 - George-lewis:glewis/suggest-upgrading-compiler, ↵bors-20/+16
r=Nilstrieb Suggest Upgrading Compiler for Gated Features This PR addresses #117318 I have a few questions: 1. Do we want to specify the current version and release date of the compiler? I have added this in via environment variables, which I found in the code for the rustc cli where it handles the `--version` flag a. How can I handle the changing message in the tests? 3. Do we want to only show this message when the compiler is old? a. How can we determine when the compiler is old? I'll wait until we figure out the message to bless the tests
2024-01-13Add check for ui_testing via promoting parameters from `ParseSess` to `Session`George-lewis-20/+16
2024-01-13Rollup merge of #119896 - oli-obk:variance_ice, r=compiler-errorsMatthias Krüger-2/+6
Taint `_` placeholder types in trait impl method signatures We report an error right below for them, but that kind of broken type can cause subsequent ICEs. fixes #119867
2024-01-13Rollup merge of #119587 - beepster4096:system_varargs, r=petrochenkovMatthias Krüger-1/+2
Varargs support for system ABI This PR allows functions with the `system` ABI to be variadic (under the `extended_varargs_abi_support` feature tracked in #100189). On x86 windows, the `system` ABI is equivalent to `C` for variadic functions. On other platforms, `system` is already equivalent to `C`. Fixes #110505
2024-01-12allow system abi to be variadicbeepster4096-1/+2
2024-01-13Auto merge of #118947 - Bryanskiy:delegStep1, r=petrochenkov,lcnrbors-4/+130
Delegation implementation: step 1 See https://github.com/rust-lang/rust/issues/118212 for more details. r? `@petrochenkov`
2024-01-12Taint `_` placeholder typesOli Scherer-2/+6
2024-01-12Rollup merge of #119817 - compiler-errors:normalize-opaques, r=lcnrGuillaume Gomez-1/+1
Remove special-casing around `AliasKind::Opaque` when structurally resolving in new solver This fixes a few inconsistencies around where we don't eagerly resolve opaques to their (locally-defined) hidden types in the new solver. It essentially allows this code to work: ```rust fn main() { type Tait = impl Sized; struct S { i: i32, } let x: Tait = S { i: 0 }; println!("{}", x.i); } ``` Since `Tait` is defined in `main`, we are able to poke through the type of `x` with deref. r? lcnr
2024-01-12Delegation implementation: step 1Bryanskiy-4/+130
2024-01-11Remove special-casing around aliaskind in new solverMichael Goulet-1/+1
2024-01-11Taint more aggressively in astconvOli Scherer-12/+28
2024-01-11Silence follow up errors if astconv already erroredOli Scherer-4/+24
2024-01-11Rollup merge of #119803 - oli-obk:even_more_follow_up_errors, r=compiler-errorsMatthias Krüger-58/+27
Silence some follow-up errors [1/x] this is one piece of the requested cleanups from https://github.com/rust-lang/rust/pull/117449 When we use `-> impl SomeTrait<_>` as a return type, we are both using the "infer return type suggestion" code path, and the infer opaque type code path within the same function. That can lead to confusing diagnostics, so silence all opaque type diagnostics in that case.
2024-01-10Auto merge of #119751 - nnethercote:error-api-fixes, r=oli-obkbors-166/+159
Diagnostic API fixes Some improvements to diagnostic APIs: improve some naming, use shortcuts in more places, and add a couple of missing methods. r? `@compiler-errors`
2024-01-10Avoid follow up errorsOli Scherer-0/+15
2024-01-10Turn some free functions into methodsOli Scherer-51/+9
2024-01-10Use a ty::Error instead of patching up a type after erroringOli Scherer-7/+3
2024-01-09Auto merge of #117449 - oli-obk:query_merge_immobile_game, r=matthewjasperbors-6/+5
Avoid silencing relevant follow-up errors r? `@matthewjasper` This PR only adds new errors to tests that are already failing and fixes one ICE. Several tests were changed to not emit new errors. I believe all of them were faulty tests, and not explicitly testing for the code that had new errors.
2024-01-09Avoid silencing relevant follow-up errorsOli Scherer-6/+5
2024-01-10Rename consuming chaining methods on `DiagnosticBuilder`.Nicholas Nethercote-54/+52
In #119606 I added them and used a `_mv` suffix, but that wasn't great. A `with_` prefix has three different existing uses. - Constructors, e.g. `Vec::with_capacity`. - Wrappers that provide an environment to execute some code, e.g. `with_session_globals`. - Consuming chaining methods, e.g. `Span::with_{lo,hi,ctxt}`. The third case is exactly what we want, so this commit changes `DiagnosticBuilder::foo_mv` to `DiagnosticBuilder::with_foo`. Thanks to @compiler-errors for the suggestion.
2024-01-10Add `DiagCtxt::delayed_bug`.Nicholas Nethercote-32/+14
We have `span_delayed_bug` and often pass it a `DUMMY_SP`. This commit adds `delayed_bug`, which matches pairs like `err`/`span_err` and `warn`/`span_warn`.
2024-01-10Shorten some error invocations.Nicholas Nethercote-4/+4
- `struct_foo` + `emit` -> `foo` - `create_foo` + `emit` -> `emit_foo` I have made recent commits in other PRs that have removed some of these shortcuts for combinations with few uses, e.g. `struct_span_err_with_code`. But for the remaining combinations that have high levels of use, we might as well use them wherever possible.
2024-01-10Rename `struct_span_err!` as `struct_span_code_err!`.Nicholas Nethercote-77/+90
Because it takes an error code after the span. This avoids the confusing overlap with the `DiagCtxt::struct_span_err` method, which doesn't take an error code.
2024-01-09Rollup merge of #119721 - compiler-errors:constness-implication, r=fee1-deadGuillaume Gomez-83/+8
`~const` trait and projection bounds do not imply their non-const counterparts This PR removes the hack where we install a non-const trait and projection bound for every `const_trait` and `~const` projection bound we have in the AST. It ends up messing up more things than it fixes, see words below. Fixes #119718 cc `@fmease` `@fee1-dead` `@oli-obk` r? fee1-dead or one of y'all i don't care --- My understanding is that this hack was added to support the following code: ```rust pub trait Owo<X = <Self as Uwu>::T> {} #[const_trait] pub trait Uwu: Owo {} ``` Which is concretely lifted from in the `FromResidual` and `Try` traits. Since within the param-env of `trait Uwu`, we only know that `Self: ~const Uwu` and not `Self: Uwu`, the projection `<Self as Uwu>::T` is not satsifyable. This causes problems such as #119718, since instantiations of `FnDef` types coming from `const fn` really do **only** implement one of `FnOnce` or `const FnOnce`! --- In the long-term, I believe that such code should really look something more like: ```rust #[const_trait] pub trait Owo<X = <Self as ~const Uwu>::T> {} #[const_trait] pub trait Uwu: Owo {} ``` ... and that we should introduce some sort of `<T as ~const Foo>::Bar` bound syntax, since due to the fact that `~const` bounds can be present in item bounds, e.g. ```rust #[const_trait] trait Foo { type Bar: ~const Destruct; } ``` It's easy to see that `<T as Foo>::Bar` and `<T as ~const Foo>::Bar` (or `<T as const Foo>::Bar`) can be distinct types with distinct item bounds! **Admission**: I know I've said before that I don't like `~const` projection syntax, I do at this point believe they're necessary to fully express bounds and types in a maybe-const world.
2024-01-09Rollup merge of #117556 - obeis:static-mut-ref-lint, r=davidtwcoGuillaume Gomez-0/+195
Disallow reference to `static mut` and adding `static_mut_ref` lint Closes #114447 r? `@scottmcm`
2024-01-08Only compute layout of opaque if coroutine is the cause of an opaque cycleMichael Goulet-9/+26
2024-01-08Don't check for recursion in generator witness fieldsMichael Goulet-18/+7
2024-01-08Remove logic in one_bound in astconv that prefers non-const boundsMichael Goulet-33/+2
2024-01-08~const trait or projection bounds do not imply non-const boundsMichael Goulet-50/+6
2024-01-08Remove all eight `DiagnosticBuilder::*_with_code` methods.Nicholas Nethercote-5/+5
These all have relatively low use, and can be perfectly emulated with a simpler construction method combined with `code` or `code_mv`.
2024-01-08Use chaining for `DiagnosticBuilder` construction and `emit`.Nicholas Nethercote-80/+88
To avoid the use of a mutable local variable, and because it reads more nicely.
2024-01-08Use chaining in `DiagnosticBuilder` construction.Nicholas Nethercote-4/+2
To avoid the use of a mutable local variable, and because it reads more nicely.
2024-01-08Make `DiagnosticBuilder::emit` consuming.Nicholas Nethercote-37/+37
This works for most of its call sites. This is nice, because `emit` very much makes sense as a consuming operation -- indeed, `DiagnosticBuilderState` exists to ensure no diagnostic is emitted twice, but it uses runtime checks. For the small number of call sites where a consuming emit doesn't work, the commit adds `DiagnosticBuilder::emit_without_consuming`. (This will be removed in subsequent commits.) Likewise, `emit_unless` becomes consuming. And `delay_as_bug` becomes consuming, while `delay_as_bug_without_consuming` is added (which will also be removed in subsequent commits.) All this requires significant changes to `DiagnosticBuilder`'s chaining methods. Currently `DiagnosticBuilder` method chaining uses a non-consuming `&mut self -> &mut Self` style, which allows chaining to be used when the chain ends in `emit()`, like so: ``` struct_err(msg).span(span).emit(); ``` But it doesn't work when producing a `DiagnosticBuilder` value, requiring this: ``` let mut err = self.struct_err(msg); err.span(span); err ``` This style of chaining won't work with consuming `emit` though. For that, we need to use to a `self -> Self` style. That also would allow `DiagnosticBuilder` production to be chained, e.g.: ``` self.struct_err(msg).span(span) ``` However, removing the `&mut self -> &mut Self` style would require that individual modifications of a `DiagnosticBuilder` go from this: ``` err.span(span); ``` to this: ``` err = err.span(span); ``` There are *many* such places. I have a high tolerance for tedious refactorings, but even I gave up after a long time trying to convert them all. Instead, this commit has it both ways: the existing `&mut self -> Self` chaining methods are kept, and new `self -> Self` chaining methods are added, all of which have a `_mv` suffix (short for "move"). Changes to the existing `forward!` macro lets this happen with very little additional boilerplate code. I chose to add the suffix to the new chaining methods rather than the existing ones, because the number of changes required is much smaller that way. This doubled chainging is a bit clumsy, but I think it is worthwhile because it allows a *lot* of good things to subsequently happen. In this commit, there are many `mut` qualifiers removed in places where diagnostics are emitted without being modified. In subsequent commits: - chaining can be used more, making the code more concise; - more use of chaining also permits the removal of redundant diagnostic APIs like `struct_err_with_code`, which can be replaced easily with `struct_err` + `code_mv`; - `emit_without_diagnostic` can be removed, which simplifies a lot of machinery, removing the need for `DiagnosticBuilderState`.
2024-01-05Rollup merge of #119420 - cjgillot:issue-119295, r=compiler-errorsMichael Goulet-0/+7
Handle ForeignItem as TAIT scope. Fixes #119295
2024-01-06Call `maybe_stmt_static_mut` inside `resolve_stmt`Obei Sideg-1/+3
2024-01-06Call `maybe_expr_static_mut` inside `resolve_expr`Obei Sideg-0/+4
2024-01-06Disallow reference to `static mut` for statementsObei Sideg-0/+19
2024-01-06Disallow reference to `static mut` for expressionsObei Sideg-0/+170
Add `E0796` error code. Add `static_mut_ref` lint. This is the idea for the 2024 edition.
2024-01-05Do not run check on foreign items.Camille GILLOT-1/+1
2024-01-05Handle ForeignItem as TAIT scope.Camille GILLOT-0/+7
2024-01-05Auto merge of #119634 - matthiaskrgr:rollup-v2xt7et, r=matthiaskrgrbors-96/+155
Rollup of 8 pull requests Successful merges: - #119151 (Hide foreign `#[doc(hidden)]` paths in import suggestions) - #119350 (Imply outlives-bounds on lazy type aliases) - #119354 (Make `negative_bounds` internal & fix some of its issues) - #119506 (Use `resolutions(()).effective_visiblities` to avoid cycle errors in `report_object_error`) - #119554 (Fix scoping for let chains in match guards) - #119563 (Check yield terminator's resume type in borrowck) - #119589 (cstore: Remove unnecessary locking from `CrateMetadata`) - #119622 (never patterns: Document behavior of never patterns with macros-by-example) r? `@ghost` `@rustbot` modify labels: rollup
2024-01-05Rollup merge of #119554 - matthewjasper:remove-guard-distinction, ↵Matthias Krüger-1/+11
r=compiler-errors Fix scoping for let chains in match guards If let guards were previously represented as a different type of guard in HIR and THIR. This meant that let chains in match guards were not handled correctly because they were treated exactly like normal guards. - Remove `hir::Guard` and `thir::Guard`. - Make the scoping different between normal guards and if let guards also check for let chains. closes #118593
2024-01-05Rollup merge of #119354 - fmease:negative_bounds-fixes, r=compiler-errorsMatthias Krüger-22/+30
Make `negative_bounds` internal & fix some of its issues r? compiler-errors