about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-02-19Switch to the LLVMBuildGEPWithNoWrapFlags APINikita Popov-12/+36
This API allows us to set the nuw flag as well.
2025-02-19don't get trapped inside of expansions when trimming labelsdianne-13/+13
2025-02-19Improve formatting within `make_mir_visitor` macro body.Nicholas Nethercote-142/+128
rustfmt doesn't touch it because it's a macro body, but it's large enough that the misformatting is annoying. This commit improves it. The most common problems fixed: - Unnecessary multi-line patterns reduced to one line. - Multi-line function headers adjusted so the parameter indentation doesn't depend on the length of the function name. (This is Rust code, not C.) - `|` used at the start of lines, not the end. - More consistent formatting of empty function bodies. - Overly long lines are broken.
2025-02-19Remove `MirVisitable`.Nicholas Nethercote-43/+18
The `MirVisitable` trait is just a complicated way to visit either a statement or a terminator. (And its impl for `Terminator` is unused.) It has a single use. This commit removes it, replacing it with an if/else, which is shorter and simpler.
2025-02-19Add `super_local` method to the MIR visitors.Nicholas Nethercote-4/+14
`visit_local` is the only method that doesn't call a corresponding `super_local` method. This is valid, because `super_local` would be empty. But it's inconsistent with every other case; we have multiple other empty `super` methods: `super_span`, `super_ty`, etc. This commit adds an empty `super_local` and makes `visit_local` call it.
2025-02-19Auto merge of #136539 - matthewjasper:late-normalize-errors, r=compiler-errorsbors-48/+108
Emit dropck normalization errors in borrowck Borrowck generally assumes that any queries it runs for type checking will succeed, thinking that HIR typeck will have errored first if there was a problem. However as of #98641, dropck isn't run on HIR, so there's no direct guarantee that it doesn't error. While a type being well-formed might be expected to ensure that its fields are well-formed, this is not the case for types containing a type projection: ```rust pub trait AuthUser { type Id; } pub trait AuthnBackend { type User: AuthUser; } pub struct AuthSession<Backend: AuthnBackend> { data: Option<<<Backend as AuthnBackend>::User as AuthUser>::Id>, } pub trait Authz: Sized { type AuthnBackend: AuthnBackend<User = Self>; } pub fn run_query<User: Authz>(auth: AuthSession<User::AuthnBackend>) {} // ^ No User: AuthUser bound is required or inferred. ``` While improvements to trait solving might fix this in the future, for now we go for a pragmatic solution of emitting an error from borrowck (by rerunning dropck outside of a query) and making drop elaboration check if an error has been emitted previously before panicking for a failed normalization. Closes #103899 Closes #135039 r? `@compiler-errors` (feel free to re-assign)
2025-02-19x86_win64 ABI: do not use xmm0 with softfloat ABIRalf Jung-6/+10
2025-02-19Register USAGE_OF_TYPE_IR_INHERENT, remove inherent usagesMichael Goulet-5/+4
2025-02-19Make fewer crates depend on rustc_ast_irMichael Goulet-39/+30
2025-02-19Auto merge of #137248 - matthiaskrgr:rollup-s18zjau, r=matthiaskrgrbors-459/+483
Rollup of 9 pull requests Successful merges: - #136936 (Use 'yes' instead of 'while-echo' in tests/ui/process/process-sigpipe.rs except 'nto') - #137026 (Stabilize (and const-stabilize) `integer_sign_cast`) - #137059 (fix: Alloc new errorcode E0803 for E0495) - #137177 (Update `minifier-rs` version to `0.3.5`) - #137210 (compiler: Stop reexporting stuff in cg_llvm::abi) - #137213 (Remove `rustc_middle::mir::tcx` module.) - #137216 (eval_outlives: bail out early if both regions are in the same SCC) - #137228 (Fix typo in hidden internal docs of `TrustedRandomAccess`) - #137242 (Add reference annotations for the `do_not_recommend` attribute) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-19Restrict bevy hackMichael Goulet-28/+35
2025-02-19coverage: Make `HolesVisitor::visit_hole_span` a regular methodZalathar-18/+18
2025-02-19coverage: Get hole spans from nested items without fully visiting themZalathar-8/+9
It turns out that this visitor doesn't actually need `nested_filter::All` to handle nested items; it just needs to override `visit_nested_item` and look up the item's span.
2025-02-18simplify fallback-to-outer condition on old editionsdianne-11/+7
2025-02-18rename `consider_inherited_ref_first` -> `consider_inherited_ref`dianne-5/+5
2025-02-18clarify wording on doc commentdianne-6/+9
Co-authored-by: Nadrieril <Nadrieril@users.noreply.github.com>
2025-02-18"classic2021" ruleset: experimentally add fallback-to-outer (eat both)dianne-28/+18
My reasoning: the ruleset implemented by the same feature gate in Edition 2024 always tries to eat the inherited reference first. For consistency, it makes sense to me to say across all editions that users should consider the inherited reference's mutability when wondering if a `&mut` pattern will type.
2025-02-18add FIXMEs for diagnostic improvementsdianne-0/+8
2025-02-18"structural2021" ruleset: add fallback-to-outer (eat both) deref ruledianne-6/+37
2025-02-18"classic2021" and "structural2021" rulesets: add eat-inherited-ref-alone ↵dianne-7/+32
deref rules
2025-02-19Auto merge of #135408 - RalfJung:x86-sse2, r=workingjubileebors-47/+85
x86: use SSE2 to pass float and SIMD types This builds on the new X86Sse2 ABI landed in https://github.com/rust-lang/rust/pull/137037 to actually make it a separate ABI from the default x86 ABI, and use SSE2 registers. Specifically, we use it in two ways: to return `f64` values in a register rather than by-ptr, and to pass vectors of size up to 128bit in a register (or, well, whatever LLVM does when passing `<4 x float>` by-val, I don't actually know if this ends up in a register). Cc `@workingjubilee` Fixes #133611 try-job: aarch64-apple try-job: aarch64-gnu try-job: aarch64-gnu-debug try-job: test-various try-job: x86_64-gnu-nopt try-job: dist-i586-gnu-i586-i686-musl try-job: x86_64-msvc-1
2025-02-19Rollup merge of #137216 - amandasystems:cheap-outlives-eval, r=compiler-errorsMatthias Krüger-0/+5
eval_outlives: bail out early if both regions are in the same SCC A drive-by optimisation of region outlives evaluation: if we are evaluating whether an outlives holds for two regions, bail out early if they are both in the same SCC. This probably won't make a huge difference, but the cost is one comparison of SCC indices (integers). May want a perf run, depending on how confident whomever reviewing this is!
2025-02-19Rollup merge of #137213 - nnethercote:rm-rustc_middle-mir-tcx, r=compiler-errorsMatthias Krüger-430/+402
Remove `rustc_middle::mir::tcx` module. This is a really weird module. For example, what does `tcx` in `rustc_middle::mir::tcx::PlaceTy` mean? The answer is "not much". The top-level module comment says: > Methods for the various MIR types. These are intended for use after > building is complete. Awfully broad for a module that has a handful of impl blocks for some MIR types, none of which really relates to `TyCtxt`. `git blame` indicates the comment is ancient, from 2015, and made sense then. This module is now vestigial. This commit removes it and moves all the code within into `rustc_middle::mir::statement`. Some specifics: - `Place`, `PlaceRef`, `Rvalue`, `Operand`, `BorrowKind`: they all have `impl` blocks in both the `tcx` and `statement` modules. The commit merges the former into the latter. - `BinOp`, `UnOp`: they only have `impl` blocks in `tcx`. The commit moves these into `statement`. - `PlaceTy`, `RvalueInitializationState`: they are defined in `tcx`. This commit moves them into `statement` *and* makes them available in `mir::*`, like many other MIR types. r? `@tmandry`
2025-02-19Rollup merge of #137210 - workingjubilee:fixup-passmode-import, r=RalfJungMatthias Krüger-27/+27
compiler: Stop reexporting stuff in cg_llvm::abi The reexports confuse tooling like rustdoc into thinking cg_llvm is the source of key types that originate in rustc_target.
2025-02-19Rollup merge of #137059 - xizheyin:issue-136827, r=davidtwcoMatthias Krüger-2/+49
fix: Alloc new errorcode E0803 for E0495 As discussion in #136827, I alloc a new errorcode.
2025-02-19Remove `rustc_middle::mir::tcx` module.Nicholas Nethercote-430/+402
This is a really weird module. For example, what does `tcx` in `rustc_middle::mir::tcx::PlaceTy` mean? The answer is "not much". The top-level module comment says: > Methods for the various MIR types. These are intended for use after > building is complete. Awfully broad for a module that has a handful of impl blocks for some MIR types, none of which really relates to `TyCtxt`. `git blame` indicates the comment is ancient, from 2015, and made sense then. This module is now vestigial. This commit removes it and moves all the code within into `rustc_middle::mir::statement`. Some specifics: - `Place`, `PlaceRef`, `Rvalue`, `Operand`, `BorrowKind`: they all have `impl` blocks in both the `tcx` and `statement` modules. The commit merges the former into the latter. - `BinOp`, `UnOp`: they only have `impl` blocks in `tcx`. The commit moves these into `statement`. - `PlaceTy`, `RvalueInitializationState`: they are defined in `tcx`. This commit moves them into `statement` *and* makes them available in `mir::*`, like many other MIR types.
2025-02-18Auto merge of #137235 - matthiaskrgr:rollup-2kjua2t, r=matthiaskrgrbors-394/+319
Rollup of 10 pull requests Successful merges: - #135711 (Do not ICE on default_field_value const with lifetimes) - #136599 (librustdoc: more usages of `Joined::joined`) - #136876 (Locking documentation updates) - #137000 (Deeply normalize item bounds in new solver) - #137126 (fix docs for inherent str constructors) - #137161 (Pattern Migration 2024: fix incorrect messages/suggestions when errors arise in macro expansions) - #137191 (Update mdbook and move error_index_generator) - #137203 (Improve MIR modification) - #137206 (Make E0599 a structured error) - #137218 (misc `layout_of` cleanup) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-18Lint `#[must_use]` attributes applied to methods in trait implsSamuel Tardieu-18/+29
The `#[must_use]` attribute has no effect when applied to methods in trait implementations. This case was not linted before.
2025-02-18When giving a suggestion to use :: instead of . where the rhs is a macro ↵Zachary S-1/+1
giving a type, make it also work when the rhs is a type alias, not just a struct.
2025-02-18Suggest using :: instead of . for enums in some cases.Zachary S-14/+56
Suggest replacing `.` with `::` when encountering "expected value, found enum": - in a method-call expression and the method has the same name as a tuple variant - in a field-access expression and the field has the same name as a unit or tuple variant
2025-02-18Suggest using :: instead of . in more cases.Zachary S-9/+7
When `Foo.field` or `Foo.method()` exprs are encountered, suggest `Foo::field` or `Foo::method()` when Foo is a type alias, not just a struct, trait, or module. Also rename test for this suggestion from issue-22692.rs to something more meaningful.
2025-02-18Rollup merge of #137218 - lukas-code:layout_of_cleanup, r=compiler-errorsMatthias Krüger-103/+93
misc `layout_of` cleanup See individual commits for details. r? `@oli-obk` but feel free to reassign
2025-02-18Rollup merge of #137206 - estebank:e0599-structured, r=jieyouxuMatthias Krüger-18/+25
Make E0599 a structured error
2025-02-18Rollup merge of #137203 - nnethercote:improve-MIR-modification, ↵Matthias Krüger-206/+127
r=compiler-errors Improve MIR modification A few commits that simplify code that manipulates MIR bodies. r? `@tmiasko`
2025-02-18Rollup merge of #137161 - dianne:pat-migration-bookkeeping-for-macros, ↵Matthias Krüger-16/+18
r=Nadrieril Pattern Migration 2024: fix incorrect messages/suggestions when errors arise in macro expansions See the diff between the two commits for how this affected the error message and suggestion. In order to decide how to format those, the pattern migration diagnostic keeps track of which parts of the user's pattern cause problems in Edition 2024. However, it neglected to do some of this bookkeeping when pointing to macro expansion sites. This fixes that.
2025-02-18Rollup merge of #137000 - compiler-errors:deeply-normalize-item-bounds, r=lcnrMatthias Krüger-50/+51
Deeply normalize item bounds in new solver Built on #136863. Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/142. Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/151. cc https://github.com/rust-lang/trait-system-refactor-initiative/issues/116 First commit reworks candidate preference for projection bounds to prefer param-env projection clauses even if the corresponding trait ref doesn't come from the param-env. Second commit adjusts the associated type item bounds check to deeply normalize in the new solver. This causes some test fallout which I will point out. r? lcnr
2025-02-18Rollup merge of #135711 - estebank:issue-135649, r=davidtwcoMatthias Krüger-1/+5
Do not ICE on default_field_value const with lifetimes `#![feature(default_field_values)]` uses a `const` body that should be treated as inline `const`s, but is actually being detected otherwise. This is similar to the situation in #78174, so we take the same solution: we check if the const actually comes from a field, and if it does, we use that logic to get the appropriate lifetimes and not ICE during borrowck. Fix #135649.
2025-02-18Rollup merge of #137221 - bjorn3:remove_unused_field, r=compiler-errorsUrgau-3/+1
Remove scrutinee_hir_id from ExprKind::Match It is unused.
2025-02-18Rollup merge of #137214 - cyrgani:clippy_diagnostic_items, r=compiler-errorsUrgau-0/+7
add last std diagnostic items for clippy Part of https://github.com/rust-lang/rust-clippy/issues/5393. Add diagnostic item attributes to the items in `std` and `core` where clippy currently uses hardcoded paths (https://github.com/rust-lang/rust-clippy/blob/master/clippy_utils/src/paths.rs).
2025-02-18Rollup merge of #137211 - lcnr:alias-relate-accept-error, r=compiler-errorsUrgau-1/+26
don't ICE for alias-relate goals with error term see comment, fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/165 r? ``@compiler-errors``
2025-02-18Don't mention `FromResidual` on bad `?`Esteban Küber-0/+8
Unless `try_trait_v2` is enabled, don't mention that `FromResidual` isn't implemented for a specific type when the implicit `From` conversion of a `?` fails. For the end user on stable, `?` might as well be a compiler intrinsic, so we remove that note to avoid further confusion and allowing other parts of the error to be more prominent. ``` error[E0277]: `?` couldn't convert the error to `u8` --> $DIR/bad-interconversion.rs:4:20 | LL | fn result_to_result() -> Result<u64, u8> { | --------------- expected `u8` because of this LL | Ok(Err(123_i32)?) | ------------^ the trait `From<i32>` is not implemented for `u8` | | | this can't be annotated with `?` because it has type `Result<_, i32>` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the following other types implement trait `From<T>`: `u8` implements `From<Char>` `u8` implements `From<bool>` ```
2025-02-18Rollup merge of #137202 - Mark-Simulacrum:interned-is-hash, r=saethlinUrgau-1/+43
Enforce T: Hash for Interned<...> This adds panicking Hash impls for several resolver types that don't actually satisfy this condition. It's not obvious to me that rustc_resolve actually upholds the Interned guarantees but fixing that seems pretty hard (the structures have at minimum some interior mutability, so it's not really recursively hashable in place...). FIXME comments as such on those impls. cc https://github.com/rust-lang/rust/pull/137196#issuecomment-2664350287 r? ``@saethlin``
2025-02-18Rollup merge of #137195 - workingjubilee:remove-pref-align-from-cg-clif, ↵Urgau-5/+4
r=bjorn3 cg_clif: use exclusively ABI alignment This will minimize possible conflict with future updates to AbiAndPrefAlign that may remove some fields. It is also almost a bug to consider them. r? ``@bjorn3``
2025-02-18Rollup merge of #137151 - Urgau:register-more-signals, r=workingjubileeUrgau-11/+39
Install more signal stack trace handlers This PR install the signal stack handler to more signals (`SIGILL`, ~~`SIGTRAP`~~, ~~`SIGABRT`~~, ~~`SIGFPE`~~, `SIGBUS`, ~~`SIGQUIT`~~). Noticed in https://github.com/rust-lang/rust/issues/137138 that we didn't print anything for `SIGILL`, so I though we could just handle more signals. r? `````@workingjubilee````` since you last touched it
2025-02-18update `cfg(bootstrap)`Josh Stone-216/+0
2025-02-18update version placeholdersJosh Stone-14/+14
(cherry picked from commit e4840ce59bdddb19394df008c5c26d9c493725f8)
2025-02-18x86-sse2 ABI: use SSE registers for floats and SIMDRalf Jung-47/+85
2025-02-18Remove scrutinee_hir_id from ExprKind::Matchbjorn3-3/+1
It is unused
2025-02-18cosmetic changesLukas Markeffsky-18/+22
- change function parameter order to `cx, ty, ...` to match the other functions in this file - use `ct` identifier for `ty::Const` to match the majority of the compiler codebase - remove useless return - bring match arms in a more natural order
2025-02-18remove useless parameterLukas Markeffsky-36/+10
Remove the `repr` parameter from the wrappers around `calc.univariant`, because it's always defaulted. Only ADTs can have a repr and those call `calc.layout_of_struct_or_enum` and not `calc.univariant`.