about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-07-06Move check for new attribute to `check_builtin_meta_item`Jonathan Brouwer-36/+35
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-06Auto merge of #143509 - cjgillot:copy-prop-noborrow, r=tmiaskobors-2/+2
Do not unify borrowed locals in CopyProp. Instead of trying yet another scheme to unify borrowed locals in CopyProp, let's just stop trying. We had already enough miscompilations because of this. I'm convinced it's possible to have both unification of some borrowed locals and soundness, but I don't have a simple and convincing formulation yet. Fixes https://github.com/rust-lang/rust/issues/143491
2025-07-06mbe: Change `unused_macro_rules` to a `DenseBitSet`Josh Triplett-6/+8
Now that it only contains indexes, and no other information, a bitset provides a more compact and simpler representation.
2025-07-06Remove duplicate wordMicke-1/+1
2025-07-06More carefully consider span context when suggesting remove &mutMichael Goulet-5/+8
2025-07-06interpret: rename StackPopCleanupRalf Jung-40/+40
2025-07-06Rollup merge of #143518 - joshtriplett:sort-attrs, r=KobzolMatthias Krüger-0/+2
rustc_builtin_macros: Make sure registered attributes stay sorted As with the list of builtin macros, use tidy to make sure the list of builtin attributes stays sorted.
2025-07-06Rollup merge of #143492 - Diggsey:db-fix-object-ambiguity, r=RalfJungMatthias Krüger-6/+14
Use `object` crate from crates.io to fix windows build error See https://rust-lang.zulipchat.com/#narrow/channel/386786-rustc-codegen-gcc/topic/Cannot.20compile.20rustc.20on.20Windows.2010/with/527240094
2025-07-06Rollup merge of #143252 - JonathanBrouwer:rewrite_empty_attribute, ↵Matthias Krüger-84/+80
r=jdonszelmann Rewrite empty attribute lint for new attribute parser cc `@jdonszelmann`
2025-07-06move `stable_mir` back to its own crate and move `rustc_internal` to ↵Makai-1288/+1232
the`stable_mir` crate As part of this reorganization, some traits need to be moved from `rustc_smir::context::traits` to `stable_mir::unstable::internal_cx`. These traits are specifically designed for `InternalCx` to clarify the behavior of different functions that share the same name. This move is necessary to avoid orphan rule violations.
2025-07-06Do not unify borrowed locals in CopyProp.Camille GILLOT-2/+2
2025-07-06Rollup merge of #143484 - bvanjoi:issue-140796, r=compiler-errorsMatthias Krüger-2/+29
distinguish the duplicate item of rpitit Fixes rust-lang/rust#140796 r? compiler cc `@Zoxc`
2025-07-06Rollup merge of #143477 - folkertdev:use-is-multiple-of, r=joshtriplettMatthias Krüger-21/+20
use `is_multiple_of` and `div_ceil` In tricky logic, these functions are much more informative than the manual implementations. They also catch subtle bugs: - the manual `is_multiple_of` often does not handle division by zero - manual `div_ceil` often does not consider overflow The transformation is free for `is_multiple_of` if the divisor is compile-time known to be non-zero. For `div_ceil` there is a small cost to considering overflow. Here is some assembly https://godbolt.org/z/5zP8KaE1d.
2025-07-06Rollup merge of #143416 - joshtriplett:mbe-simplifications, r=nnethercoteMatthias Krüger-130/+134
mbe: Defer checks for `compile_error!` until reporting an unused macro rule The current MBE parser checks rules at initial parse time to see if their RHS has `compile_error!` in it, and returns a list of rule indexes and LHS spans that don't map to `compile_error!`, for use in unused macro rule checking. Instead, have the unused macro rule reporting ask the macro for the rule to report, and let the macro check at that time. That avoids checking rules unless they're unused. In the process, refactor the data structure used to store macro rules, to group the LHS and RHS (and LHS span) of each rule together, and refactor the unused rule tracking to only track rule indexes. This builds atop a couple of minor MBE refactors. I would suggest reviewing commit-by-commit. The overall result is a further simplification of the macro code.
2025-07-06Fix line break after ":" in unpretty attribute printJonathan Brouwer-1/+2
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-06Rewrite empty attribute lintJonathan Brouwer-83/+78
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-06distinguish the duplicate item of rpititbohan-2/+29
2025-07-06Auto merge of #143507 - matthiaskrgr:rollup-lpg7t12, r=matthiaskrgrbors-283/+184
Rollup of 6 pull requests Successful merges: - rust-lang/rust#143238 (Port `#[ignore]` to the new attribute parsing infrastructure) - rust-lang/rust#143441 (Stop using `Key` trait unnecessarily) - rust-lang/rust#143478 (Miri subtree update) - rust-lang/rust#143486 (remove armv5te-unknown-linux-gnueabi target maintainer) - rust-lang/rust#143489 (Complete rustc_ast::mut_visit for spans.) - rust-lang/rust#143494 (Remove yields_in_scope from the scope tree.) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-05rustc_builtin_macros: Make sure registered attributes stay sortedJosh Triplett-0/+2
As with the list of builtin macros, use tidy to make sure the list of builtin attributes stays sorted.
2025-07-05remove `DesugaringKind::CondTemporary`dianne-24/+1
2025-07-05de-duplicate condition scoping logicdianne-56/+33
2025-07-05mbe: Defer checks for `compile_error!` until reporting an unused macro ruleJosh Triplett-92/+80
The MBE parser checks rules at initial parse time to see if their RHS has `compile_error!` in it, and returns a list of rule indexes and LHS spans that don't map to `compile_error!`, for use in unused macro rule checking. Instead, have the unused macro rule reporting ask the macro for the rule to report, and let the macro check at that time. That avoids checking rules unless they're unused. In the process, refactor the data structure used to store macro rules, to group the LHS and RHS (and LHS span) of each rule together, and refactor the unused rule tracking to only track rule indexes. This ends up being a net simplification, and reduction in code size.
2025-07-05mbe: Simplify a match to a let-elseJosh Triplett-3/+2
2025-07-05mbe: Add a helper to parse a single `TokenTree`Josh Triplett-22/+20
The parser repeatedly invokes the `parse` function, constructing a one-entry vector, and assuming that the return value will be a one-entry vector. Add a helper for that case. This will simplify adding additional callers, and put all the logic in one place to allow potential future simplification of the one-TT case.
2025-07-05Rollup merge of #143494 - cjgillot:no-yield-in-scope, r=compiler-errorsMatthias Krüger-263/+37
Remove yields_in_scope from the scope tree. I believe this has not been in use since we removed the HIR-based generator interior type computation.
2025-07-05Rollup merge of #143489 - cjgillot:mut-visit-span, r=petrochenkovMatthias Krüger-11/+79
Complete rustc_ast::mut_visit for spans. Extracted from https://github.com/rust-lang/rust/pull/127241 r? `@petrochenkov`
2025-07-05Rollup merge of #143441 - compiler-errors:no-key, r=petrochenkovMatthias Krüger-6/+4
Stop using `Key` trait unnecessarily Few places where the `Key` trait was being used but not really for a useful reason. This fixes those usages. Namely, `<Ty as Key>::default_span()` is `DUMMY_SP` anyways.
2025-07-05Rollup merge of #143238 - JonathanBrouwer:ignore_parser, r=jdonszelmannMatthias Krüger-3/+64
Port `#[ignore]` to the new attribute parsing infrastructure Ports `ignore` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971353197 This PR duplicates a change from https://github.com/rust-lang/rust/pull/143237 Draft until that one is merged
2025-07-05Auto merge of #142732 - compiler-errors:more-root, r=lcnrbors-119/+33
Canonicalize input ty/ct infer/placeholder in the root universe We shouldn't care what universe the inputs are, since we only ever do the leak check on the universes instantiated after entering the canonical binder.
2025-07-05Port `#[ignore]` to the new attribute parsing infrastructureJonathan Brouwer-3/+64
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-05Don't compress input universesMichael Goulet-111/+10
2025-07-05[perf] Skip walking into param-env component if it has no placeholder/re-varMichael Goulet-4/+9
2025-07-05Canonicalize input ty/ct infer/placeholder in the root universeMichael Goulet-8/+23
2025-07-05Stop using Key trait randomlyMichael Goulet-6/+4
2025-07-05Don't call predicates_of on a dummy obligation cause's body idMichael Goulet-13/+20
2025-07-05Make tempfile a normal dependencyDiggory Blake-5/+3
2025-07-05Remove yields_in_scope from the scope tree.Camille GILLOT-263/+37
2025-07-05Use `object` crate from crates.io to fix windows build errorDiggory Blake-1/+11
2025-07-05codegen_ssa: replace a Result by an EitherRalf Jung-23/+24
2025-07-05Complete mut_visit.Camille GILLOT-11/+79
2025-07-05mbe: Introduce an enum for which part of a rule we're parsingJosh Triplett-17/+36
Rather than a `bool` that's `true` for the LHS and `false` for the RHS, use a self-documenting enum.
2025-07-05Auto merge of #143473 - workingjubilee:rollup-bxie7zg, r=scottmcmbors-165/+111
Rollup of 11 pull requests Successful merges: - rust-lang/rust#142440 (`tests/ui`: A New Order [14/N]) - rust-lang/rust#143040 (Add `const Rem`) - rust-lang/rust#143086 (Update poison.rs to fix the typo (sys->sync)) - rust-lang/rust#143202 (`tests/ui`: A New Order [18/N]) - rust-lang/rust#143296 (`tests/ui`: A New Order [21/N]) - rust-lang/rust#143297 (`tests/ui`: A New Order [22/N]) - rust-lang/rust#143299 (`tests/ui`: A New Order [24/N]) - rust-lang/rust#143300 (`tests/ui`: A New Order [25/N]) - rust-lang/rust#143397 (test passing a `VaList` from rust to C) - rust-lang/rust#143410 (Block SIMD in transmute_immediate; delete `OperandValueKind`) - rust-lang/rust#143452 (Fix CLI completion check in `tidy`) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-05Fix short linker error outputia0-4/+11
This PR does 2 things: - It removes the braces when there's a single element. This is required since brace expansion (at least in bash and zsh) only triggers if there's at least 2 elements. - It removes the extra `.rlib` suffixes of the elements. See https://github.com/rust-lang/rust/pull/135707#discussion_r2185212393 for context. Running `cargo +stage1 build` on the following program: ```rust unsafe extern "C" { fn foo() -> libc::c_int; } fn main() { let x = unsafe { foo() } as u32; // println!("{}", data_encoding::BASE64.encode(&x.to_le_bytes())); } ``` Gives the following diff before and after the PR: ```diff -/tmp/foo/target/debug/deps/{liblibc-faf416f178830595.rlib}.rlib +/tmp/foo/target/debug/deps/liblibc-faf416f178830595.rlib ``` Running on the same program with the additional dependency, we get the following diff: ```diff -/tmp/foo/target/debug/deps/{liblibc-faf416f178830595.rlib,libdata_encoding-84bb5aadfa9e8839.rlib}.rlib +/tmp/foo/target/debug/deps/{liblibc-faf416f178830595,libdata_encoding-84bb5aadfa9e8839}.rlib ``` Do we want to add a UI test?
2025-07-05use `div_ceil` instead of manual logicFolkert de Vries-12/+11
2025-07-05use `is_multiple_of` instead of manual moduloFolkert de Vries-9/+9
2025-07-04only check for mixed deref/normal constructors when neededdianne-1/+26
2025-07-04always check for mixed deref pattern and normal constructorsdianne-53/+88
This makes it work for box patterns and in rust-analyzer.
2025-07-05Auto merge of #139598 - compiler-errors:no-bound-var-symbol, r=WaffleLapkinbors-327/+292
Remove `Symbol` from `Named` variant of `BoundRegionKind`/`LateParamRegionKind` The `Symbol` is redundant, since we already store a `DefId` in the region variant. Instead, load the name via `item_name` when needed (which is almost always on the diagnostic path). This introduces a `BoundRegionKind::NamedAnon` which is used for giving anonymous bound regions names, but which should only be used during pretty printing and error reporting.
2025-07-04Rollup merge of #143410 - scottmcm:redo-transmute-again, ↵Jubilee-165/+111
r=RalfJung,workingjubilee Block SIMD in transmute_immediate; delete `OperandValueKind` Vectors have been causing me problems for years in this code, for example https://github.com/rust-lang/rust/pull/110021#discussion_r1160975086 and https://github.com/rust-lang/rust/pull/143194 See conversation in <https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Is.20transmuting.20a.20.60T.60.20to.20.60Tx1.60.20.28one-element.20SIMD.20vector.29.20UB.3F/near/526262799>. By blocking SIMD in `transmute_immediate` it can be simplified to just take the `Scalar`s involved -- the backend types can be gotten from those `Scalar`s, rather than needing to be passed. And there's an assert added to ICE it if it does get hit. Accordingly, this changes `rvalue_creates_operand` to not send SIMD transmutes through the operand path, but to always go through memory instead, like they did back before rust-lang/rust#108442. And thanks to those changes, I could also remove the `OperandValueKind` type that I added back then which `@RalfJung` rightly considers pretty sketchy. cc `@folkertdev` `@workingjubilee` from the zulip conversation too
2025-07-05Auto merge of #138759 - scottmcm:operand-builder, r=saethlinbors-67/+149
Allow `enum` and `union` literals to also create SSA values Today, `Some(x)` always goes through an `alloca`, even in trivial cases where the niching means the constructor doesn't even change the value. For example, <https://rust.godbolt.org/z/6KG6PqoYz> ```rust pub fn demo(r: &i32) -> Option<&i32> { Some(r) } ``` currently emits the IR ```llvm define align 4 ptr `@demo(ptr` align 4 %r) unnamed_addr { start: %_0 = alloca [8 x i8], align 8 store ptr %r, ptr %_0, align 8 %0 = load ptr, ptr %_0, align 8 ret ptr %0 } ``` but with this PR it becomes just ```llvm define align 4 ptr `@demo(ptr` align 4 %r) unnamed_addr { start: ret ptr %r } ``` (Of course the optimizer can clean that up, but it'd be nice if it didn't have to -- especially in debug where it doesn't run. This is like rust-lang/rust#123886, but that only handled non-simd `struct`s -- this PR generalizes it to all non-simd ADTs.) Doing this means handing variants other than `FIRST_VARIANT`, handling the active field for unions, refactoring the discriminant code so the Place and Operand parts can share the calculation, etc. Other PRs that led up to this one: - https://github.com/rust-lang/rust/pull/142005 - https://github.com/rust-lang/rust/pull/142103 - https://github.com/rust-lang/rust/pull/142324 - https://github.com/rust-lang/rust/pull/142383 --- try-job: aarch64-gnu