Commit graph

23682 commits

Author SHA1 Message Date
bors
139651428d Auto merge of #152452 - ShE3py:overruled-lint, r=BoxyUwU
feat: show what lint was overruled

We can't `#[allow]` a whole lint group if any of its members is forbidden, but the offending member is not currently shown if it was forbidden from the command line.

Before/after:
```diff
 $ rustc -F dead_code - <<< '#![allow(unused)]'
 error[E0453]: allow(unused) incompatible with previous forbid
  --> <anon>:1:10
   |
 1 | #![allow(unused)]
   |          ^^^^^^ overruled by previous forbid
   |
-  = note: `forbid` lint level was set on command line
+  = note: `forbid` lint level was set on command line (`-F dead_code`)
 
 error: aborting due to 1 previous error
```

@rustbot label +A-diagnostics +A-lints +D-terse
2026-02-15 20:05:05 +00:00
bors
873b4beb0c Auto merge of #152671 - JonathanBrouwer:rollup-4Ov19Nw, r=JonathanBrouwer
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#152566 (Remove code for ThinLTO from cg_gcc)
 - rust-lang/rust#152278 (Fix const normalization for generic const items with trait assoc consts)
 - rust-lang/rust#152604 (Relocate some tests)
 - rust-lang/rust#152625 (Provide all lint group names to Clippy)
2026-02-15 16:52:45 +00:00
Jonathan Brouwer
c5a12fbd0d
Rollup merge of #152604 - reddevilmidzy:refactor, r=Zalathar
Relocate some tests

`dynamically-sized-types` -> `dst`
`underscore-imports` -> `imports/underscore-imports`
`btreemap`, `hashmap` -> `collections/btreemap`, `collections/hashmap`
`higher-ranked-trait-bounds` -> `higher-ranked/trait-bounds`
`meta` -> `compiletest-self-test`, `bootstrap`

After the review, I'll squash.
2026-02-15 16:37:37 +01:00
Lieselotte
d12923346c
feat: show what lint was overruled 2026-02-15 15:40:13 +01:00
bors
2219766af6 Auto merge of #152605 - scottmcm:box-drop-alignment, r=Mark-Simulacrum
Pass alignments through the shim as `Alignment` (not `usize`)

We're using `Layout` on both sides, so might as well skip the transmutes back and forth to `usize`.

The mir-opt test shows that doing so allows simplifying the boxed-slice drop slightly, for example.
2026-02-15 13:38:45 +00:00
lapla
88f0ac34dc
Fix const normalization for generic const items with trait assoc consts 2026-02-15 22:05:27 +09:00
bors
ce0bf0b22b Auto merge of #152639 - jhpratt:rollup-sIUYGho, r=jhpratt
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#150424 (diagnostics: add note when param-env shadows global impl)
 - rust-lang/rust#152132 (implement `carryless_mul`)
 - rust-lang/rust#152508 (Improve write! and writeln! error when called without destination)
 - rust-lang/rust#152534 (Test(lib/win/net): Skip UDS tests when under Win7)
 - rust-lang/rust#152578 (ci: Lock cross toolchain version and update docs)
 - rust-lang/rust#152188 (Include `library/stdarch` for `CURRENT_RUSTC_VERSION` updates)
 - rust-lang/rust#152402 (Add regression test for rust-lang/rust#141738)
 - rust-lang/rust#152472 (unwind/wasm: fix compile error by wrapping wasm_throw in unsafe block)
 - rust-lang/rust#152610 (Exchange js_lint message between bless and non-bless)
2026-02-15 06:20:35 +00:00
reddevilmidzy
c92f384eb1 Move meta tests to compiletest-self-test, bootstrap dir 2026-02-15 04:43:02 +00:00
reddevilmidzy
86f1affe5a Move higher-ranked-trait-bounds tests into higher-ranked subdir 2026-02-15 04:39:21 +00:00
reddevilmidzy
863caf8b6b Move btreemap, hashmap tests into collections subdir 2026-02-15 04:39:13 +00:00
reddevilmidzy
1612988310 Move underscore-imports tests into imports subdir 2026-02-15 04:38:55 +00:00
reddevilmidzy
abca0d5f74 Move dynamically-sized-types tests into dst dir 2026-02-15 04:38:12 +00:00
Jacob Pratt
9369cfff04
Rollup merge of #152402 - AprilNEA:test/issue-141738-struct-ctor-array-len, r=BoxyUwU
Add regression test for #141738

