-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can not use argument impl Trait in type alias #139055
Comments
Yeep, that's the fragile visitors in ast_passes. In this case, we won't reset the context on AnonConst. |
I've already reported the general issue here #119924 in the past incl. your specific issue #119924 (comment) |
I guess you found this by fuzzing? If not, I can say I never thought sb. would stumble upon this for real ^^ |
I actually stumbled into this while developing a macro that defines a new type wherever you are supposed to provide a type. trait Sneak {
type Out;
}
macro_rules! new_type {
($($fields:tt)*) => {
<[(); {
struct Bar {$($fields)*}
impl Sneak for [(); line!() as usize] {
type Out = Bar;
}
line!() as usize
}] as Sneak>::Out
};
}
type Test = new_type!(x: u32);
type Test2 = new_type!(x: String);
fn test(val: Test) -> Test2 {
let Test { x } = val;
Test2 { x: "hi".to_owned() }
} P.S. I would appreciate anyone who uses this trick to credit me for the idea :P |
Nice! I'll send a fix shortly! |
Rollup merge of rust-lang#139063 - fmease:fix-tait-atpit-gating, r=oli-obk Fix TAIT & ATPIT feature gating in the presence of anon consts Fixes rust-lang#139055 (rust-lang#119924 (comment)). r? oli-obk or anybody else
I tried this code:
I expect this to compile, but instead i get this error.
Meta
Bug also reproduces on nightly.
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: