Commit graph

52760 commits

Author SHA1 Message Date
dianqk
3b1756fbf5
Run SimplifyComparisonIntegral with opt-level 2 2026-01-12 18:16:39 +08:00
dianqk
37f83fb11d
Use Copy in the SwitchInt terminator
Move can be used only when both the compared operand and the operand on switch are move operands.
This commit directly changes to Copy, because I don't know if Move has beneficial.
2026-01-12 18:16:39 +08:00
dianqk
ac80ccec5f
Only use SSA locals in SimplifyComparisonIntegral 2026-01-12 18:16:34 +08:00
Jana Dönszelmann
6d0f23adad
rename extern item to foreign item 2026-01-12 08:07:23 +01:00
Jana Dönszelmann
322bbdfaaf
rename eii-extern-target 2026-01-12 08:07:23 +01:00
rust-bors[bot]
840245e91b
Auto merge of #150981 - matthiaskrgr:rollup-px5fFnj, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#147938 (Add const cloning of slices and tests)
 - rust-lang/rust#149718 (Add freeze file times on Windows)
 - rust-lang/rust#150438 (Remove mentions of debootstrap and chroots from the m68k-unknown-none-elf platform support doc)
 - rust-lang/rust#150790 (feat: invisible character help string)
 - rust-lang/rust#150906 (Simplify `#[eii]` macro using methods on ecx)
 - rust-lang/rust#150938 (Port `#[collapse_debuginfo]` to the new attribute parsing system)
 - rust-lang/rust#150953 (std: sys: fs: uefi: Implement copy)
 - rust-lang/rust#150964 (Completely list all unparsed attributes)
 - rust-lang/rust#150975 (ui: add test for normalizing const projections with assoc const equality)

Failed merges:

 - rust-lang/rust#150972 (Rename EII attributes slightly (being consistent in naming things foreign items, not extern items))

r? @ghost
2026-01-12 02:14:38 +00:00
The 8472
e6071522db mark rust_dealloc as captures(address)
Co-authored-by: Ralf Jung <post@ralfj.de>
2026-01-12 02:54:22 +01:00
Asuna
e555d2c44b Use updated indexes to build reverse map for delegation generics 2026-01-12 00:11:55 +01:00
Matthias Krüger
565c663413
Rollup merge of #150964 - list_all_attrs, r=jdonszelmann
Completely list all unparsed attributes

Also introduce a `SPECIAL_ATTRIBUTES` list, since `cfg` was incorrectly being detected as an unparsed attribute in `check_attr`.

I will also update https://github.com/rust-lang/rust/issues/131229#issuecomment-2971351163

r? @jdonszelmann
2026-01-12 00:02:55 +01:00
Matthias Krüger
d6621f07ae
Rollup merge of #150938 - collapse_debuginfo, r=jdonszelmann
Port `#[collapse_debuginfo]` to the new attribute parsing system

Tracking issue: https://github.com/rust-lang/rust/issues/131229

Felt like doing one again, has been a while :3

r? @jdonszelmann
2026-01-12 00:02:54 +01:00
Matthias Krüger
a44a2d3232
Rollup merge of #150906 - eii-ecx-mehods, r=Kivooeo
Simplify `#[eii]` macro using methods on ecx
2026-01-12 00:02:54 +01:00
Matthias Krüger
66d18446fc
Rollup merge of #150790 - lexer/help-invisible-character, r=Kivooeo,tgross35
feat: invisible character help string

I was playing around with zero width spaces in different programming languages and thought that this error message could be more helpful. Hopefully it's a good first contribution! :)
2026-01-12 00:02:53 +01:00
rust-bors[bot]
44a5b55557
Auto merge of #150748 - nnethercote:canonicalizer-cleanups, r=lcnr
Canonicalizer cleanups

Some cleanups in and around the canonicalizers, found while I was looking closely at this code.

