Commit graph

318302 commits

Author SHA1 Message Date
Folkert de Vries
f5bf3353e6
move va_list operations into InterpCx 2026-02-14 22:55:26 +01:00
Folkert de Vries
ca3d1a3211
add c-variadic miri test 2026-02-14 22:27:41 +01:00
Folkert de Vries
02c4af397e
c-variadic functions in rustc_const_eval 2026-02-14 22:27:39 +01:00
Folkert de Vries
ce693807f6
make Va::arg and VaList::drop const fns 2026-02-14 22:26:24 +01:00
Folkert de Vries
a7888c1342
allow const fn to be c-variadic
however `Drop` for `VaList` is not yet available in const fn
2026-02-14 22:26:23 +01:00
bors
a33907a7a5 Auto merge of #152627 - JonathanBrouwer:rollup-wjHXhK0, r=JonathanBrouwer
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#152618 (stdarch subtree update)
 - rust-lang/rust#152001 (mGCA: Validate const literal against expected type)
 - rust-lang/rust#152120 (Don't ICE on layout error in vtable computation)
 - rust-lang/rust#152531 (`proc_macro::bridge`: simplify `ExecutionStrategy` and `DispatcherTrait`)
 - rust-lang/rust#152577 (Port #[rustc_proc_macro_decls] to the new attribute parser.)
 - rust-lang/rust#152570 (Port #[rustc_test_marker] to the attribute parser)
 - rust-lang/rust#152590 (DepGraphQuery: correctly skip adding edges with not-yet-added nodes)
 - rust-lang/rust#152612 (Rename `inline_fluent!` to `msg!`)
2026-02-14 17:56:54 +00:00
Jonathan Brouwer
38cc50b6e4
Rollup merge of #152612 - JonathanBrouwer:rename_to_msg, r=jdonszelmann
Rename `inline_fluent!` to `msg!`