Closes rust-lang/rust#141738

- Add a regression test for rust-lang/rust#141738
- Using a struct constructor (`DefKind::Ctor(Struct, Const)`) as an array repeat count with `#![feature(min_generic_const_args)]` used to ICE in const alias normalization
- Fixed by rust-lang/rust#150704, which added const constructor support for mGCA. This test covers the **error path** (struct ctor where `usize` is expected), which was not covered by the tests in rust-lang/rust#150704
2026-02-14 23:17:40 -05:00
Jacob Pratt
8075b89aa6
Rollup merge of #152508 - arferreira:improve-write-macro-diagnostic, r=Mark-Simulacrum
Improve write! and writeln! error when called without destination

Fixes rust-lang/rust#152493

Adds catch-all arms to `write!` and `writeln!` macros so that calling them without a destination (e.g., `write!("S")` instead of `write!(f, "S")`) gives a clear error instead of the cryptic "unexpected end of macro invocation" pointing at macro internals.

r? @estebank
2026-02-14 23:17:31 -05:00
Jacob Pratt
79adcd1375
Rollup merge of #150424 - xonx4l:suggest_param_env_shadowing, r=lcnr
diagnostics: add note when param-env shadows global impl

 This PR adds a diagnostics note when param-env shadows global impl as discussed in https://github.com/rust-lang/rust/issues/149910

It adds a note explaining that the definition is hidden by the generic bound.

r?lcnr
2026-02-14 23:17:30 -05:00
bors
75b9d89c68 Auto merge of #151380 - ShoyuVanilla:shallow-resolve-to-root-var, r=lcnr
Shallow resolve ty and const vars to their root vars

Continuation of https://github.com/rust-lang/rust/pull/147193
2026-02-15 03:04:28 +00:00
xonx
1be41648d4 move and add comment 2026-02-14 21:32:57 +00:00
Jonathan Brouwer
e6ca590153
Rollup merge of #152404 - durin42:llvm-23-instcombine-shrink-constant, r=Mark-Simulacrum
tests: adapt align-offset.rs for InstCombine improvements in LLVM 23

Upstream [has improved InstCombine](8d2078332c) so that it can shrink added constants using known zeroes, which caused a little bit of change in this test. As far as I can tell either output is fine, so we just accept both.

@rustbot label: +llvm-main
2026-02-14 22:11:54 +01:00
Jonathan Brouwer
96066cb5b5
Rollup merge of #143575 - GrigorenkoPV:unused_lifetimes, r=Mark-Simulacrum
Remove named lifetimes in some `PartialOrd` & `PartialEq` `impl`s

