gccrs: This is an utterly insane rustc shim needed for stdarch - #4889
Open
philberty wants to merge 1 commit into
Open
gccrs: This is an utterly insane rustc shim needed for stdarch#4889philberty wants to merge 1 commit into
philberty wants to merge 1 commit into
Conversation
This doesnt fully implement the legacy const generics attribute but its
the starting point.
What we actually need to do is understand:
#[rustc_legacy_const_generics(1)]
fn foo<const N: usize>(x: i32) -> i32 {
x + N as i32
}
fn main() {
let a = foo(10, 3);
}
So you can see the call to foo has a 2nd param but its not a real 2nd param
its meant to be turned into:
foo::<3>(10)
Honestly this is just silly they probably implemented a bit of const
generics wanted to use it in core and put this work around in to get away
with it. Dumb.
Addresses #3868
gcc/rust/ChangeLog:
* typecheck/rust-casts.cc (TypeCastRules::cast_rules): fix bad const cast
* util/rust-attribute-values.h: add attribute
* util/rust-attributes.cc: likewise
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
CohenArthur
approved these changes
Sep 11, 2026
CohenArthur
left a comment
Member
There was a problem hiding this comment.
code LGTM, just the issue number in the commit and it's all good
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.
This doesnt fully implement the legacy const generics attribute but its the starting point.
What we actually need to do is understand:
So you can see the call to foo has a 2nd param but its not a real 2nd param its meant to be turned into:
Honestly this is just silly they probably implemented a bit of const generics wanted to use it in core and put this work around in to get away with it. Dumb.
Addresses #3868
gcc/rust/ChangeLog: