summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src
AgeCommit message (Collapse)AuthorLines
2024-03-04Improve wording of static_mut_refObei Sideg-39/+17
Rename `static_mut_ref` lint to `static_mut_refs`. (cherry picked from commit 408eeae59d35cbcaab2cfb345d24373954e74fc5)
2024-01-31Auto merge of #120346 - petrochenkov:ownodes, r=oli-obkbors-3/+3
hir: Refactor getters for owner nodes
2024-01-30Auto merge of #119101 - compiler-errors:outlives, r=lcnrbors-22/+19
Normalize region obligation in lexical region resolution with next-gen solver This normalizes region obligations when we `resolve_regions`, since they may be unnormalized with deferred projection equality. It's pretty hard to add tests that exercise this without also triggering MIR borrowck errors (because we don't normalize there yet). I've added one test with two revisions that should test that we both 1. normalize region obligations in the param env, and 2. normalize registered region obligations during lexical region resolution.
2024-01-30hir: Remove `hir::Map::{owner,expect_owner}`Vadim Petrochenkov-3/+3
2024-01-30Rollup merge of #120400 - estebank:bound-error-cleanup, r=oli-obkGuillaume Gomez-11/+21
Bound errors span label cleanup Consolidate span labels for "this type doesn't satisfy a bound" for more compact diagnostic output.
2024-01-30Apply suggestions from reviewMichael Goulet-1/+1
2024-01-30Deeply normalize when processing registered region obligationsMichael Goulet-0/+5
2024-01-30No need to pass region bound pairs to resolve_regions_with_wf_tysMichael Goulet-22/+14
2024-01-29review commentsEsteban Küber-16/+9
2024-01-29Auto merge of #120466 - Dylan-DPC:rollup-v0or19a, r=Dylan-DPCbors-3/+3
Rollup of 9 pull requests Successful merges: - #116677 (References refer to allocated objects) - #118625 (Improve handling of expressions in patterns) - #120266 (Improve documentation for [A]Rc::into_inner) - #120373 (Adjust Behaviour of `read_dir` and `ReadDir` in Windows Implementation: Check Whether Path to Search In Exists) - #120390 (Borrow check inline const patterns) - #120420 (Stop using derivative in rustc_pattern_analysis) - #120428 (hir: Two preparatory changes for #120206) - #120453 (Fix incorrect comment in normalize_newlines) - #120462 (Clean dead code) r? `@ghost` `@rustbot` modify labels: rollup
2024-01-29Avoid ICE in trait without `dyn` lintEsteban Küber-5/+3
Do not attempt to provide an accurate suggestion for `impl Trait` in bare trait types when linting. Instead, only do the object safety check when an E0782 is already going to be emitted in the 2021 edition. Fix #120241.
2024-01-29Rollup merge of #120428 - petrochenkov:somehir2, r=compiler-errorsDylan DPC-3/+3
hir: Two preparatory changes for #120206 cc https://github.com/rust-lang/rust/pull/120206 r? ```@compiler-errors```
2024-01-29Stop using `String` for error codes.Nicholas Nethercote-104/+110
Error codes are integers, but `String` is used everywhere to represent them. Gross! This commit introduces `ErrCode`, an integral newtype for error codes, replacing `String`. It also introduces a constant for every error code, e.g. `E0123`, and removes the `error_code!` macro. The constants are imported wherever used with `use rustc_errors::codes::*`. With the old code, we have three different ways to specify an error code at a use point: ``` error_code!(E0123) // macro call struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call \#[diag(name, code = "E0123")] // string struct Diag; ``` With the new code, they all use the `E0123` constant. ``` E0123 // constant struct_span_code_err!(dcx, span, E0123, "msg"); // constant \#[diag(name, code = E0123)] // constant struct Diag; ``` The commit also changes the structure of the error code definitions: - `rustc_error_codes` now just defines a higher-order macro listing the used error codes and nothing else. - Because that's now the only thing in the `rustc_error_codes` crate, I moved it into the `lib.rs` file and removed the `error_codes.rs` file. - `rustc_errors` uses that macro to define everything, e.g. the error code constants and the `DIAGNOSTIC_TABLES`. This is in its new `codes.rs` file.
2024-01-28hir: Use `InferArg` in `ArrayLen::Infer`Vadim Petrochenkov-3/+3
2024-01-26Use only one label for multiple unsatisfied bounds on type (astconv)Esteban Küber-11/+28
2024-01-25Remove unused featuresclubby789-3/+0
2024-01-25Rollup merge of #119895 - oli-obk:track_errors_3, r=matthewjasperMatthias Krüger-105/+132
Remove `track_errors` entirely follow up to https://github.com/rust-lang/rust/pull/119869 r? `@matthewjasper` There are some diagnostic changes adding new diagnostics or not emitting some anymore. We can improve upon that in follow-up work imo.
2024-01-25Auto merge of #119911 - NCGThompson:is-statically-known, r=oli-obkbors-0/+2
Replacement of #114390: Add new intrinsic `is_var_statically_known` and optimize pow for powers of two This adds a new intrinsic `is_val_statically_known` that lowers to [``@llvm.is.constant.*`](https://llvm.org/docs/LangRef.html#llvm-is-constant-intrinsic).` It also applies the intrinsic in the int_pow methods to recognize and optimize the idiom `2isize.pow(x)`. See #114390 for more discussion. While I have extended the scope of the power of two optimization from #114390, I haven't added any new uses for the intrinsic. That can be done in later pull requests. Note: When testing or using the library, be sure to use `--stage 1` or higher. Otherwise, the intrinsic will be a noop and the doctests will be skipped. If you are trying out edits, you may be interested in [`--keep-stage 0`](https://rustc-dev-guide.rust-lang.org/building/suggested.html#faster-builds-with---keep-stage). Fixes #47234 Resolves #114390 `@Centri3`
2024-01-23Auto merge of #120283 - fmease:rollup-rk0f6r5, r=fmeasebors-7/+77
Rollup of 9 pull requests Successful merges: - #112806 (Small code improvements in `collect_intra_doc_links.rs`) - #119766 (Split tait and impl trait in assoc items logic) - #120139 (Do not normalize closure signature when building `FnOnce` shim) - #120160 (Manually implement derived `NonZero` traits.) - #120171 (Fix assume and assert in jump threading) - #120183 (Add `#[coverage(off)]` to closures introduced by `#[test]` and `#[bench]`) - #120195 (add several resolution test cases) - #120259 (Split Diagnostics for Uncommon Codepoints: Add List to Display Characters Involved) - #120261 (Provide structured suggestion to use trait objects in some cases of `if` arm type divergence) r? `@ghost` `@rustbot` modify labels: rollup
2024-01-23Rollup merge of #119766 - oli-obk:split_tait_and_atpit, r=compiler-errorsLeón Orell Valerian Liehr-7/+77
Split tait and impl trait in assoc items logic And simplify the assoc item logic where applicable. This separation shows that it is easier to reason about impl trait in assoc items compared with TAITs. See https://rust-lang.zulipchat.com/#narrow/stream/315482-t-compiler.2Fetc.2Fopaque-types/topic/impl.20trait.20in.20associated.20type for some discussion. The current plan is to try to stabilize impl trait in associated items before TAIT, as they do not have any issues with their defining scopes (see https://github.com/rust-lang/rust/issues/107645 for why this is not a trivial or uncontroversial topic).
2024-01-23Rollup merge of #120270 - compiler-errors:randos, r=lcnrLeón Orell Valerian Liehr-1/+4
A bunch of random modifications r? oli-obk Kitchen sink of changes that I didn't know where to put elsewhere. Documentation tweaks mostly, but also removing some unreachable code and simplifying the pretty printing for closures/coroutines.
2024-01-23Remove track_errors entirelyOli Scherer-105/+132
2024-01-23Random type checker changesMichael Goulet-1/+4
2024-01-23Rename `TyCtxt::emit_spanned_lint` as `TyCtxt::emit_node_span_lint`.Nicholas Nethercote-3/+3
2024-01-23Rename `TyCtxt::struct_span_lint_hir` as `TyCtxt::node_span_lint`.Nicholas Nethercote-34/+22
2024-01-22Auto merge of #120242 - matthiaskrgr:rollup-a93yj3i, r=matthiaskrgrbors-7/+9
Rollup of 10 pull requests Successful merges: - #117910 (Refactor uses of `objc_msgSend` to no longer have clashing definitions) - #118639 (Undeprecate lint `unstable_features` and make use of it in the compiler) - #119801 (Fix deallocation with wrong allocator in (A)Rc::from_box_in) - #120058 (bootstrap: improvements for compiler builds) - #120059 (Make generic const type mismatches not hide trait impls from the trait solver) - #120097 (Report unreachable subpatterns consistently) - #120137 (Validate AggregateKind types in MIR) - #120164 (`maybe_lint_impl_trait`: separate `is_downgradable` from `is_object_safe`) - #120181 (Allow any `const` expression blocks in `thread_local!`) - #120218 (rustfmt: Check that a token can begin a nonterminal kind before parsing it as a macro arg) r? `@ghost` `@rustbot` modify labels: rollup
2024-01-22Rollup merge of #120164 - trevyn:is_downgradable, r=compiler-errorsMatthias Krüger-7/+9
`maybe_lint_impl_trait`: separate `is_downgradable` from `is_object_safe` https://github.com/rust-lang/rust/pull/119752 leveraged and overloaded `is_object_safe` to prevent an ICE, but accurate object safety information is needed for precise suggestions. This separates out `is_downgradable`, used for the ICE prevention, and `is_object_safe`, which returns to its original meaning.
2024-01-22Rollup merge of #120213 - ↵Matthias Krüger-25/+9
compiler-errors:dont-make-non-lifetime-binders-in-rtn, r=fmease Don't actually make bound ty/const for RTN Avoid creating an unnecessary non-lifetime binder when we do RTN on a method that has ty/const params. Fixes #120208 r? oli-obk
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`