about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-06-13Use more slicing and slice interning over iterable interningLeón Orell Valerian Liehr-3/+2
2025-06-13[perf] Change asserts to debug ones in trait_ref_and_own_argsLeón Orell Valerian Liehr-3/+3
2025-06-12Auto merge of #142438 - matthiaskrgr:rollup-u1jdnhz, r=matthiaskrgrbors-39/+218
Rollup of 9 pull requests Successful merges: - rust-lang/rust#134536 (Lint on fn pointers comparisons in external macros) - rust-lang/rust#141069 (Suggest mut when possbile for temporary value dropped while borrowed) - rust-lang/rust#141934 (resolve: Tweak `private_macro_use` lint to be compatible with upcoming macro prelude changes) - rust-lang/rust#142034 (Detect method not being present that is present in other tuple types) - rust-lang/rust#142402 (chore(doctest): Remove redundant blank lines) - rust-lang/rust#142406 (Note when enum variants shadow an associated function) - rust-lang/rust#142407 (Remove bootstrap adhoc group) - rust-lang/rust#142408 (Add myself (WaffleLapkin) to review rotation) - rust-lang/rust#142418 (Remove lower_arg_ty as all callers were passing `None`) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-12Detect when attribute is provided by missing `derive` macroEsteban Küber-7/+162
``` error: cannot find attribute `empty_helper` in this scope --> $DIR/derive-helper-legacy-limits.rs:17:3 | LL | #[empty_helper] | ^^^^^^^^^^^^ | help: `empty_helper` is an attribute that can be used by the derive macro `Empty`, you might be missing a `derive` attribute | LL + #[derive(Empty)] LL | struct S2; | ``` Look at proc-macro attributes when encountering unknown attribute ``` error: cannot find attribute `sede` in this scope --> src/main.rs:18:7 | 18 | #[sede(untagged)] | ^^^^ | help: the derive macros `Serialize` and `Deserialize` accept the similarly named `serde` attribute | 18 | #[serde(untagged)] | ~~~~~ error: cannot find attribute `serde` in this scope --> src/main.rs:12:7 | 12 | #[serde(untagged)] | ^^^^^ | = note: `serde` is in scope, but it is a crate, not an attribute help: `serde` is an attribute that can be used by the derive macros `Serialize` and `Deserialize`, you might be missing a `derive` attribute | 10 | #[derive(Serialize, Deserialize)] | ```
2025-06-12Rollup merge of #142418 - oli-obk:lower_arg_ty, r=BoxyUwU,fmeaseMatthias Krüger-12/+2
Remove lower_arg_ty as all callers were passing `None` r? ``@fmease`` or ``@BoxyUwU`` I think this is just leftover from other refactorings
2025-06-12Rollup merge of #142406 - jdonszelmann:dead-code-enum-variant, r=WaffleLapkinMatthias Krüger-1/+44
Note when enum variants shadow an associated function r? ``@WaffleLapkin`` Closes rust-lang/rust#142263
2025-06-12Rollup merge of #142034 - estebank:issue-141258, r=davidtwcoMatthias Krüger-2/+121
Detect method not being present that is present in other tuple types When a method is not present because of a trait bound not being met, and that trait bound is on a tuple, we check if making the tuple have no borrowed types makes the method to be found and highlight it if it does. This is a common problem for Bevy in particular and ORMs in general. <img width="1166" alt="Screenshot 2025-06-04 at 10 38 24 AM" src="https://github.com/user-attachments/assets/d257c9ea-c2d7-42e7-8473-8b93aa54b8e0" /> Address rust-lang/rust#141258. I believe that more combination of cases in the tuple types should be handled (like adding borrows and checking when a specific type needs to not be a borrow while the rest stay the same), but for now this handles the most common case.
2025-06-12Rollup merge of #141934 - petrochenkov:privmacuse, r=compiler-errorsMatthias Krüger-22/+36
resolve: Tweak `private_macro_use` lint to be compatible with upcoming macro prelude changes Unblocks https://github.com/rust-lang/rust/pull/139493. Zulip thread requesting help - [#t-compiler/help > Help requested for effects of #139493](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/Help.20requested.20for.20effects.20of.20.23139493/with/514653911). This PR by itself shouldn't cause any observable changes, its only observable effect is that the prelude changes from https://github.com/rust-lang/rust/pull/139493 will no longer cause regressions in tests like `tests/ui/imports/issue-119369.rs` or `tests/ui/extern/issue-80074.rs`. This is achieved by moving the "is this thing in stdlib prelude" check from an early point (`fn process_macro_use_imports`) to a later point (`fn record_use_inner`), at which the stdlib prelude is already populated and can be inspected. (The `is_builtin_macro` check is subsumed by the stdlib prelude check, all built-in macros go through the stdlib prelude anyway.)
2025-06-12Rollup merge of #141069 - chenyukang:yukang-fix-137486-suggest-mut, r=davidtwcoMatthias Krüger-1/+13
Suggest mut when possbile for temporary value dropped while borrowed Fixes #137486
2025-06-12Rollup merge of #134536 - Urgau:fn-ptr-option, r=compiler-errors,traviscrossMatthias Krüger-1/+2
Lint on fn pointers comparisons in external macros This PR extends the recently stabilized `unpredictable_function_pointer_comparisons` lint ~~to also lint on `Option<{function pointer}>` and~~ as well as linting in external macros (as to catch `assert_eq!` and others). ```rust assert_eq!(Some::<FnPtr>(func), Some(func as unsafe extern "C" fn())); //~^ WARN function pointer comparisons #[derive(PartialEq, Eq)] struct A { f: fn(), //~^ WARN function pointer comparisons } ``` Fixes https://github.com/rust-lang/rust/issues/134527
2025-06-12Auto merge of #138164 - jdonszelmann:attr-parsing-lint-infra, r=oli-obkbors-226/+725
Infrastructure for lints during attribute parsing, specifically duplicate usages of attributes r? `@oli-obk` This PR adds a new field to OwnerInfo to buffer lints which are generated during attribute parsing and ast lowering in general. They can't be emitted at this stage because at that point there's no HIR yet, and early lints are already emitted. This also adds the generic `S: Stage` to attribute parsers. Currently we don't emit any lints during early attribute parsing, but if we ever want to that logic will be different. That's because there we don't have hir ids yet, while at the same time still having access to node ids and early lints. Even though that logic isn't completely there in this PR (no worries, we don't use it), that's why the parameter is there. With this PR, we also add 2 associated consts to `SingleAttributeParser`. Those determine what logic should be applied when finding a duplicate attribute. This PR was getting pretty large, so the first code using this logic is in rust-lang/rust#138165. This code is all new things that weren't possible before so it also doesn't break any behaviour. However, some of it will be dead code right now. I recommend reviewing both before merging, though in some sense that doubles the size of the review again, and the other PR might be more controversial. Let me know how you want to do this `@oli-obk`
2025-06-12add `extern "custom"` functionsFolkert de Vries-10/+311
2025-06-12Rollup merge of #141474 - mejrs:diagnostic_mode, r=compiler-errorsMatthias Krüger-238/+233
Add `ParseMode::Diagnostic` and fix multiline spans in diagnostic attribute lints Best viewed commit by commit. The first commit is a test, the commits following that are small refactors to `rustc_parse_format`. Originally I wanted to do a much larger change (doing these smaller fixes first would have that made easier to review), but ended up doing something else instead. An observable change from this is that the diagnostic attribute no longer tries to parse align/fill/width/etc parameters. For an example (see also test changes), a string like `"{Self:!}"` no longer says "missing '}'", instead it says that format parameters are not allowed. It'll now also format the string as if the user wrote just `"{Self}"`
2025-06-12Rollup merge of #141162 - mejrs:gated, r=fee1-deadMatthias Krüger-195/+135
refactor `AttributeGate` and `rustc_attr!` to emit notes during feature checking First commit changes the following: - `AttributeGate ` from an enum with (four) tuple fields to (five) named fields - adds a `notes` fields that is emitted as notes in the `PostExpansionVisitor` pass - removes the `this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date` note if the feature gate is `rustc_attrs`. - various phrasing changes and touchups - and finally, the reason why I went down this path to begin with: tell people they can use the diagnostic namespace when they hit the rustc_on_unimplemented feature gate 🙈 Second commit removes unused machinery for deprecated attributes
2025-06-12intrinsics: rename min_align_of to align_ofRalf Jung-29/+24
2025-06-12Remove lower_arg_ty as all callers were passing `None`Oli Scherer-12/+2
2025-06-12Auto merge of #142127 - compiler-errors:nested-goals-certainty, r=lcnrbors-44/+65
Apply nested goals certainty to `InspectGoals` for normalizes-to ...so that normalizes-to goals don't have `Certainty::Yes` even if they have nested goals which don't hold. r? lcnr
2025-06-12Tracking the old name of renamed unstable library attributexizheyin-10/+35
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-12Introduce `-Zmacro-stats`.Nicholas Nethercote-52/+427
It collects data about macro expansions and prints them in a table after expansion finishes. It's very useful for detecting macro bloat, especially for proc macros. Details: - It measures code snippets by pretty-printing them and then measuring lines and bytes. This required a bunch of additional pretty-printing plumbing, in `rustc_ast_pretty` and `rustc_expand`. - The measurement is done in `MacroExpander::expand_invoc`. - The measurements are stored in `ExtCtxt::macro_stats`.
2025-06-12early linting: avoid redundant calls to `check_id`Deadbeef-15/+4
2025-06-12detect when variants have the same name as an associated functionJana Dönszelmann-1/+44
2025-06-12Add documentation for init_logger_with_additional_layerStypox-4/+14
2025-06-12Don't hardcode the intrinsic return types twice in the compilerOli Scherer-7/+7
2025-06-12avoid `&mut P<T>` in `visit_expr` etc methodsDeadbeef-36/+54
2025-06-12remove 'static in some placesJana Dönszelmann-13/+13
2025-06-12Make `missing_fragment_specifier` an unconditional errorTrevor Gross-76/+12
This was attempted in [1] then reverted in [2] because of fallout. Recently, this was made an edition-dependent error in [3]. Make missing fragment specifiers an unconditional error again. [1]: https://github.com/rust-lang/rust/pull/75516 [2]: https://github.com/rust-lang/rust/pull/80210 [3]: https://github.com/rust-lang/rust/pull/128006
2025-06-12add error message for unused duplicateJana Dönszelmann-4/+2
2025-06-12introduce new lint infraJana Dönszelmann-227/+662
lint on duplicates during attribute parsing To do this we stuff them in the diagnostic context to be emitted after hir is constructed
2025-06-12Start using new diagnostic logic on all existing `single` parsersJonathan Dönszelmann-43/+14
2025-06-12introduce duplicate attribute diagnostic logicJana Dönszelmann-17/+112
2025-06-12Report the `unpredictable_function_pointer_comparisons` lint in macroUrgau-1/+2
2025-06-12Overhaul the `thousands` module.Nicholas Nethercote-27/+86
It currently only inserts separators into `usize`s, because that's all that has been needed so far. `-Zmacro-stats` will need `isize` and `f64` handling, so this commit adds that.
2025-06-12Add some useful `Path`/`PathSegment` equality operations.Nicholas Nethercote-2/+19
They will be used in a subsequent commit.
2025-06-12Rollup merge of #142352 - workingjubilee:c-int-width-is-an-integer, ↵Matthias Krüger-26/+24
r=wesleywiser compiler: Make `c_int_width` an integer Because it is. That's all I got.
2025-06-12Rollup merge of #142318 - Urgau:cleanup-rust-src-remap, r=jieyouxuMatthias Krüger-28/+1
Cleanup `rust-src` remapping and real dir When remapping, `bootstrap` sets `CFG_VIRTUAL_RUST_SOURCE_BASE_DIR` to indicate what the base build dir (`/` of this repo) was remapped to, ie. `/rustc/...`. It is therefore impossible when stripping `/rustc/...` from a remapped path to be inside the our `library/` directory, nevertheless we have code that assumed it was possible and helpfully tried to correct it. I don't why this was done, but it's not necessary. ~~The normalization in compiletest of `$SRC_DIR_REAL` was also slightly wrong, it ate the `library` part for no reason.~~ EDIT: there is a reason, it affects too much tests otherwise r? `@jieyouxu`
2025-06-12Rollup merge of #142261 - folkertdev:unstable-attr-correct-edition, ↵Matthias Krüger-1/+6
r=compiler-errors use correct edition when warning for unsafe attributes fixes https://github.com/rust-lang/rust/issues/142182 If an attribute is re-emitted by a macro, the incorrect edition was used to emit warnings for unsafe attributes. This logic was introduced in https://github.com/rust-lang/rust/pull/139718 cc `@compiler-errors` `@ehuss`
2025-06-12Rollup merge of #142157 - Enselic:trivial-anon-const-use-cases, ↵Matthias Krüger-1/+1
r=compiler-errors rustc_resolve: Improve `resolve_const_param_in_non_trivial_anon_const` wording In some contexts, const expressions are OK. Add a `here` to the error message to clarify this. Closes rust-lang/rust#79429 which has 15 x 👍
2025-06-12Rollup merge of #142040 - jswrenn:transmute-ty-region-generic, r=compiler-errorsMatthias Krüger-348/+346
transmutability: shift abstraction boundary Previously, `rustc_transmute`'s layout representations were genericized over `R`, a reference. Now, it's instead genericized over representations of type and region. This allows us to move reference transmutability logic from `rustc_trait_selection` to `rustc_transmutability` (and thus unit test it independently of the compiler), and — in a follow-up PR — will make it possible to support analyzing function pointer transmutability with minimal surgery. r? `@compiler-errors`
2025-06-12Rollup merge of #141307 - b-naber:closure-body, r=celinvalMatthias Krüger-0/+8
Add method to retrieve body of closure in stable-mir fixes https://github.com/rust-lang/project-stable-mir/issues/85 r? `@celinval`
2025-06-11Another round of tidy / warning fixesCelina G. Val-104/+119
2025-06-12Apply ABI attributes on return types in `rustc_codegen_cranelift`beetrees-24/+40
2025-06-11Do not clone Arc when hashing span.Camille GILLOT-10/+10
2025-06-11Rollup merge of #142369 - jdonszelmann:attr-docs, r=fmeaseMatthias Krüger-12/+23
Improve some attribute docs and rename groups r? `@nnethercote` Some naming here got changed at some point, and this feels more consistent. The docs changes were a direct response to `@mejrs` trying to implement a new parsers and running into this.
2025-06-11Rollup merge of #142362 - Veykril:push-rzmrsswqourz, r=oli-obkMatthias Krüger-13/+19
Add expectation for `{` when parsing lone coroutine qualifiers Fixes https://github.com/rust-lang/rust/issues/80931
2025-06-11Rollup merge of #142356 - Stypox:fix-enter_trace_span, r=RalfJungMatthias Krüger-2/+2
Fix enter_trace_span!() using wrong $crate paths This is a followup to rust-lang/rust#140972, where I made a silly mistake and forgot to update `$crate::interpret::tracing_utils::...` to `$crate::interpret::util::...` inside the macro after moving the referenced code from `tracing_utils.rs` to `util.rs`. Sorry about this. r? `@RalfJung`
2025-06-11Rollup merge of #142305 - ↵Matthias Krüger-2/+0
GuillaumeGomez:remove-visit_id-EarlyContextAndPass, r=oli-obk Remove unneeded `check_id` calls as they are already called in `visit_id` in `EarlyContextAndPass` type Follow-up from [this message](https://github.com/rust-lang/rust/pull/142240/files#r2137474724). Since `check_id` is already called in `visit_id` which is supposed to be called for each item with an ID, we don't need to manually call `check_id`. r? `@oli-obk`
2025-06-11Use `rustc_thread_pool` instead of `rustc-rayon-core`Celina G. Val-66/+60
2025-06-12Simplify implementation of Rust intrinsics by using type parameters in the cachesayantn-829/+479
2025-06-11Fix format and tidy for code moved from rayonCelina G. Val-328/+190
2025-06-11Auto merge of #142358 - matthiaskrgr:rollup-fxe6m7k, r=matthiaskrgrbors-111/+109
Rollup of 9 pull requests Successful merges: - rust-lang/rust#141967 (Configure bootstrap backport nominations through triagebot) - rust-lang/rust#142042 (Make E0621 missing lifetime suggestion verbose) - rust-lang/rust#142272 (tests: Change ABIs in tests to more future-resilient ones) - rust-lang/rust#142282 (Only run `citool` tests on the `auto` branch) - rust-lang/rust#142297 (Implement `//@ needs-target-std` compiletest directive) - rust-lang/rust#142298 (Make loongarch-none target maintainers more easily pingable) - rust-lang/rust#142306 (Dont unwrap and re-wrap typing envs) - rust-lang/rust#142324 (Remove unneeded `FunctionCx` from some codegen methods) - rust-lang/rust#142328 (feat: Add `bit_width` for unsigned integer types) Failed merges: - rust-lang/rust#141639 (Expose discriminant values in stable_mir) r? `@ghost` `@rustbot` modify labels: rollup