r? @lcnr
2026-01-11 22:58:38 +00:00
Nicholas Nethercote
46d8c2beeb Clean up src/dst transmute mess.
- Remove the vacuous `Types`, which provides extremely little value.
- Make sure `src` comes before `dst` in all transmute-related functions.
  (Currently it's a mix: sometimes `src` is first, sometimes it is
  second`.)
2026-01-12 09:22:58 +11:00
Nicholas Nethercote
5e510929c6 Remove useless call to erase_and_anonymize_regions.
The only thing we do with the result is consult the `.def_id` field,
which is unaffected by `erase_and_anonymize_regions`.
2026-01-12 09:22:58 +11:00
Nicholas Nethercote
02e0879c5d Remove redundant call to erase_and_anonymize_regions.
The exact same call appears earlier in this function.
2026-01-12 09:22:58 +11:00
Nicholas Nethercote
71d1b2ca7f Whitespace fixes. 2026-01-12 08:51:49 +11:00
Nicholas Nethercote
2ae298711f Replace two BottomUpFolders with fold_regions.
Because these folders only change regions.

Note: `BottomUpFolder` folds all regions, while `fold_regions` skips
some bound regions. But that's ok because these two folders only modify
`ReVar`s.
2026-01-12 08:51:49 +11:00
rust-bors[bot]
b68e16cfc0
Auto merge of #150741 - petrochenkov:modsplitfast, r=nnethercote
resolve: Use `Macros20NormalizedIdent` in more interfaces

It allows to avoid expensive double normalization in some cases.
This is an attempt to fix the perf regressions from https://github.com/rust-lang/rust/pull/149681.
2026-01-11 19:23:22 +00:00
Usman Akinyemi
76ad528d32 rustc_parse_format: improve diagnostics for unsupported python numeric grouping
Detect Python-style numeric grouping syntax in format strings (e.g. `{x:,}`)
and emit a clear diagnostic explaining that it is not supported in Rust.
This helps users coming from Python understand the error without exposing
the full set of valid Rust format specifiers.

Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
2026-01-11 23:42:38 +05:30
Guillaume Gomez
ef1e4e65b7 Move checks from check_doc_attrs directly into rustc_attr_parsing 2026-01-11 18:36:03 +01:00
rust-bors[bot]
1279939b38
Auto merge of #150957 - matthiaskrgr:rollup-Cf6MsNU, r=matthiaskrgr
Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#148941 (stabilize `Peekable::next_if_map` (`#![feature(peekable_next_if_map)]`))
 - rust-lang/rust#150368 (adding Ordering enum to minicore.rs, importing minicore in "tests/assembly-llvm/rust-abi-arg-attr.rs" test file)
 - rust-lang/rust#150668 (Unix implementation for stdio set/take/replace)
 - rust-lang/rust#150743 (Reword the collect() docs)
 - rust-lang/rust#150776 (Fix the connect_error test on FreeBSD 15+)
 - rust-lang/rust#150781 (Use `rand` crate more idiomatically)
 - rust-lang/rust#150812 (Bump `diesel` to the most recent commit in `cargotest`)
 - rust-lang/rust#150862 (std: sys: fs: uefi: Implement File::flush)
 - rust-lang/rust#150873 (Reenable GCC CI download)
 - rust-lang/rust#150908 (llvm: Update `reliable_f16` configuration for LLVM22)
 - rust-lang/rust#150918 (std: sys: fs: uefi: Implement File::seek)
 - rust-lang/rust#150922 (Subscribe myself to attr parsing)
 - rust-lang/rust#150930 (Remove special case for `AllowedTargets::CrateLevel`)
 - rust-lang/rust#150942 (Port `#[rustc_has_incoherent_inherent_impls]` to attribute parser)

Failed merges:

 - rust-lang/rust#150943 (Port `#[must_not_suspend]` to attribute parser)

r? @ghost
2026-01-11 12:16:33 +00:00
Jana Dönszelmann
d993bd1bb1
improve eii macro by using ecx methods 2026-01-11 13:03:05 +01:00
Jonathan Brouwer
eac7bda659
Completely list all unparsed attributes 2026-01-11 12:56:00 +01:00
Jonathan Brouwer
6153fa0f88
Fix that cfg attribute was incorrectly not a parsed attribute 2026-01-11 12:12:53 +01:00
Jonathan Brouwer
b5dd72d292
Port #[collapse_debuginfo] to the new attribute parsing system 2026-01-11 10:54:45 +01:00
Matthias Krüger
83924065f7
Rollup merge of #150942 - port_more_attrs, r=jdonszelmann
Port `#[rustc_has_incoherent_inherent_impls]` to attribute parser

Tracking issue: rust-lang/rust#131229
no tests changed here at all, so maybe we should add some but would like to know what kind of tests would be good to add

r? @JonathanBrouwer
2026-01-11 09:56:52 +01:00
Matthias Krüger
c6cf1c3ab8
Rollup merge of #150930 - crate_level, r=jdonszelmann
Remove special case for `AllowedTargets::CrateLevel`

r? @jdonszelmann
2026-01-11 09:56:51 +01:00
Matthias Krüger
cbdfa9167f
Rollup merge of #150908 - llvm-f16-cfg, r=nikic
llvm: Update `reliable_f16` configuration for LLVM22

Since yesterday, the LLVM `main` branch should have working `f16` on all platforms that Rust supports; this will be LLVM version 22, so update how `cfg(target_has_reliable_f16)` is set to reflect this.

Within the rust-lang organization, this currently has no effect. The goal is to start catching problems as early as possible in external CI that runs top-of-tree rust against top-of-tree LLVM, and once testing for the rust-lang bump to LLVM 22 starts. Hopefully this will mean that we can fix any problems that show up before the bump actually happens, meaning `f16` will be about ready for stabilization at that point (with some considerations for the GCC patch at [1] propagating).

References:

* 919021b0df
* 054ee2f870
* db26ce5c55
* 549d7c4f35
* 4903c6260c

[1]: 8b6a18ecaf
2026-01-11 09:56:50 +01:00
rust-bors[bot]
08f833aa17
Auto merge of #150540 - JonathanBrouwer:incremental_test, r=cjgillot
Also hash spans inside the same file as relative (V2)

Hashes spans relatively to their parent, even if they are not contained inside their parent.

Fixes https://github.com/rust-lang/rust/issues/150400

Closes https://github.com/rust-lang/rust/pull/143882, as this is a successor PR
This PR is very closely based on that PR with a few minor changes, so to give proper credit I made @cjgillot coauthor of the commit.
2026-01-11 08:54:50 +00:00
Stuart Cook
1987b15908
Rollup merge of #150913 - eii-macro-attrs, r=jdonszelmann
compiler: Forward attributes to eii-expanded macros

Since https://github.com/rust-lang/rust/pull/150592 is quite complicated to reason about I figured it would be good to split it up in smaller pieces that are easier to digest. Here is the attribute fix in isolation.

## The Problem

With this eii in **library/std/src/io/mod.rs**:
```rs
/// Foo
#[eii(on_broken_pipe)]
#[unstable(feature = "on_broken_pipe", issue = "150588")]
pub fn on_broken_pipe() -> OnBrokenPipe {
    OnBrokenPipe::BackwardsCompatible
}
```

you currently get this compilation error:

```
error: attribute macro has missing stability attribute
    --> library/std/src/io/mod.rs:2269:1
     |
2269 | #[eii(on_broken_pipe)]
     | ^^^^^^^^^^^^^^^^^^^^--
     | |
     | in this attribute macro expansion
     |
    ::: library/core/src/macros/mod.rs:1899:5
     |
1899 |     pub macro eii($item:item) {
     |     ------------- in this expansion of `#[eii]`
```

because with ` MAGIC_EXTRA_RUSTFLAGS=-Zunpretty=expanded ./x build library/std` we can see that a pub item in the expanded code is indeed missing that attribute:

```rs
const _: () =
    {
        #[on_broken_pipe]
        fn on_broken_pipe() -> OnBrokenPipe {
            OnBrokenPipe::BackwardsCompatible
        }
    };
unsafe extern "Rust" {
    /// Foo
    #[unstable(feature = "on_broken_pipe", issue = "150588")]
    #[rustc_eii_extern_item]
    pub safe fn on_broken_pipe()
    -> OnBrokenPipe;
}
#[rustc_builtin_macro(eii_shared_macro)]
#[eii_extern_target(on_broken_pipe)]
pub macro on_broken_pipe { () => {} }
```

## The Solution

With the fix, that error goes away because we get this expanded code instead:

```rs
const _: () =
    {
        #[on_broken_pipe]
        fn on_broken_pipe() -> OnBrokenPipe {
            OnBrokenPipe::BackwardsCompatible
        }
    };
unsafe extern "Rust" {
    /// Foo
    #[unstable(feature = "on_broken_pipe", issue = "150588")]
    #[rustc_eii_extern_item]
    pub safe fn on_broken_pipe()
    -> OnBrokenPipe;
}
/// Foo
#[unstable(feature = "on_broken_pipe", issue = "150588")]
#[rustc_builtin_macro(eii_shared_macro)]
#[eii_extern_target(on_broken_pipe)]
pub macro on_broken_pipe { () => {} }
```

Note that we also need to forward the docs, otherwise get get (fatal) warnings like these:

```
warning: missing documentation for an attribute macro
    --> library/std/src/io/mod.rs:2269:1
```

r? @jdonszelmann

Tracking issues:
- https://github.com/rust-lang/rust/issues/125418
- https://github.com/rust-lang/rust/issues/150588

### What about a test?

https://github.com/rust-lang/rust/pull/150591 will prevent regressions once it lands since it does not build without this fix. I think it is overkill to add a temporary eii to std before that.
2026-01-11 14:28:06 +11:00
Stuart Cook
c2448d7311
Rollup merge of #150911 - master, r=Kivooeo
Add missing documentation for globs feature

Fixes FIXME by documenting that globs enables wildcard imports (use module::*;).
2026-01-11 14:28:05 +11:00
Stuart Cook
5b685d7b03
Rollup merge of #150878 - bpf_staticlib_error, r=Urgau
Emit an error for linking staticlibs on BPF

Rather than panicking. Also a drive-by diagnostic type visibility reduction.

Fixes https://github.com/rust-lang/rust/issues/149432
2026-01-11 14:27:58 +11:00
Stuart Cook
e25d7a898a
Rollup merge of #150799 - mcga, r=BoxyUwU
Fix ICE: can't type-check body of DefId  for issue #148729

This commit fixes https://github.com/rust-lang/rust/issues/148729 for min_const_generic_args https://github.com/rust-lang/rust/issues/132980.

It's pretty small PR. The first commit makes sure that the `type_const`s are made into normal consts in const expressions.

The next one just handles the case https://github.com/rust-lang/rust/issues/148729 of where the type of the const was omitted at which point it was trying to treat a `type_const` again as a regular const. That obviously will fail since a type_const does not have a body.

@rustbot label +F-associated_const_equality +F-min_generic_const_args +I-ICE
2026-01-11 14:27:56 +11:00
Stuart Cook
8a5c66efb9
Rollup merge of #150788 - thir-pat, r=Nadrieril
THIR patterns: Replace `AscribeUserType` and `ExpandedConstant` wrappers with per-node data

This PR removes the `AscribeUserType` and `ExpandedConstant` variants from `thir::PatKind`, and replaces them with an `Option<Box<PatExtra>>` field attached to every `thir::Pat`.

### Why remove these variants?

Unlike other THIR pattern kinds, these variants are mere “wrappers” that exist to attach some additional information to an underlying pattern node.

There are several places where code that consumes THIR patterns needs to carefully “unpeel” any wrapper nodes, in order to match on the underlying pattern. This is clunky, and easy to forget to do, especially since it's not always obvious where the wrapper nodes can and can't appear.

Attaching the data to an optional per-node field makes it easier for consuming code to simply ignore the extra data when it is not relevant.

(One downside is that it is now easier to accidentally ignore the extra data when it *is* relevant, but I think that's generally a favourable tradeoff.)

### Impact

After this change, THIR pattern trees should be “logically identical” to the previous THIR pattern trees, in the sense that information that was carried by wrapper nodes should now be directly attached to the non-wrapper nodes that were being wrapped. Types and spans associated with THIR pattern nodes should (hopefully!) still be accurate.

There should be no change to the output of THIR-based checks or MIR building.
2026-01-11 14:27:56 +11:00
Stuart Cook
30585ebbd3
Rollup merge of #150494 - extern_linkage_dso_local, r=bjorn3
Fix dso_local for external statics with linkage

Tracking issue of the feature: rust-lang/rust#127488

DSO local attributes are not correctly applied to extern statics with `#[linkage = "foo"]` as we generate an internal global for such statics, and the we evaluate (and apply) DSO attributes on the internal one instead.

Fix this by applying DSO local attributes on the actually extern ones, too.
2026-01-11 14:27:55 +11:00
mu001999
8ca1c9eb8f Rename tests for const tuple properly 2026-01-11 11:26:10 +08:00
mu001999
9e0a27cfa9 Emit error instead of delayed bug when meeting mismatch type for const tuple 2026-01-11 11:26:10 +08:00
Edvin Bryntesson
76fcac2371
Port #[rustc_has_incoherent_inherent_impls] to attribute parser 2026-01-10 23:58:03 +01:00
rust-bors[bot]
ad04f76d84
Auto merge of #150912 - matthiaskrgr:rollup-SHXgjYS, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#150269 (Remove inactive nvptx maintainer)
 - rust-lang/rust#150713 (mgca: Type-check fields of struct expr const args)
 - rust-lang/rust#150765 (rustc_parse_format: improve error for missing `:` before `?` in format args)
 - rust-lang/rust#150847 (Fix broken documentation links to SipHash)
 - rust-lang/rust#150867 (rustdoc_json: Remove one call to `std::mem::take` in `after_krate`)
 - rust-lang/rust#150872 (Fix some loop block coercion diagnostics)
 - rust-lang/rust#150874 (Ignore `rustc-src-gpl` in fast try builds)
 - rust-lang/rust#150875 (Refactor artifact keep mode in bootstrap)
 - rust-lang/rust#150876 (Mention that `rustc_codegen_gcc` is a subtree in `rustc-dev-guide`)
 - rust-lang/rust#150882 (Supress unused_parens lint for guard patterns)
 - rust-lang/rust#150884 (Update bors email in CI postprocessing step)

Failed merges:

 - rust-lang/rust#150869 (Emit error instead of delayed bug when meeting mismatch type for const tuple)

r? @ghost
2026-01-10 22:52:39 +00:00
rust-bors[bot]
f57eac1bf9
Auto merge of #146923 - oli-obk:comptime-reflect, r=BoxyUwU
Reflection MVP

I am opening this PR for discussion about the general design we should start out with, as there are various options (that are not too hard to transition between each other, so we should totally just pick one and go with it and reiterate later)

r? @scottmcm and @joshtriplett

project goal issue: https://github.com/rust-lang/rust-project-goals/issues/406
tracking issue: https://github.com/rust-lang/rust/issues/146922

The design currently implemented by this PR is

* `TypeId::info` (method, usually used as `id.info()` returns a `Type` struct
* the `Type` struct has fields that contain information about the type
* the most notable field is `kind`, which is a non-exhaustive enum over all possible type kinds and their specific information. So it has a `Tuple(Tuple)` variant, where the only field is a `Tuple` struct type that contains more information (The list of type ids that make up the tuple).
* To get nested type information (like the type of fields) you need to call `TypeId::info` again.
* There is only one language intrinsic to go from `TypeId` to `Type`, and it does all the work

An alternative design could be

* Lots of small methods (each backed by an intrinsic) on `TypeId` that return all the individual information pieces (size, align, number of fields, number of variants, ...)
* This is how C++ does it (see https://lemire.me/blog/2025/06/22/c26-will-include-compile-time-reflection-why-should-you-care/ and https://isocpp.org/files/papers/P2996R13.html#member-queries)
* Advantage: you only get the information you ask for, so it's probably cheaper if you get just one piece of information for lots of types (e.g. reimplementing size_of in terms of `TypeId::info` is likely expensive and wasteful)
* Disadvantage: lots of method calling (and `Option` return types, or "general" methods like `num_fields` returning 0 for primitives) instead of matching and field accesses
* a crates.io crate could implement `TypeId::info` in terms of this design

The backing implementation is modular enough that switching from one to the other is probably not an issue, and the alternative design could be easier for the CTFE engine's implementation, just not as nice to use for end users (without crates wrapping the logic)

One wart of this design that I'm fixing in separate branches is that `TypeId::info` will panic if used at runtime, while it should be uncallable
2026-01-10 15:00:14 +00:00
Fabio Almeida
2b597f599e
feat: invisible character help string 2026-01-10 14:31:37 +00:00
Jonathan Brouwer
da0dda1503
Remove special case for AllowedTargets::CrateLevel 2026-01-10 14:27:44 +01:00
Zalathar
539e855008 Use a hook to decouple rustc_mir_transform from rustc_mir_build 2026-01-10 22:14:35 +11:00
Martin Nordholts
a0df7b2ad5 compiler: Forward attributes to eii-expanded macros
Otherwise you get errors like these if you have an Externally
Implementable Item defined in std:

    error: attribute macro has missing stability attribute
        --> library/std/src/io/mod.rs:2269:1
         |
    2269 | #[eii(on_broken_pipe)]
         | ^^^^^^^^^^^^^^^^^^^^--
         | |
         | in this attribute macro expansion
         |
        ::: library/core/src/macros/mod.rs:1899:5
         |
    1899 |     pub macro eii($item:item) {
         |     ------------- in this expansion of `#[eii]`

Or (fatal) warnings like these:

    warning: missing documentation for an attribute macro
        --> library/std/src/io/mod.rs:2269:1
2026-01-10 10:04:40 +01:00
Matthias Krüger
e7b08033a2
Rollup merge of #150882 - issue-149594, r=JonathanBrouwer
Supress unused_parens lint for guard patterns

Fixes rust-lang/rust#149594
2026-01-10 08:34:08 +01:00
Matthias Krüger
86806ab019
Rollup merge of #150872 - issue-150850, r=dianne
Fix some loop block coercion diagnostics

Fixes rust-lang/rust#150850
2026-01-10 08:33:58 +01:00
Matthias Krüger
a8d66d4670
Rollup merge of #150765 - ua/missing-colon, r=estebank
rustc_parse_format: improve error for missing `:` before `?` in format args

Detect the `{ident?}` pattern where `?` is immediately followed by `}` and emit a clearer diagnostic explaining that `:` is required for Debug formatting. This avoids falling back to a generic “invalid format string” error and adds a targeted UI test for the case.
2026-01-10 08:33:57 +01:00
Matthias Krüger
727688a8e4
Rollup merge of #150713 - mgca-typeck-struct-fields, r=BoxyUwU
mgca: Type-check fields of struct expr const args

Fixes rust-lang/rust#150623.
Fixes rust-lang/rust#150712. Fixes rust-lang/rust#150714. Fixes rust-lang/rust#150734.

r? @BoxyUwU
2026-01-10 08:33:56 +01:00
oncecelll
14c6e602f4 Add missing documentation for globs feature
Signed-off-by: oncecelll <oncecell@outlook.com>
2026-01-10 13:25:31 +08:00