Commit Graph

47309 Commits

Author SHA1 Message Date
Michael Goulet
fe92efaf31 Make connection between Placeholder and Bound a bit more clear in the type abstraction 2025-06-13 17:54:45 +00:00
Michael Goulet
86497e6376 Don't use BTreeMap for mapped_consts 2025-06-13 17:54:45 +00:00
bors
c359117819 Auto merge of #142442 - matthiaskrgr:rollup-6yodjfx, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#134847 (Implement asymmetrical precedence for closures and jumps)
 - rust-lang/rust#141491 (Delegate `<CStr as Debug>` to `ByteStr`)
 - rust-lang/rust#141770 (Merge `Cfg::render_long_html` and `Cfg::render_long_plain` methods common code)
 - rust-lang/rust#142069 (Introduce `-Zmacro-stats`)
 - rust-lang/rust#142158 (Tracking the old name of renamed unstable library features)
 - rust-lang/rust#142221 ([AIX] strip underlying xcoff object)
 - rust-lang/rust#142340 (miri: we can use apfloat's mul_add now)
 - rust-lang/rust#142379 (Add bootstrap option to compile a tool with features)
 - rust-lang/rust#142410 (intrinsics: rename min_align_of to align_of)
 - rust-lang/rust#142413 (rustc-dev-guide subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-13 11:42:31 +00:00
bors
015c7770ec Auto merge of #142432 - matthiaskrgr:rollup-ziuls9y, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#138016 (Added `Clone` implementation for `ChunkBy`)
 - rust-lang/rust#141162 (refactor  `AttributeGate` and `rustc_attr!` to emit notes during feature checking)
 - rust-lang/rust#141474 (Add `ParseMode::Diagnostic` and fix multiline spans in diagnostic attribute lints)
 - rust-lang/rust#141947 (Specify that "option-like" enums must be `#[repr(Rust)]` to be ABI-compatible with their non-1ZST field.)
 - rust-lang/rust#142252 (Improve clarity of `core::sync::atomic` docs about "Considerations" in regards to CAS operations)
 - rust-lang/rust#142337 (miri: add flag to suppress float non-determinism)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-13 05:09:09 +00:00
Matthias Krüger
86e9995e7a
Rollup merge of #142410 - RalfJung:align_of, r=WaffleLapkin,workingjubilee
intrinsics: rename min_align_of to align_of