Makes [the docs](https://doc.rust-lang.org/1.88.0/std/cmp/trait.PartialOrd.html#impl-PartialOrd%3CPathBuf%3E-for-Cow%3C'a,+Path%3E) way easier to look at, gets rid of a few `#[allow(unused_lifetimes)]`, and AFAICT is completely equivalent.
2026-02-14 22:11:54 +01:00
Jonathan Brouwer
33c2a6eba9
Rollup merge of #151365 - RalfJung:unsafe-unpin-opsem, r=BoxyUwU
UnsafePinned: implement opsem effects of UnsafeUnpin

This implements the next step for https://github.com/rust-lang/rust/issues/125735: actually making `UnsafePinned` have special opsem effects by suppressing the `noalias` *even if* the type is wrapped in an `Unpin` wrapper.

For backwards compatibility we also still keep the `Unpin` hack, i.e. a type must be both `Unpin` and `UnsafeUnpin` to get `noalias`.
2026-02-14 22:11:53 +01:00
Jonathan Brouwer
6d625cc074
Rollup merge of #145024 - Kmeakin:km/optimize-slice-index/v3, r=Mark-Simulacrum
Optimize indexing slices and strs with inclusive ranges

Instead of separately checking for `end == usize::MAX` and `end + 1 > slice.len()`, we can check for `end >= slice.len()`. Also consolidate all the str indexing related panic functions into a single function which reports the correct error depending on the arguments, as the slice indexing code already does.

The downside of all this is that the panic message is slightly less specific when trying to index with `[..=usize::MAX]`: instead of saying "attempted to index str up to maximum usize" it just says "end byte index {end} out of bounds". But this is a rare enough case that I think it is acceptable
2026-02-14 22:11:52 +01:00
AprilNEA
8d96e26684
Add regression test for struct ctor used as array repeat count under mGCA
Using a struct constructor (DefKind::Ctor(Struct, Const)) as an array
repeat count with `#![feature(min_generic_const_args)]` used to trigger
an ICE in const alias normalization. Add a regression test to ensure
the compiler produces a proper type error instead of panicking.
2026-02-14 19:44:50 +00:00
Jonathan Brouwer
2c4656ac66
Rollup merge of #152120 - meithecatte:push-ltvwvkqrytno, r=petrochenkov
Don't ICE on layout error in vtable computation

Fixes rust-lang/rust#152030.

Note: I'm including a more general testcase that doesn't use the feature in the original report, but only reproduces with debuginfo disabled. Does it make sense to also include the original testcase?
2026-02-14 18:55:36 +01:00
Jonathan Brouwer
5ae6bb3faf
Rollup merge of #152001 - reddevilmidzy:mgca-i, r=BoxyUwU
mGCA: Validate const literal against expected type

close: rust-lang/rust#151625
close: rust-lang/rust#150983

also fix: https://github.com/rust-lang/rust/issues/133966 (moved crashes test)
2026-02-14 18:55:35 +01:00
bors
f8463896a9 Auto merge of #150681 - meithecatte:always-discriminate, r=JonathanBrouwer,Nadrieril
Make operational semantics of pattern matching independent of crate and module

The question of "when does matching an enum against a pattern of one of its variants read its discriminant" is currently an underspecified part of the language, causing weird behavior around borrowck, drop order, and UB.

Of course, in the common cases, the discriminant must be read to distinguish the variant of the enum, but currently the following exceptions are implemented:

1. If the enum has only one variant, we currently skip the discriminant read.
     - This has the advantage that single-variant enums behave the same way as structs in this regard.
     - However, it means that if the discriminant exists in the layout, we can't say that this discriminant being invalid is UB. This makes me particularly uneasy in its interactions with niches – consider the following example ([playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=5904a6155cbdd39af4a2e7b1d32a9b1a)), where miri currently doesn't detect any UB (because the semantics don't specify any):

        <details><summary>Example 1</summary>

        ```rust
        #![allow(dead_code)]
        use core::mem::{size_of, transmute};
        
        #[repr(u8)]
        enum Inner {
            X(u8),
        }
        
        enum Outer {
            A(Inner),
            B(u8),
        }
        
        fn f(x: &Inner) {
            match x {
                Inner::X(v) => {
                    println!("{v}");
                }
            }
        }
        
        fn main() {
            assert_eq!(size_of::<Inner>(), 2);
            assert_eq!(size_of::<Outer>(), 2);
            let x = Outer::B(42);
            let y = &x;
            f(unsafe { transmute(y) });
        }
        ```

      </details>

2. For the purpose of the above, enums with marked with `#[non_exhaustive]` are always considered to have multiple variants when observed from foreign crates, but the actual number of variants is considered in the current crate.
    - This means that whether code has UB can depend on which crate it is in: https://github.com/rust-lang/rust/issues/147722
    - In another case of `#[non_exhaustive]` affecting the runtime semantics, its presence or absence can change what gets captured by a closure, and by extension, the drop order: https://github.com/rust-lang/rust/issues/147722#issuecomment-3674554872
    - Also at the above link, there is an example where removing `#[non_exhaustive]` can cause borrowck to suddenly start failing in another crate.
3. Moreover, we currently make a more specific check: we only read the discriminant if there is more than one *inhabited* variant in the enum.
    - This means that the semantics can differ between `foo<!>`, and a copy of `foo` where `T` was manually replaced with `!`: rust-lang/rust#146803
    - Moreover, due to the privacy rules for inhabitedness, it means that the semantics of code can depend on the *module* in which it is located.
    - Additionally, this inhabitedness rule is even uglier due to the fact that closure capture analysis needs to happen before we can determine whether types are uninhabited, which means that whether the discriminant read happens has a different answer specifically for capture analysis.
    - For the two above points, see the following example ([playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=a07d8a3ec0b31953942e96e2130476d9)):

        <details><summary>Example 2</summary>

        ```rust
        #![allow(unused)]
        
        mod foo {
            enum Never {}
            struct PrivatelyUninhabited(Never);
            pub enum A {
                V(String, String),
                Y(PrivatelyUninhabited),
            }
            
            fn works(mut x: A) {
                let a = match x {
                    A::V(ref mut a, _) => a,
                    _ => unreachable!(),
                };
                
                let b = match x {
                    A::V(_, ref mut b) => b,
                    _ => unreachable!(),
                };
            
                a.len(); b.len();
            }
            
            fn fails(mut x: A) {
                let mut f = || match x {
                    A::V(ref mut a, _) => (),
                    _ => unreachable!(),
                };
                
                let mut g = || match x {
                    A::V(_, ref mut b) => (),
                    _ => unreachable!(),
                };
            
                f(); g();
            }
        }
        
        use foo::A;
        
        fn fails(mut x: A) {
            let a = match x {
                A::V(ref mut a, _) => a,
                _ => unreachable!(),
            };
            
            let b = match x {
                A::V(_, ref mut b) => b,
                _ => unreachable!(),
            };
        
            a.len(); b.len();
        }
        
        
        fn fails2(mut x: A) {
            let mut f = || match x {
                A::V(ref mut a, _) => (),
                _ => unreachable!(),
            };
            
            let mut g = || match x {
                A::V(_, ref mut b) => (),
                _ => unreachable!(),
            };
        
            f(); g();
        }
        ```

        </details>

In light of the above, and following the discussion at rust-lang/rust#138961 and rust-lang/rust#147722, this PR ~~makes it so that, operationally, matching on an enum *always* reads its discriminant.~~ introduces the following changes to this behavior:

 - matching on a `#[non_exhaustive]` enum will always introduce a discriminant read, regardless of whether the enum is from an external crate
 - uninhabited variants now count just like normal ones, and don't get skipped in the checks

As per the discussion below, the resolution for point (1) above is that it should land as part of a separate PR, so that the subtler decision can be more carefully considered.

Note that this is a breaking change, due to the aforementioned changes in borrow checking behavior, new UB (or at least UB newly detected by miri), as well as drop order around closure captures. However, it seems to me that the combination of this PR with rust-lang/rust#138961 should have smaller real-world impact than rust-lang/rust#138961 by itself.

Fixes rust-lang/rust#142394 
Fixes rust-lang/rust#146590
Fixes rust-lang/rust#146803 (though already marked as duplicate)
Fixes parts of rust-lang/rust#147722
Fixes rust-lang/miri#4778

r? @Nadrieril @RalfJung 

@rustbot label +A-closures +A-patterns +T-opsem +T-lang
2026-02-14 12:53:09 +00:00
Scott McMurray
774268afc1 Pass alignments through the shim as Alignment (not usize)
We're using `Layout` on both sides, so might as well skip the transmutes back and forth to `usize`.

The mir-opt test shows that doing so allows simplifying the boxed-slice drop slightly, for example.
2026-02-14 01:39:16 -08:00
bors
3f808f29e6 Auto merge of #152602 - jhpratt:rollup-uaxGseW, r=jhpratt
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#151998 (Set hidden visibility on naked functions in compiler-builtins)
 - rust-lang/rust#149460 (rustdoc: sort stable items first)
 - rust-lang/rust#152076 (Feed `ErrorGuaranteed` from late lifetime resolution errors through to bound variable resolution)
 - rust-lang/rust#152471 (improve associated-type suggestions from bounds)
 - rust-lang/rust#152573 (move `escape_symbol_name` to `cg_ssa`)
 - rust-lang/rust#152594 (c-variadic: implement `va_arg` for `wasm64`)
 - rust-lang/rust#151386 (rustdoc: more js cleanup)
 - rust-lang/rust#152567 (nix-dev-shell: fix a typo)
 - rust-lang/rust#152568 (Port `#[lang]` and `#[panic_handler]` to the new attribute parsers)
 - rust-lang/rust#152575 (layout_of unexpected rigid alias delayed bug)
 - rust-lang/rust#152587 (A couple of tiny polonius things)
2026-02-14 06:23:09 +00:00
reddevilmidzy
b4ee9953d8 modify error comment and bless test, delete tests/ui/const-generics/generic_const_exprs/lit_type_mismatch.rs 2026-02-14 04:12:46 +00:00
reddevilmidzy
8af02e230a mGCA: Validate const literal against expected type
Co-authored-by: Boxy <rust@boxyuwu.dev>
2026-02-14 04:12:40 +00:00
Jacob Pratt
4bcbf6274a
Rollup merge of #152587 - lqd:tiny-things, r=jackh726
A couple of tiny polonius things

Here's a couple of tiny things I had ready to go @jackh726
- a tiny cleanup to avoid round-tripping through `Location`s to check for liveness, since we're already working with points
- while I was there, I fixed the doc which wasn't showing up properly (maybe a rustdoc or bootstrap bug when we build locally or during dist, either way, both don't show up correctly linked most of the time) for `PointIndex`es.
- and in the second commit slightly expand test coverage with [an example](https://internals.rust-lang.org/t/get-mut-map-back-from-entry-api/24003) that would have needed stdlib changes (cc author @Darksonn for visibility here)

More soon.

r? @jackh726
2026-02-13 22:26:36 -05:00
Jacob Pratt
8125a56f07
Rollup merge of #152575 - lcnr:layout-error-to-delayed-bug, r=jackh726
layout_of unexpected rigid alias delayed bug

fixes rust-lang/rust#152545. The trait solver can keep aliases as rigid even if they are not well-formed d7daac06d8/compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs (L315-L345)

r? types
2026-02-13 22:26:36 -05:00
Jacob Pratt
22f973db34
Rollup merge of #152568 - JonathanBrouwer:port_lang, r=jdonszelmann
Port `#[lang]` and `#[panic_handler]` to the new attribute parsers

For https://github.com/rust-lang/rust/issues/131229#issuecomment-2971351163

r? @jdonszelmann
2026-02-13 22:26:35 -05:00
Jacob Pratt
b80512462f
Rollup merge of #152471 - JohnTitor:sugg-assoc-items-from-bounds, r=estebank
improve associated-type suggestions from bounds

Should address invalid suggestions I could come up with, but the suggestion is too hand-crafted and invalid patterns may exist.
r? @estebank
Fix https://github.com/rust-lang/rust/issues/73321
2026-02-13 22:26:33 -05:00
Jacob Pratt
000d1f18bc
Rollup merge of #152076 - eggyal:undeclared-object-lifetime, r=fmease
Feed `ErrorGuaranteed` from late lifetime resolution errors through to bound variable resolution

If late lifetime resolution fails for whatever reason, forward to RBV the guarantee that an error was emitted - thereby eliminating the need for a "hack" to suppress subsequent/superfluous error diagnostics.

Fixes rust-lang/rust#152014
r? fmease
2026-02-13 22:26:32 -05:00
Jacob Pratt
9b4219baad
Rollup merge of #149460 - lolbinarycat:rustdoc-search-sort-stable-first, r=notriddle
rustdoc: sort stable items first

Finally tackling this again now that the search system refactor is done.  The tests and the general approach were taken from the original PR.
2026-02-13 22:26:32 -05:00
bors
29fa07e3db Auto merge of #149389 - ShoyuVanilla:local-region-param-wf, r=lcnr
WF check lifetime bounds for locals with type params

FCP proposal in https://github.com/rust-lang/rust/pull/149389#issuecomment-3669689488

Fixes rust-lang/rust#115175
Fixes rust-lang/rust#148854
2026-02-14 02:52:05 +00:00
Pavel Grigorenko
cd314dead1 Remove named lifetimes in some PartialOrd & PartialEq impls 2026-02-14 00:13:46 +03:00
binarycat
dca86a9521 rustdoc: sort stable items first 2026-02-13 14:44:41 -06:00
Rémy Rakic
65eb2e709d add another NLL problem case 3 variant 2026-02-13 17:29:49 +00:00
Alan Egerton
c43a33eec7
Feed ErrorGuaranteed from late lifetime resolution to RBV
If late lifetime resolution fails for whatever reason, forward to RBV
the guarantee that an error was emitted - thereby eliminating the need
for a "hack" to suppress subsequent/superfluous error diagnostics.
2026-02-13 16:24:39 +00:00
Jonathan Brouwer
c61c2603cf Port #[lang] to the new attribute parsers 2026-02-13 16:04:19 +00:00
xonx
34981bf3cd add comments to tests 2026-02-13 14:44:40 +00:00
lcnr
b3d9fbc172 ICE to delayed bug 2026-02-13 13:50:43 +00:00
lcnr
b4f38c1da4 add regression test 2026-02-13 13:50:43 +00:00
Jonathan Brouwer
d93a38a488
Rollup merge of #152565 - Kivooeo:ctor-diag, r=BoxyUwU
fix missleading error for tuple ctor

r? BoxyUwU

fixes https://github.com/rust-lang/rust/issues/151414
2026-02-13 13:35:04 +01:00
Jonathan Brouwer
1944af691e
Rollup merge of #152554 - JonathanBrouwer:remove_deprecated_safe, r=jdonszelmann
Remove `deprecated_safe` and its corresponding feature gate

This unimplements the feature gate for tracking issue https://github.com/rust-lang/rust/issues/94978
The author of that tracking issue and the MCP seem to no longer exist
Afaik we can just do this, but let me know if I'm wrong

Because this feature has been idle for 3+ years, and it is in the way to finish the attribute refactoring (https://github.com/rust-lang/rust/issues/131229#issuecomment-2971351163)
When someone wants to do work on it the feature gate can be re-added

r? @jdonszelmann
2026-02-13 13:35:03 +01:00
Jonathan Brouwer
7ea8f5b721
Rollup merge of #152407 - AprilNEA:test/issue-148953-type-const-ctor, r=Kivooeo
Add regression test for type_const with unit struct ctor under mGCA

- Add a regression test for https://github.com/rust-lang/rust/issues/148953

Closes #148953
2026-02-13 13:35:01 +01:00
Jonathan Brouwer
e91d02a8c3
Rollup merge of #152392 - TaKO8Ki:missing-generics-in-traits-used-in-const, r=jieyouxu
Fix ICE in supertrait_vtable_slot when supertrait has missing generics

Fixes rust-lang/rust#151330
2026-02-13 13:35:01 +01:00
Jonathan Brouwer
98e8f99bc0
Rollup merge of #152218 - adwinwhite:fix-mir-borrowck-opaque-handling-keep-all-errors, r=lcnr
Report unconstrained region in hidden types lazily

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/264

I didn't copy the mechanism of HIR typeck as I found that we just need to be lax in the unconstrained region case.
It already ignores non-defining uses and invalid params.

About tests, I'm having trouble coming up with more complex ones. 🙁

This fixes `ukanren` and `codecrafters-redis-rust` but not rust-lang/rust#151322 and rust-lang/rust#151323.
I believe they are a [different problem](https://github.com/rust-lang/rust/issues/151322#issuecomment-3864656974).

r? @lcnr
2026-02-13 13:35:00 +01:00
Jonathan Brouwer
9d662b5815
Rollup merge of #152323 - JohnTitor:issue-135845-2, r=lcnr
Fix ICE in borrowck when recovering `fn_sig` for `-> _`

(Should be) a proper fix for rust-lang/rust#135845, replaces a dummy binder with a concrete one not to ICE, as mentioned in https://github.com/rust-lang/rust/pull/147631#issuecomment-3460724226.
Fixes rust-lang/rust#135845
r? @lcnr @jackh726
2026-02-13 13:34:58 +01:00