This was the most popular name for the macro as voted in [#t-compiler > Bikeshed the new `inline_fluent!` macro @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Bikeshed.20the.20new.20.60inline_fluent!.60.20macro/near/572751863)
2026-02-14 18:55:38 +01:00
Jonathan Brouwer
3f3c6fda3d
Rollup merge of #152590 - petrochenkov:skipedge, r=mati865
DepGraphQuery: correctly skip adding edges with not-yet-added nodes

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

The current logic already skips some edges, so I'm not sure how critical it is to have *all* the edges recorded, the logic seems to only be used for debug dumping.
Recording all edges requires supporting holes in the `LinkedGraph` data structure, to add nodes and edges out of order, https://github.com/rust-lang/rust/pull/151821 implements that at cost of complicating the data structure.
2026-02-14 18:55:38 +01:00
Jonathan Brouwer
923fb76303
Rollup merge of #152570 - Ozzy1423:attr-parse, r=JonathanBrouwer
Port #[rustc_test_marker] to the attribute parser

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

Targets:
Const is for normal tests (const test::TestDescAndFn is inserted before the test fn)
Const/Static/Fn is for custom_test_framework's #[test_case] e.g. tests/ui/custom_test_frameworks/full.rs

r? @JonathanBrouwer

Again I left the use-sites as is since they are early uses.
2026-02-14 18:55:37 +01:00
Jonathan Brouwer
cf0cb74612
Rollup merge of #152577 - Ozzy1423:macro-attr, r=JonathanBrouwer
Port #[rustc_proc_macro_decls] to the new attribute parser.

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

r? @JonathanBrouwer
2026-02-14 18:55:36 +01:00
Jonathan Brouwer
8a03b5f3ec
Rollup merge of #152531 - cyrgani:pm-yet-another-cleanup, r=petrochenkov
`proc_macro::bridge`: simplify `ExecutionStrategy` and `DispatcherTrait`

Also includes another tiny cleanup (functions can only have one return type).
2026-02-14 18:55:36 +01: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
Jonathan Brouwer
6213acdbb8
Rollup merge of #152618 - folkertdev:stdarch-sync-2026-02-14, r=folkertdev
stdarch subtree update

Subtree update of `stdarch` to 1239a9f83a.

Created using https://github.com/rust-lang/josh-sync.

r? @ghost
2026-02-14 18:55:34 +01:00
Vadim Petrochenkov
b0366ce935 DepGraphQuery: correctly skip adding edges with not-yet-added nodes 2026-02-14 16:17:42 +03:00
Oscar Bray
6ed7615608 Port #[rustc_test_marker] to the attribute parser 2026-02-14 13:14:57 +00: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
Jonathan Brouwer
018a5efcf7
Rename inline_fluent! to msg! 2026-02-14 13:47:52 +01:00
bors
5d04477ea8 Auto merge of #152516 - nnethercote:mv-query-system-code-3, r=Zalathar
Move `rustc_query_system` code, part 3

Following on from rust-lang/rust#152419.

r? @Zalathar
2026-02-14 09:38:24 +00:00
Nicholas Nethercote
ed091aaf5d Move rustc_query_system::query::dep_graph to rustc_middle.
Most of the files within the `dep_graph` module can be moved wholesale
into `rustc_middle`. But two of them (`mod.rs` and `dep_node.rs`) have
the same name as existing files in `rustc_middle`, so for those I just
copied the contents into the existing files.

The commit also moves `QueryContext` and `incremental_verify_ich*`
because they are tightly intertwined with the dep graph code. And a
couple of error structs moved as well.
2026-02-14 18:46:05 +11:00
Nicholas Nethercote
fa3b046aa5 Move QueryMode.
From `rustc_query_system::query::plumbing` to
`rustc_middle::query::plumbing`.
2026-02-14 18:38:33 +11:00
Nicholas Nethercote
924dbc46d9 Move CycleErrorHandling.
From `rustc_query_system` to `rustc_middle`.
2026-02-14 18:38:33 +11:00
Nicholas Nethercote
940f30792c Move rustc_query_system::query::caches to rustc_middle::query.
This one is straightforward.
2026-02-14 18:38:30 +11:00
Nicholas Nethercote
8b0dc1ece0 Move rustc_query_system::query::job to rustc_middle.
This includes the types `QueryInfo`, `QueryJob`, `QueryJobId`,
`QueryWaiter`, `QueryLatch`, and `QueryLatchInfo`.

`CycleError` and `QueryStack*` had to come along too, due to type
interdependencies. The `QueryStack*` types are put into a new submodule
`rustc_middle::query::stack`.
2026-02-14 18:33:13 +11:00
Nicholas Nethercote
1ac199af0a Move QueryState/ActiveKeyStatus.
From `rustc_query_state` to `rustc_middle`.
2026-02-14 18:24:47 +11: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
01d48c62a5 Move LitToConstInput into ty::consts
Relocate LitToConstInput and const_lit_matches_ty from mir::interpret
to ty::consts::lit
2026-02-14 04:12:46 +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
7719d63f01
Rollup merge of #152567 - makai410:nix-typo, r=WaffleLapkin
nix-dev-shell: fix a typo

meow

r? @WaffleLapkin
2026-02-13 22:26:35 -05:00
Jacob Pratt
9f3f83bfee
Rollup merge of #151386 - lolbinarycat:rustdoc-ts-cleanup, r=GuillaumeGomez
rustdoc: more js cleanup

Continuing the effort of removing `@ts-expect-error` from the codebase wherever possible, this time focusing on `main.js`.  Found some oddities with `register_type_impls`, fixed most of them, but the one that I couldn't figure out is what's going on with `sidebarTraitList`.  It's queried, then if there are any trait imps, unconditionally overwritten, then latter code assumes that one of these two things has initialized it, but it's not obvious why this would be the case, or if there's a reason this wasn't done in a more straightforwards way.

r? @GuillaumeGomez
2026-02-13 22:26:34 -05:00
Jacob Pratt
61dee57441
Rollup merge of #152594 - folkertdev:va-list-wasm64, r=alexcrichton
c-variadic: implement `va_arg` for `wasm64`

tracking issue: https://github.com/rust-lang/rust/issues/44930

A LLVM maintainer of the wasm backend confirmed that the behavior on wasm64 is intented: the slot size is 4 on both wasm32 and wasm64. https://github.com/llvm/llvm-project/pull/173580#issuecomment-3900118960

r? workingjubilee
cc @alexcrichton as target maintainer
2026-02-13 22:26:34 -05:00
Jacob Pratt
202f102914
Rollup merge of #152573 - usamoi:escape-2, r=bjorn3
move `escape_symbol_name` to `cg_ssa`

followup of rust-lang/rust#151955

r? @bjorn3
2026-02-13 22:26:33 -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
Jacob Pratt
4571317d32
Rollup merge of #151998 - zmodem:naked_visibility.squash, r=saethlin,bjorn3
Set hidden visibility on naked functions in compiler-builtins

88b46460fa made builtin functions hidden, but it doesn't apply to naked functions, which are generated through a different code path.

This was discovered in rust-lang/rust#151486 where aarch64 outline atomics showed up in shared objects, overriding the symbols from compiler-rt.
2026-02-13 22:26:31 -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
Folkert de Vries
cc9e8c9716
c-variadic: implement va_arg for wasm64 2026-02-14 00:51:10 +01:00
bors
f403dee04e Auto merge of #152574 - JonathanBrouwer:rollup-ERc05AE, r=JonathanBrouwer
Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#152323 (Fix ICE in borrowck when recovering `fn_sig` for `-> _`)
 - rust-lang/rust#152469 (Remove unused features)
 - rust-lang/rust#152515 (Extract `DepKindVTable` constructors to their own module)
 - rust-lang/rust#152555 (Port `#[rustc_diagnostic_item]` to the new attribute parsers)
 - rust-lang/rust#152218 (Report unconstrained region in hidden types lazily)
 - rust-lang/rust#152356 (Improve the `inline_fluent!` macro)
 - rust-lang/rust#152392 (Fix ICE in supertrait_vtable_slot when supertrait has missing generics)
 - rust-lang/rust#152407 (Add regression test for type_const with unit struct ctor under mGCA)
 - rust-lang/rust#152440 (Fix typos and grammar in compiler and build documentation)
 - rust-lang/rust#152536 (bootstrap: add explicit UTF-8 encoding to text-mode open() calls)
 - rust-lang/rust#152554 (Remove `deprecated_safe` and its corresponding feature gate)
 - rust-lang/rust#152556 (doc: move riscv64a23-unknown-linux-gnu to tier 2)
 - rust-lang/rust#152563 (Replace "bug" with "issue" in triagebot ping messages)
 - rust-lang/rust#152565 (fix missleading error for tuple ctor)

Failed merges:

 - rust-lang/rust#152512 (core: Implement feature `float_exact_integer_constants`)
 - rust-lang/rust#152296 (Port `rust_nonnull_optimization_guaranteed` and `rustc_do_not_const_check` to the new attribute parser)
2026-02-13 23:16:29 +00:00
binarycat
dca86a9521 rustdoc: sort stable items first 2026-02-13 14:44:41 -06:00
bors
a423f68a0d Auto merge of #152533 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update

r? @Manishearth 

1 week late, due to vacation and some technical issues.
2026-02-13 18:09:00 +00:00
Rémy Rakic
65eb2e709d add another NLL problem case 3 variant 2026-02-13 17:29:49 +00:00
Rémy Rakic
be204dd047 make per-point liveness accessible
It avoids round-tripping through `Location`s if you're working with
`Point`s already.
2026-02-13 17:10:29 +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
ee8ca0a89f Port #[panic_handler] to the new attribute parsers 2026-02-13 16:05:17 +00:00
Jonathan Brouwer
c61c2603cf Port #[lang] to the new attribute parsers 2026-02-13 16:04:19 +00:00