Now that `pref_align_of` is gone (https://github.com/rust-lang/rust/pull/141803), we can give the intrinsic backing `align_of` its proper name.

r? `@workingjubilee` or `@bjorn3`
2025-06-13 05:16:59 +02:00
Matthias Krüger
b24473cfd1
Rollup merge of #142221 - mustartt:aix-fix-strip-order, r=davidtwco
[AIX] strip underlying xcoff object

When stripping, we need to strip the archive member first before archiving. Otherwise, the shared library remain untouched, only the archive symbol table will be modified.
2025-06-13 05:16:57 +02:00
Matthias Krüger
fac011eb2d
Rollup merge of #142158 - xizheyin:141617, r=jdonszelmann
Tracking the old name of renamed unstable library features

This PR resolves the first problem of rust-lang/rust#141617 : tracking renamed unstable features. The first commit is to add a ui test, and the second one tracks the changes. I will comment on the code for clarification.

r? `@jdonszelmann`
There have been a lot of PR's reviewed by you lately, thanks for your time!

cc `@jyn514`
2025-06-13 05:16:56 +02:00
Matthias Krüger
9639a7c522
Rollup merge of #142069 - nnethercote:Zmacro-stats, r=petrochenkov
Introduce `-Zmacro-stats`

Introduce `-Zmacro-stats`.

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.

r? `@petrochenkov`
2025-06-13 05:16:56 +02:00
Matthias Krüger
b12bb2530b
Rollup merge of #134847 - dtolnay:asymmetrical, r=fmease
Implement asymmetrical precedence for closures and jumps

I have been through a series of asymmetrical precedence designs in Syn, and finally have one that I like and is worth backporting into rustc. It is based on just 2 bits of state: `next_operator_can_begin_expr` and `next_operator_can_continue_expr`.

Asymmetrical precedence is the thing that enables `(return 1) + 1` to require parentheses while `1 + return 1` does not, despite `+` always having stronger precedence than `return` [according to the Rust Reference](https://doc.rust-lang.org/1.83.0/reference/expressions.html#expression-precedence). This is facilitated by `next_operator_can_continue_expr`.

Relatedly, it is the thing that enables `(return) - 1` to require parentheses while `return + 1` does not, despite `+` and `-` having exactly the same precedence. This is facilitated by `next_operator_can_begin_expr`.

**Example:**

```rust
macro_rules! repro {
    ($e:expr) => {
        $e - $e;
        $e + $e;
    };
}

fn main() {
    repro!{return}
    repro!{return 1}
}
```

`-Zunpretty=expanded` **Before:**

```console
fn main() {
    (return) - (return);
    (return) + (return);
    (return 1) - (return 1);
    (return 1) + (return 1);
}
```

**After:**

```console
fn main() {
    (return) - return;
    return + return;
    (return 1) - return 1;
    (return 1) + return 1;
}
```
2025-06-13 05:16:54 +02:00
bors
ed44c0e3b3 Auto merge of #142353 - workingjubilee:warn-less-about-cdecl-and-other-abis, r=ChrisDenton,RalfJung
compiler: Ease off the accelerator on `unsupported_calling_conventions`

This is to give us more time to discuss rust-lang/rust#142330 without the ecosystem having an anxiety attack. I have withdrawn `unsupported_calling_conventions` from report-in-deps

I believe we should consider this a simple suspension of the decision in rust-lang/rust#141435 to start this process, rather than a reversal. That is, we may continue with linting again. But I believe we are about to get a... reasonable amount of feedback just from currently available information and should allow ourselves time to process it.
2025-06-13 02:06:04 +00:00
bors
bb3a3c530c Auto merge of #142438 - matthiaskrgr:rollup-u1jdnhz, r=matthiaskrgr
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-12 23:05:49 +00:00
Matthias Krüger
7309c103ba
Rollup merge of #142418 - oli-obk:lower_arg_ty, r=BoxyUwU,fmease
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-12 22:09:46 +02:00
Matthias Krüger
7cd6944458
Rollup merge of #142406 - jdonszelmann:dead-code-enum-variant, r=WaffleLapkin
Note when enum variants shadow an associated function

r? ``@WaffleLapkin``

Closes rust-lang/rust#142263
2025-06-12 22:09:44 +02:00
Matthias Krüger
c77191f46b
Rollup merge of #142034 - estebank:issue-141258, r=davidtwco
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-12 22:09:43 +02:00
Matthias Krüger
8b6d55e782
Rollup merge of #141934 - petrochenkov:privmacuse, r=compiler-errors
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-12 22:09:42 +02:00
Matthias Krüger
bfd8abd8f3
Rollup merge of #141069 - chenyukang:yukang-fix-137486-suggest-mut, r=davidtwco
Suggest mut when possbile for temporary value dropped while borrowed

Fixes #137486
2025-06-12 22:09:41 +02:00
Matthias Krüger
ae7615039f
Rollup merge of #134536 - Urgau:fn-ptr-option, r=compiler-errors,traviscross
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-12 22:09:41 +02:00
bors
573a015690 Auto merge of #138164 - jdonszelmann:attr-parsing-lint-infra, r=oli-obk
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-12 19:48:49 +00:00
Matthias Krüger
94e8a2448f
Rollup merge of #141474 - mejrs:diagnostic_mode, r=compiler-errors
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-12 20:03:36 +02:00
Matthias Krüger
25914399ab
Rollup merge of #141162 - mejrs:gated, r=fee1-dead
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-12 20:03:35 +02:00
Ralf Jung
62418f4c56 intrinsics: rename min_align_of to align_of 2025-06-12 17:50:25 +02:00
Oli Scherer
488ebeecbe Remove lower_arg_ty as all callers were passing None 2025-06-12 15:04:09 +00:00
bors
6c8138de8f Auto merge of #142127 - compiler-errors:nested-goals-certainty, r=lcnr
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-12 11:29:20 +00:00
xizheyin
b8066f94fd
Tracking the old name of renamed unstable library attribute
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-12 19:24:11 +08:00
Nicholas Nethercote
376cbc3787 Introduce -Zmacro-stats.
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-12 21:17:17 +10:00
Jana Dönszelmann
2e7e52e07c
detect when variants have the same name as an associated function 2025-06-12 12:26:27 +02:00
Jana Dönszelmann
e2afe04e2e
remove 'static in some places 2025-06-12 09:57:38 +02:00
Jana Dönszelmann
e6a5f281ec
add error message for unused duplicate 2025-06-12 09:56:47 +02:00
Jana Dönszelmann
6072207a11
introduce new lint infra
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-12 09:56:47 +02:00
Jonathan Dönszelmann
4e1b6d13a2 Start using new diagnostic logic on all existing single parsers 2025-06-12 09:42:45 +02:00
Jana Dönszelmann
28bf61b9b3
introduce duplicate attribute diagnostic logic 2025-06-12 09:42:45 +02:00
Urgau
fafc0f249f Report the unpredictable_function_pointer_comparisons lint in macro 2025-06-12 07:33:56 +02:00
Nicholas Nethercote
bdfe1b9fb0 Overhaul the thousands module.
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-12 15:26:06 +10:00
Nicholas Nethercote
fb73893e51 Add some useful Path/PathSegment equality operations.
They will be used in a subsequent commit.
2025-06-12 15:26:06 +10:00
Matthias Krüger
240776176b
Rollup merge of #142352 - workingjubilee:c-int-width-is-an-integer, r=wesleywiser
compiler: Make `c_int_width` an integer

Because it is.

That's all I got.
2025-06-12 03:14:54 +02:00
Matthias Krüger
78d83952e4
Rollup merge of #142318 - Urgau:cleanup-rust-src-remap, r=jieyouxu
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-12 03:14:53 +02:00
Matthias Krüger
75c186bf43
Rollup merge of #142261 - folkertdev:unstable-attr-correct-edition, 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-12 03:14:52 +02:00
Matthias Krüger
2d9513b98c
Rollup merge of #142157 - Enselic:trivial-anon-const-use-cases, 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-12 03:14:51 +02:00
Matthias Krüger
bdf7b74517
Rollup merge of #142040 - jswrenn:transmute-ty-region-generic, r=compiler-errors
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-12 03:14:49 +02:00
Matthias Krüger
9f6e81c202
Rollup merge of #141307 - b-naber:closure-body, r=celinval
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-12 03:14:49 +02:00
Matthias Krüger
f417620160
Rollup merge of #142369 - jdonszelmann:attr-docs, r=fmease
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-11 22:58:29 +02:00
Matthias Krüger
e78b619cad
Rollup merge of #142362 - Veykril:push-rzmrsswqourz, r=oli-obk
Add expectation for `{` when parsing lone coroutine qualifiers

Fixes https://github.com/rust-lang/rust/issues/80931
2025-06-11 22:58:28 +02:00
Matthias Krüger
e2846d6b75
Rollup merge of #142356 - Stypox:fix-enter_trace_span, r=RalfJung
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-11 22:58:28 +02:00
Matthias Krüger
b29c9a3588
Rollup merge of #142305 - 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-11 22:58:26 +02:00
bors
e703dff8fe Auto merge of #142358 - matthiaskrgr:rollup-fxe6m7k, r=matthiaskrgr
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
2025-06-11 17:51:57 +00:00
Jubilee Young
86493f75a5 compiler: Avoid reporting unsupported_calling_conventions in deps 2025-06-11 09:55:41 -07:00
Jana Dönszelmann
ce0438684d
consistently rename (old) attribute groups 2025-06-11 18:46:57 +02:00
Jana Dönszelmann
34241e5397
document attribute parsers better 2025-06-11 18:46:57 +02:00
Lukas Wirth
edc405d383 Add expectation for { when parsing lone coroutine qualifiers 2025-06-11 17:11:58 +02:00
Matthias Krüger
b1c668ca03
Rollup merge of #142324 - scottmcm:less-functioncx, r=workingjubilee
Remove unneeded `FunctionCx` from some codegen methods

No changes; just removing the `self` that wasn't needed.

r? workingjubilee
cc https://github.com/rust-lang/rust/pull/138759#issuecomment-2920860686
2025-06-11 13:48:13 +02:00