about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis
AgeCommit message (Collapse)AuthorLines
2024-01-22Use an enum instead of a boolOli Scherer-10/+17
2024-01-22Add a simpler and more targetted code path for impl trait in assoc itemsOli Scherer-7/+70
2024-01-22Tweak error counting.Nicholas Nethercote-1/+1
We have several methods indicating the presence of errors, lint errors, and delayed bugs. I find it frustrating that it's very unclear which one you should use in any particular spot. This commit attempts to instill a basic principle of "use the least general one possible", because that reflects reality in practice -- `has_errors` is the least general one and has by far the most uses (esp. via `abort_if_errors`). Specifics: - Add some comments giving some usage guidelines. - Prefer `has_errors` to comparing `err_count` to zero. - Remove `has_errors_or_span_delayed_bugs` because it's a weird one: in the cases where we need to count delayed bugs, we should really be counting lint errors as well. - Rename `is_compilation_going_to_fail` as `has_errors_or_lint_errors_or_span_delayed_bugs`, for consistency with `has_errors` and `has_errors_or_lint_errors`. - Change a few other `has_errors_or_lint_errors` calls to `has_errors`, as per the "least general" principle. This didn't turn out to be as neat as I hoped when I started, but I think it's still an improvement.
2024-01-21Don't actually make bound ty/const for RTNMichael Goulet-25/+9
2024-01-21`maybe_lint_impl_trait`: separate `is_downgradable` from `is_object_safe`trevyn-7/+9
2024-01-21Auto merge of #120100 - oli-obk:astconv_lifetimes, r=BoxyUwUbors-43/+50
Don't forget that the lifetime on hir types is `'tcx` This PR just tracks the `'tcx` lifetime to wherever the original objects actually have that lifetime. This code is needed for https://github.com/rust-lang/rust/pull/107606 (now #120131) so that `ast_ty_to_ty` can invoke `lit_to_const` on an argument passed to it. Currently the argument is `&hir::Ty<'_>`, but after this PR it is `&'tcx hir::Ty<'tcx>`.
2024-01-19Account for traits using self-trait by name without `dyn`Esteban Küber-8/+16
Fix #119652.
2024-01-19Avoid ICE: Check diagnostic is error before downgradingEsteban Küber-3/+5
Fix #119633.
2024-01-19Add new intrinsic `is_constant` and optimize `pow`Catherine Flores-0/+2
Fix overflow check Make MIRI choose the path randomly and rename the intrinsic Add back test Add miri test and make it operate on `ptr` Define `llvm.is.constant` for primitives Update MIRI comment and fix test in stage2 Add const eval test Clarify that both branches must have the same side effects guaranteed non guarantee use immediate type instead Co-Authored-By: Ralf Jung <post@ralfj.de>
2024-01-18Rollup merge of #119869 - oli-obk:track_errors2, r=matthewjasperMatthias Krüger-143/+225
replace `track_errors` usages with bubbling up `ErrorGuaranteed` more of the same as https://github.com/rust-lang/rust/pull/117449 (removing `track_errors`)
2024-01-18Auto merge of #120089 - matthiaskrgr:rollup-xyfqrb5, r=matthiaskrgrbors-1/+2
Rollup of 8 pull requests Successful merges: - #119172 (Detect `NulInCStr` error earlier.) - #119833 (Make tcx optional from StableMIR run macro and extend it to accept closures) - #119967 (Add `PatKind::Err` to AST/HIR) - #119978 (Move async closure parameters into the resultant closure's future eagerly) - #120021 (don't store const var origins for known vars) - #120038 (Don't create a separate "basename" when naming and opening a MIR dump file) - #120057 (Don't ICE when deducing future output if other errors already occurred) - #120073 (Remove spastorino from users_on_vacation) r? `@ghost` `@rustbot` modify labels: rollup
2024-01-18Don't forget that the lifetime on hir types is `'tcx`Oli Scherer-43/+50
2024-01-18Auto merge of #118553 - jackh726:lint-implied-bounds, r=lcnrbors-11/+65
error on incorrect implied bounds in wfcheck except for Bevy dependents Rebase of #109763 Additionally, special cases Bevy `ParamSet` types to not trigger the lint. This is tracked in #119956. Fixes #109628
2024-01-18Rollup merge of #119967 - ShE3py:patkind-err, r=WaffleLapkinMatthias Krüger-1/+2
Add `PatKind::Err` to AST/HIR #116715 added `thir::PatKind::Error`; this PR adds `hir::PatKind::Err` and `ast::PatKind::Err` (see https://github.com/rust-lang/rust/pull/118625#discussion_r1446587901.) --- ``@rustbot`` label +A-patterns r? WaffleLapkin
2024-01-17Add -Zno-implied-bounds-compat option and use itJack Huey-13/+18
2024-01-17Correctly handle normalization in implied boundsAli MJ Al-Nasrawy-11/+60
Special-case Bevy dependents to not error
2024-01-17Rollup merge of #119975 - ↵Matthias Krüger-12/+19
lukas-code:inferring-return-types-and-opaque-types-do-mix-sometimes, r=compiler-errors Don't ICE if TAIT-defining fn contains a closure with `_` in return type The `delay_span_bug` got added in https://github.com/rust-lang/rust/pull/119803/commits/0e82aaeb6799041991c54fb9ff37b5c20a5c6146 to reduce the amount of errors emitted for functions that have `_` in their return type, because inference doesn't apply to function items. But this logic shouldn't apply to closures, because their return types *can* be inferred. Fixes https://github.com/rust-lang/rust/issues/119916.
2024-01-17Make crate_inherent_impls fallible and stop using `track_errors` for itOli Scherer-36/+52
2024-01-17Make crate_inherent_impls_overlap_check bubble up its errorsOli Scherer-19/+29
2024-01-17Move `check_mod_impl_wf` query call out of track_errors and bubble errors up ↵Oli Scherer-70/+123
instead.
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/+3
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/+3
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/+134
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/+134
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.