mGCA: Validate const literal against expected type#152001
Merged
rust-bors[bot] merged 3 commits intorust-lang:mainfrom Feb 14, 2026
Merged
mGCA: Validate const literal against expected type#152001rust-bors[bot] merged 3 commits intorust-lang:mainfrom
rust-bors[bot] merged 3 commits intorust-lang:mainfrom
Conversation
reddevilmidzy
commented
Feb 2, 2026
This comment has been minimized.
This comment has been minimized.
BoxyUwU
reviewed
Feb 4, 2026
Member
|
very cool :) thanks for working on this |
This comment has been minimized.
This comment has been minimized.
This was referenced Feb 6, 2026
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Feb 6, 2026
…=oli-obk Dont strip const blocks in array lengths r? oli-obk mGCA now handles const blocks by *always* handling them during `lower_expr_to_const_arg_direct` instead of *sometimes* stripping them out at parse time. This is just generally a lot clearer/nicer but also means parsing isn't lossy which is just straight up wrong. We now use `MgcaDisambiguation::Direct` for const blocks because we "directly" represent a const block as `hir::ConstArgKind::Anon` :> The only time that an anon const for const generics uses `MgcaDisambiguation::AnonConst` is for unbraced literals. Once we properly support literals in `hir::ConstArgKind` (see rust-lang#152139 rust-lang#152001) then `MgcaDisambiguation` can be renamed to `AnonConstKind` with `TypeSystem` and `NonTypeSystem` variants. We can also get rid of `mgca_direct_lit_hack`. I expect this to be a very nice cleanup :) Fixes rust-lang/rustfmt#6788 The diff relating to passing spans around is to avoid a bunch of mGCA diagnostics changing from `const {}` to `{}`. I'm not entirely sure why this was happening. cc @rust-lang/rustfmt How do I run the tests in the rustfmt repo from here? `x test rustfmt` only seems to run like 100 tests and doesn't result in a `target/issue-6788.rs` getting created. I've verified locally that this formats correctly though
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Feb 6, 2026
…=oli-obk Dont strip const blocks in array lengths r? oli-obk mGCA now handles const blocks by *always* handling them during `lower_expr_to_const_arg_direct` instead of *sometimes* stripping them out at parse time. This is just generally a lot clearer/nicer but also means parsing isn't lossy which is just straight up wrong. We now use `MgcaDisambiguation::Direct` for const blocks because we "directly" represent a const block as `hir::ConstArgKind::Anon` :> The only time that an anon const for const generics uses `MgcaDisambiguation::AnonConst` is for unbraced literals. Once we properly support literals in `hir::ConstArgKind` (see rust-lang#152139 rust-lang#152001) then `MgcaDisambiguation` can be renamed to `AnonConstKind` with `TypeSystem` and `NonTypeSystem` variants. We can also get rid of `mgca_direct_lit_hack`. I expect this to be a very nice cleanup :) Fixes rust-lang/rustfmt#6788 The diff relating to passing spans around is to avoid a bunch of mGCA diagnostics changing from `const {}` to `{}`. I'm not entirely sure why this was happening. cc @rust-lang/rustfmt How do I run the tests in the rustfmt repo from here? `x test rustfmt` only seems to run like 100 tests and doesn't result in a `target/issue-6788.rs` getting created. I've verified locally that this formats correctly though
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Feb 6, 2026
…=oli-obk Dont strip const blocks in array lengths r? oli-obk mGCA now handles const blocks by *always* handling them during `lower_expr_to_const_arg_direct` instead of *sometimes* stripping them out at parse time. This is just generally a lot clearer/nicer but also means parsing isn't lossy which is just straight up wrong. We now use `MgcaDisambiguation::Direct` for const blocks because we "directly" represent a const block as `hir::ConstArgKind::Anon` :> The only time that an anon const for const generics uses `MgcaDisambiguation::AnonConst` is for unbraced literals. Once we properly support literals in `hir::ConstArgKind` (see rust-lang#152139 rust-lang#152001) then `MgcaDisambiguation` can be renamed to `AnonConstKind` with `TypeSystem` and `NonTypeSystem` variants. We can also get rid of `mgca_direct_lit_hack`. I expect this to be a very nice cleanup :) Fixes rust-lang/rustfmt#6788 The diff relating to passing spans around is to avoid a bunch of mGCA diagnostics changing from `const {}` to `{}`. I'm not entirely sure why this was happening. cc @rust-lang/rustfmt How do I run the tests in the rustfmt repo from here? `x test rustfmt` only seems to run like 100 tests and doesn't result in a `target/issue-6788.rs` getting created. I've verified locally that this formats correctly though
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Feb 7, 2026
…=oli-obk Dont strip const blocks in array lengths r? oli-obk mGCA now handles const blocks by *always* handling them during `lower_expr_to_const_arg_direct` instead of *sometimes* stripping them out at parse time. This is just generally a lot clearer/nicer but also means parsing isn't lossy which is just straight up wrong. We now use `MgcaDisambiguation::Direct` for const blocks because we "directly" represent a const block as `hir::ConstArgKind::Anon` :> The only time that an anon const for const generics uses `MgcaDisambiguation::AnonConst` is for unbraced literals. Once we properly support literals in `hir::ConstArgKind` (see rust-lang#152139 rust-lang#152001) then `MgcaDisambiguation` can be renamed to `AnonConstKind` with `TypeSystem` and `NonTypeSystem` variants. We can also get rid of `mgca_direct_lit_hack`. I expect this to be a very nice cleanup :) Fixes rust-lang/rustfmt#6788 The diff relating to passing spans around is to avoid a bunch of mGCA diagnostics changing from `const {}` to `{}`. I'm not entirely sure why this was happening. cc @rust-lang/rustfmt How do I run the tests in the rustfmt repo from here? `x test rustfmt` only seems to run like 100 tests and doesn't result in a `target/issue-6788.rs` getting created. I've verified locally that this formats correctly though
rust-timer
added a commit
that referenced
this pull request
Feb 7, 2026
Rollup merge of #152234 - BoxyUwU:dont_strip_const_blocks, r=oli-obk Dont strip const blocks in array lengths r? oli-obk mGCA now handles const blocks by *always* handling them during `lower_expr_to_const_arg_direct` instead of *sometimes* stripping them out at parse time. This is just generally a lot clearer/nicer but also means parsing isn't lossy which is just straight up wrong. We now use `MgcaDisambiguation::Direct` for const blocks because we "directly" represent a const block as `hir::ConstArgKind::Anon` :> The only time that an anon const for const generics uses `MgcaDisambiguation::AnonConst` is for unbraced literals. Once we properly support literals in `hir::ConstArgKind` (see #152139 #152001) then `MgcaDisambiguation` can be renamed to `AnonConstKind` with `TypeSystem` and `NonTypeSystem` variants. We can also get rid of `mgca_direct_lit_hack`. I expect this to be a very nice cleanup :) Fixes rust-lang/rustfmt#6788 The diff relating to passing spans around is to avoid a bunch of mGCA diagnostics changing from `const {}` to `{}`. I'm not entirely sure why this was happening. cc @rust-lang/rustfmt How do I run the tests in the rustfmt repo from here? `x test rustfmt` only seems to run like 100 tests and doesn't result in a `target/issue-6788.rs` getting created. I've verified locally that this formats correctly though
e08830e to
cd5b323
Compare
BoxyUwU
reviewed
Feb 7, 2026
BoxyUwU
reviewed
Feb 7, 2026
This comment has been minimized.
This comment has been minimized.
Member
Author
|
Haha, ICE occurs in other tests... |
ac69206 to
ca77eab
Compare
reddevilmidzy
commented
Feb 7, 2026
This comment has been minimized.
This comment has been minimized.
reddevilmidzy
commented
Feb 8, 2026
Member
Author
There was a problem hiding this comment.
In ten crash tests, the ICE disappeared; however, in tests/crashes/117460.rs, tests/crashes/114212-2.rs and tests/crashes/114212.rs, adding the main function caused the ICE to occur again.
| @@ -0,0 +1,23 @@ | |||
| //! Regression test for <https://github.com/rust-lang/rust/issues/116554> | |||
Member
Author
There was a problem hiding this comment.
This issue was closed; is there a need to add further testing?
Member
There was a problem hiding this comment.
unsure, I will look over all the GCE tests (outside of this PR) at some point soon and see which ones are worth keeping
Member
Author
This comment has been minimized.
This comment has been minimized.
75e7e18 to
2b5c8b7
Compare
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Feb 14, 2026
mGCA: Validate const literal against expected type close: rust-lang#151625 close: rust-lang#150983 also fix: rust-lang#133966 (moved crashes test)
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Feb 14, 2026
mGCA: Validate const literal against expected type close: rust-lang#151625 close: rust-lang#150983 also fix: rust-lang#133966 (moved crashes test)
rust-bors bot
pushed a commit
that referenced
this pull request
Feb 14, 2026
…uwer Rollup of 7 pull requests Successful merges: - #152001 (mGCA: Validate const literal against expected type) - #152120 (Don't ICE on layout error in vtable computation) - #152512 (core: Implement feature `float_exact_integer_constants`) - #152531 (`proc_macro::bridge`: simplify `ExecutionStrategy` and `DispatcherTrait`) - #152577 (Port #[rustc_proc_macro_decls] to the new attribute parser.) - #152590 (DepGraphQuery: correctly skip adding edges with not-yet-added nodes) - #152612 (Rename `inline_fluent!` to `msg!`)
rust-bors bot
pushed a commit
that referenced
this pull request
Feb 14, 2026
…uwer Rollup of 8 pull requests Successful merges: - #152618 (stdarch subtree update) - #152001 (mGCA: Validate const literal against expected type) - #152120 (Don't ICE on layout error in vtable computation) - #152531 (`proc_macro::bridge`: simplify `ExecutionStrategy` and `DispatcherTrait`) - #152577 (Port #[rustc_proc_macro_decls] to the new attribute parser.) - #152570 (Port #[rustc_test_marker] to the attribute parser) - #152590 (DepGraphQuery: correctly skip adding edges with not-yet-added nodes) - #152612 (Rename `inline_fluent!` to `msg!`)
rust-timer
added a commit
that referenced
this pull request
Feb 14, 2026
github-actions bot
pushed a commit
to rust-lang/stdarch
that referenced
this pull request
Feb 16, 2026
…uwer 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!`)
github-actions bot
pushed a commit
to rust-lang/rust-analyzer
that referenced
this pull request
Feb 16, 2026
…uwer 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!`)
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Feb 25, 2026
mGCA: Lower negated literals directly and reject non-integer negations follow up rust-lang#152001 resolve: rust-lang#152246 r? BoxyUwU
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Feb 25, 2026
mGCA: Lower negated literals directly and reject non-integer negations follow up rust-lang#152001 resolve: rust-lang#152246 r? BoxyUwU
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Feb 25, 2026
mGCA: Lower negated literals directly and reject non-integer negations follow up rust-lang#152001 resolve: rust-lang#152246 r? BoxyUwU
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Feb 25, 2026
mGCA: Lower negated literals directly and reject non-integer negations follow up rust-lang#152001 resolve: rust-lang#152246 r? BoxyUwU
jhpratt
added a commit
to jhpratt/rust
that referenced
this pull request
Feb 26, 2026
mGCA: Lower negated literals directly and reject non-integer negations follow up rust-lang#152001 resolve: rust-lang#152246 r? BoxyUwU
rust-timer
added a commit
that referenced
this pull request
Feb 26, 2026
29 tasks
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Feb 28, 2026
Fix ICE in `try_to_raw_bytes` when array elements have mismatched close: rust-lang#152683 After rust-lang#152001, suffixed integer literals preserve their own type during const lowering, so `try_to_raw_bytes` could call `.to_u8()` on a scalar with size > 1, causing an ICE. Fix by using `try_to_bits(Size::from_bytes(1)).ok()` instead. r? BoxyUwU
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Feb 28, 2026
Fix ICE in `try_to_raw_bytes` when array elements have mismatched close: rust-lang#152683 After rust-lang#152001, suffixed integer literals preserve their own type during const lowering, so `try_to_raw_bytes` could call `.to_u8()` on a scalar with size > 1, causing an ICE. Fix by using `try_to_bits(Size::from_bytes(1)).ok()` instead. r? BoxyUwU
rust-timer
added a commit
that referenced
this pull request
Mar 1, 2026
Rollup merge of #152794 - reddevilmidzy:mgca-print, r=BoxyUwU Fix ICE in `try_to_raw_bytes` when array elements have mismatched close: #152683 After #152001, suffixed integer literals preserve their own type during const lowering, so `try_to_raw_bytes` could call `.to_u8()` on a scalar with size > 1, causing an ICE. Fix by using `try_to_bits(Size::from_bytes(1)).ok()` instead. r? BoxyUwU
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
close: #151625
close: #150983
also fix: #133966 (moved crashes test)