summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-06-22Rollup merge of #142776 - dtolnay:hirattrstyle2, r=jdonszelmannJacob Pratt-119/+124
All HIR attributes are outer Fixes https://github.com/rust-lang/rust/issues/142649. Closes https://github.com/rust-lang/rust/pull/142759. All HIR attributes, including parsed and not yet parsed, will now be rendered as outer attributes by `rustc_hir_pretty`. The original style of the corresponding AST attribute(s) is not relevant for pretty printing, only for diagnostics. r? ````@jdonszelmann````
2025-06-22Rollup merge of #142617 - lcnr:search_graph-3, r=compiler-errorsJacob Pratt-73/+122
improve search graph docs, reset `encountered_overflow` between reruns I think this shouldn't really matter for now. It will be more relevant for my current rework as we otherwise cannot partially reevaluate the root goal in case there has been overflow during the prervious iteration. r? ````@BoxyUwU````
2025-06-22Rollup merge of #142600 - GrigorenkoPV:attributes/rustc_pub_transparent, ↵Jacob Pratt-4/+29
r=jdonszelmann Port `#[rustc_pub_transparent]` to the new attribute system Very similar to rust-lang/rust#142498. This is a part of rust-lang/rust#131229, so r? ````@jdonszelmann```` --- For reference, the `#[rustc_pub_transparent]` attribute was created by me back in rust-lang/rust#129487. As mentioned back in https://github.com/rust-lang/rust/pull/129487#discussion_r1730120385, this attribute does not check that it is applied to an ADT, because it checks that `#[repr(transparent)]` is also applied to the same item, which, in turn, should check for ADT.
2025-06-21Auto merge of #142546 - cjgillot:reachable-jump, r=compiler-errorsbors-1/+1
Only traverse reachable blocks in JumpThreading. Fixes https://github.com/rust-lang/rust/issues/131451 We only compute loop headers for reachable blocks. We shouldn't try to perform an opt on unreachable blocks anyway.
2025-06-21Port `#[rustc_pub_transparent]` to the new attribute systemPavel Grigorenko-4/+29
2025-06-21All HIR attributes are outerDavid Tolnay-108/+89
2025-06-21Remove style() from AttributeExt traitDavid Tolnay-23/+11
2025-06-21Add AttributeExt::doc_resolution_scopeDavid Tolnay-1/+37
2025-06-21Rollup merge of #142698 - tgross35:concat-byte-cstr-diag, r=petrochenkovJana Dönszelmann-10/+41
Improve diagnostics for `concat_bytes!` with C string literals Use the same error as other invalid types for `concat_bytes!`, rather than using `ConcatCStrLit` from `concat!`. Also add more information with a note about why this doesn't work, and a suggestion to use a null-terminated byte string instead.
2025-06-21Rollup merge of #142690 - petrochenkov:expnoparam, r=compiler-errorsJana Dönszelmann-46/+46
expand: Remove some unnecessary generic parameters
2025-06-21Rollup merge of #142539 - GrigorenkoPV:attributes/may_dangle, r=jdonszelmannJana Dönszelmann-3/+33
Port `#[may_dangle]` to the new attribute system Very similar to rust-lang/rust#142498. This is a part of rust-lang/rust#131229, so r? `@jdonszelmann`
2025-06-21Rollup merge of #142804 - zachs18:rename-layouts-to-layoutdata-in-comments, ↵Matthias Krüger-8/+8
r=saethlin Rename `LayoutS` to `LayoutData` in comments `LayoutS` was renamed to `LayoutData`, but some comments in the compiler were not changed. This updates comments in the compiler (and one section of commented-out code in rust-analyzer) to refer to `LayoutData` instead of `LayoutS`. cc <https://github.com/rust-lang/rust/pull/132252>, `@workingjubilee`
2025-06-21Rollup merge of #142801 - compiler-errors:gen-blocks, r=oli-obkMatthias Krüger-154/+139
Use gen blocks in the compiler instead of `from_coroutine` r? oli-obk
2025-06-21Rollup merge of #142787 - samueltardieu:diag-items-for-clippy, ↵Matthias Krüger-0/+7
r=Manishearth,Urgau Add diagnostic items for Clippy Clippy still uses some paths to access items from the standard library. Adding the missing diagnostic items allows removing the last remaining paths. Closes rust-lang/rust-clippy#5393
2025-06-21Rollup merge of #142597 - folkertdev:abi-cannot-be-called, r=workingjubileeMatthias Krüger-25/+52
error on calls to ABIs that cannot be called We recently added `extern "custom"`, which cannot be called using a rust call expression. But there are more ABIs that can't be called in that way, because the call does not semantically make sense. More details are in https://github.com/rust-lang/rust/issues/140566#issuecomment-2846205457 r? `@workingjubilee` try-job: x86_64-gnu-llvm-19-3
2025-06-20Rollup merge of #142765 - workingjubilee:more-abimap-docs, r=compiler-errorsTrevor Gross-0/+6
rustc_target: document public AbiMap-related fn and variants
2025-06-20Rollup merge of #142716 - nnethercote:adjust-with_generic_param_rib, ↵Trevor Gross-119/+77
r=petrochenkov Adjust `with_generic_param_rib`. Currently all of its call sites construct a `LifetimeRibKind::Generics` value, which `with_generic_param_rib` then deconstructs (and panics if it's a different `LifetimeRibKind` variant). This commit makes the code simpler and shorter: the call sites just pass in the three values and `with_generic_param_rib` constructs the `LifetimeRibKind::Generics` value from them. r? `@petrochenkov`
2025-06-20Rollup merge of #142571 - cjgillot:borrowed-classes, r=oli-obkTrevor Gross-27/+30
Reason about borrowed classes in CopyProp. Fixes https://github.com/rust-lang/rust/issues/141122 The current implementation of `CopyProp` avoids unifying two borrowed locals, as this would change the result of address comparison. However, the implementation was inconsistent with the general algorithm, which identifies equivalence classes of locals and then replaces all locals by a single representative of their equivalence class. This PR fixes it by forbidding the unification of two *classes* if any of those contain a borrowed local.
2025-06-20Rollup merge of #142485 - mu001999-contrib:dead-code/adt-pattern, r=petrochenkovTrevor Gross-50/+28
Marks ADT live if it appears in pattern Marks ADT live if it appears in pattern, it implies the construction of the ADT. 1. Then we can detect unused private ADTs impl `Default`, without special logics for `Default` and other std traits. 2. We can also remove `rustc_trivial_field_reads` on `Default`, and the logic in `should_ignore_item` (introduced by rust-lang/rust#126302). Fixes rust-lang/rust#120770 Extracted from rust-lang/rust#128637. r? `@petrochenkov`
2025-06-20Rollup merge of #142476 - dtolnay:attrbinop, r=fmeaseTrevor Gross-12/+38
Insert parentheses around binary operation with attribute Fixes the bug found by `@fmease` in https://github.com/rust-lang/rust/pull/134661#pullrequestreview-2538983253. Previously, `-Zunpretty=expanded` would expand this program as follows: ```rust #![feature(stmt_expr_attributes)] #![allow(unused_attributes)] macro_rules! group { ($e:expr) => { $e }; } macro_rules! extra { ($e:expr) => { #[allow()] $e }; } fn main() { let _ = #[allow()] 1 + 1; let _ = group!(#[allow()] 1) + 1; let _ = 1 + group!(#[allow()] 1); let _ = extra!({ 0 }) + 1; let _ = extra!({ 0 } + 1); } ``` ```console let _ = #[allow()] 1 + 1; let _ = #[allow()] 1 + 1; let _ = 1 + #[allow()] 1; let _ = #[allow()] { 0 } + 1; let _ = #[allow()] { 0 } + 1; ``` The first 4 statements are the correct expansion, but the last one is not. The attribute is supposed to apply to the entire binary operation, not only to the left operand. After this PR, the 5th statement will expand to: ```console let _ = #[allow()] ({ 0 } + 1); ``` In the future, as some subset of `stmt_expr_attributes` approaches stabilization, it is possible that we will need to do parenthesization for a number of additional cases depending on the outcome of https://github.com/rust-lang/rust/issues/127436. But for now, at least this PR makes the pretty-printer align with the current behavior of the parser. r? fmease
2025-06-20Rollup merge of #142384 - celinval:chores-rayon-mv, r=oli-obkTrevor Gross-22/+7889
Bringing `rustc_rayon_core` in tree as `rustc_thread_pool` This PR moves [`rustc_rayon_core`](https://github.com/rust-lang/rustc-rayon/tree/5fadf44/rayon-core) from commit `5fadf44` as suggested in [this zulip thread](https://rust-lang.zulipchat.com/#narrow/channel/187679-t-compiler.2Fparallel-rustc/topic/Bringing.20.60rustc_rayon_core.60.20in.20tree). I tried to split the work into separate commits so it is easy to review. The first commit is a simple copy and paste from the fork, and subsequent changes were made to use the new crate and to ensure the new crate complies with different format and lint expectations. **Call-out:** I was also wondering if I need to make any further changes to accommodate licensing requirements. r? oli-obk
2025-06-20Auto merge of #142794 - tgross35:rollup-iae7okj, r=tgross35bors-610/+678
Rollup of 9 pull requests Successful merges: - rust-lang/rust#142331 (Add `trim_prefix` and `trim_suffix` methods for both `slice` and `str` types.) - rust-lang/rust#142491 (Rework #[cold] attribute parser) - rust-lang/rust#142494 (Fix missing docs in `rustc_attr_parsing`) - rust-lang/rust#142495 (Better template for `#[repr]` attributes) - rust-lang/rust#142497 (Fix random failure when JS code is executed when the whole file was not read yet) - rust-lang/rust#142575 (Ensure copy* intrinsics also perform the static self-init checks) - rust-lang/rust#142650 (Refactor Translator) - rust-lang/rust#142713 (mbe: Refactor transcription) - rust-lang/rust#142755 (rustdoc: Remove `FormatRenderer::cache`) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-20Insert parentheses around binary operation with attributeDavid Tolnay-12/+38
2025-06-20Port `#[may_dangle]` to the new attribute systemPavel Grigorenko-3/+33
2025-06-20Use gen blocks in the compiler instead of from_coroutineMichael Goulet-154/+139
2025-06-20Rollup merge of #142769 - jdonszelmann:remove-useless-new-method, r=tgross35Jakub Beránek-9/+3
remove equivalent new method on context Noticed the two had converged so much they literally became equivalent. So one could go hehe
2025-06-20Rollup merge of #142767 - nnethercote:symbol-cleanups, r=petrochenkovJakub Beránek-21/+26
Some symbol and PathRoot cleanups I'm looking into unifying how we join and print paths. Here are some preliminary cleanups. r? ``@petrochenkov``
2025-06-20Rollup merge of #142715 - folkertdev:fn-align-corrections, r=jdonszelmannJakub Beránek-2/+2
correct template for `#[align]` attribute Tracking issue: https://github.com/rust-lang/rust/issues/82232 related: https://github.com/rust-lang/rust/pull/142507 I didn't fully understand what `template!` did, clearly. An empty `#[align]` attribute was still rejected later, but without this change it does get suggested in certain cases. I've also updated some outdated references to `#[repr(align)]` on functions. r? ``@jdonszelmann``
2025-06-20compiler: Rename LayoutS to LayoutData in commentsZachary S-8/+8
2025-06-20Rollup merge of #142713 - tgross35:mbe-transcribe-refactor, r=petrochenkovTrevor Gross-363/+404
mbe: Refactor transcription Introduce `MacroTcbCtx` that holds everything relevant to transcription. This allows for the following changes: * Split `transcribe_sequence` and `transcribe_metavar` out of the heavily nested `transcribe` * Split `metavar_expr_concat` out of `transcribe_metavar_expr` This is a nonfunctional change.
2025-06-20Rollup merge of #142650 - camsteffen:refactor-translator, r=petrochenkovTrevor Gross-232/+185
Refactor Translator My main motivation was to simplify the usage of `SilentEmitter` for users like rustfmt. A few refactoring opportunities arose along the way. * Replace `Translate` trait with `Translator` struct * Replace `Emitter: Translate` with `Emitter::translator` * Split `SilentEmitter` into `FatalOnlyEmitter` and `SilentEmitter`
2025-06-20Rollup merge of #142575 - oli-obk:sneaky-self-init, r=RalfJungTrevor Gross-1/+6
Ensure copy* intrinsics also perform the static self-init checks fixes rust-lang/rust#142532 r? `@RalfJung`
2025-06-20Rollup merge of #142495 - jdonszelmann:better-repr-template, r=oli-obkTrevor Gross-1/+2
Better template for `#[repr]` attributes
2025-06-20Rollup merge of #142494 - jdonszelmann:missing-attr-parsing-docs, r=oli-obkTrevor Gross-0/+19
Fix missing docs in `rustc_attr_parsing`
2025-06-20Rollup merge of #142491 - jdonszelmann:cold, r=oli-obkTrevor Gross-13/+62
Rework #[cold] attribute parser r? `@oli-obk`
2025-06-20error on calls to ABIs that cannot be calledFolkert de Vries-25/+52
2025-06-20Add diagnostic items for ClippySamuel Tardieu-0/+7
2025-06-20expected word diagnostic testJana Dönszelmann-3/+4
2025-06-20coldJana Dönszelmann-13/+61
2025-06-20Auto merge of #142316 - compiler-errors:cache-param-env, r=lcnrbors-20/+177
[perf] Cache the canonical *instantiation* of param-envs r? lcnr
2025-06-20Ensure copy* intrinsics also perform the static self-init checksOli Scherer-1/+6
2025-06-20Rollup merge of #142687 - cjgillot:less-hir_crate, r=oli-obkTrevor Gross-100/+48
Reduce uses of `hir_crate`. I tried rebasing my old incremental-HIR branch. This is a by-product, which is required if we want to get rid of `hir_crate` entirely. The second commit is a drive-by cleanup. It can be pulled into its own PR. r? ````@oli-obk````
2025-06-20Rollup merge of #140920 - RalfJung:target-feature-unification, ↵Trevor Gross-602/+486
r=nnethercote,WaffleLapkin Extract some shared code from codegen backend target feature handling There's a bunch of code duplication between the GCC and LLVM backends in target feature handling. This moves that into new shared helper functions in `rustc_codegen_ssa`. The first two commits should be purely refactoring. I am fairly sure the LLVM-side behavior stays the same; if the GCC side deliberately diverges from this then I may have missed that. I did account for one divergence, which I do not know is deliberate or not: GCC does not seem to use the `-Ctarget-feature` flag to populate `cfg(target_feature)`. That seems odd, since the `-Ctarget-feature` flag is used to populate the return value of `global_gcc_features` which controls the target features actually used by GCC. ``@GuillaumeGomez`` ``@antoyo`` is there a reason `target_config` ignores `-Ctarget-feature` but `global_gcc_features` does not? The second commit also cleans up a bunch of unneeded complexity added in https://github.com/rust-lang/rust/pull/135927. The third commit extracts some shared logic out of the functions that populate `cfg(target_feature)` and the backend target feature set, respectively. This one actually has some slight functional changes: - Before, with `-Ctarget-feature=-feat`, if there is some other feature `x` that implies `feat` we would *not* add `-x` to the backend target feature set. Now, we do. This fixes rust-lang/rust#134792. - The logic that removes `x` from `cfg(target_feature)` in this case also changed a bit, avoiding a large number of calls to the (uncached) `sess.target.implied_target_features` (if there were a large number of positive features listed before a negative feature) but instead constructing a full inverse implication map when encountering the first negative feature. Ideally this would be done with queries but the backend target feature logic runs before `tcx` so we can't use that... - Previously, if feature "a" implied "b" and "b" was unstable, then using `-Ctarget-feature=+a` would also emit a warning about `b`. I had to remove this since when accounting for negative implications, this emits a ton of warnings in a bunch of existing tests... I assume this was unintentional anyway. The fourth commit increases consistency of the GCC backend with the LLVM backend. The last commit does some further cleanup: - Get rid of RUSTC_SPECIAL_FEATURES. It was only needed for s390x "backchain", but since LLVM 19 that is always a regular target feature so we don't need this hack any more. The hack also has various unintended side-effects so we don't want to keep it. Fixes https://github.com/rust-lang/rust/issues/142412. - Move RUSTC_SPECIFIC_FEATURES handling into the shared parse_rust_feature_flag helper so all consumers of `-Ctarget-feature` that only care about actual target features (and not "crt-static") have it. Previously, we actually set `cfg(target_feature = "crt-static")` twice: once in the backend target feature logic, and once specifically for that one feature. IIUC, some targets are meant to ignore `-Ctarget-feature=+crt-static`, it seems like before this PR that flag still incorrectly enabled `cfg(target_feature = "crt-static")` (but I didn't test this). - Move fixed_x18 handling together with retpoline handling. - Forbid setting fixed_x18 as a regular target feature, even unstably. It must be set via the `-Z` flag. ``@bjorn3`` I did not touch the cranelift backend here, since AFAIK it doesn't really support target features. But if you ever do, please use the new helpers. :) Cc ``@workingjubilee``
2025-06-20Rollup merge of #138291 - jdonszelmann:optimize-attr, r=oli-obkTrevor Gross-52/+63
rewrite `optimize` attribute to use new attribute parsing infrastructure r? ```@oli-obk``` I'm afraid we'll get quite a few of these PRs in the future. If we get a lot of trivial changes I'll start merging multiple into one PR. They should be easy to review :) Waiting on #138165 first
2025-06-20remove equivalent new method on contextJana Dönszelmann-9/+3
2025-06-20Avoid some unnecessary symbol interning.Nicholas Nethercote-8/+9
- `Ident::from_str_and_span` -> `Ident::new` when the string is pre-interned. - `Ident::from_str` -> `Ident::with_dummy_span` when the string is pre-interned. - `_d` and `_e` are unused.
2025-06-20Use a symbol for `ExpansionConfig::crate_name`.Nicholas Nethercote-11/+12
This avoids some symbol interning and `to_string` conversions.
2025-06-20Fix `tests/ui/asm/naked-invalid-attr.stderr`.Nicholas Nethercote-2/+5
`{{root}}` is supposed to be an internal-only name but it shows up in the output. (I'm working towards a more general fix -- a universal "joiner" function that can be used all over the place -- but I'm not there yet, so let's fix this one in-place for now.)
2025-06-19rustc_target: document public AbiMap-related fn and variantsJubilee Young-0/+6
2025-06-19Auto merge of #140748 - m-ou-se:super-format-args3, r=jdonszelmannbors-162/+114
Allow storing `format_args!()` in variable Fixes https://github.com/rust-lang/rust/issues/92698 Tracking issue for super let: https://github.com/rust-lang/rust/issues/139076 Tracking issue for format_args: https://github.com/rust-lang/rust/issues/99012 This change allows: ```rust let name = "world"; let f = format_args!("hello {name}!"); // New: Store format_args!() for later! println!("{f}"); ``` This will need an FCP. This implementation makes use of `super let`, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have _a_ way of expressing temporary lifetimes like this, since the (stable) `pin!()` macro needs this too. (This was also the motivation for merging https://github.com/rust-lang/rust/pull/139114.) (This is a second version of https://github.com/rust-lang/rust/pull/139135)