You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fnid<'c,'b>(f:&'c&'bFn(&i32)) -> &'c&'bFn(&'statici32){
f
}fnmain(){let f:&Fn(&i32) = &|x| {};id(&f);}
gives the following error on beta (1.24) and nightly (1.25 2018-01-17). It compiles successfully on stable.
Function return type does not match operand type of return inst!
ret { %"core::ops::function::Fn<(&i32), Output=()>.0"*, {}* }* %3, !dbg !36
{ %"core::ops::function::Fn<(&i32), Output=()>"*, {}* }*LLVM ERROR: Broken function found, compilation aborted!
Mentioning @michaelwoerister@eddyb@nagisa who touched librustc_trans recently (disclaimer: I don't know if that's where this problem would come from but it sounds relevant).
cc @pnkfelix@nikomatsakis Is this one of those "HRTB lifetimes in rustc_trans causes distinct LLVM types" bugs? It seems like there's two distinct types for the unsized pointee of Fn(&i32).
@dtolnay I introduced it for this specific case, yeah, but it's a long-standing bug AFAICT (#36744).
We have some hacks when doing stores and calls, at least, but it's not ideal.
I'm hoping @nikomatsakis can confirm and knows of a better direction for #36744.
So I agree with @eddyb that it's the same bug. I think my preferred longer term fix is to change our rules around subtyping and higher-ranked regions -- but in the short term, I suspect we need some bit casts.
This is not a new regression in its general case, only specifically trait objects outside of structs:
structNewtype<T>(T);fnid<'c,'b>(f:&'cNewtype<&'bFn(&i32)>) -> &'cNewtype<&'bFn(&'statici32)>{
f
}fnmain(){let f:&Fn(&i32) = &|x| {};id(&Newtype(f));}
This fails with the LLVM error in 1.0 through 1.22, according to godbolt. Somehow, #45225 (presumably) fixed that and introduced a different form of it.
Activity
dtolnay commentedon Jan 21, 2018
Mentioning @michaelwoerister @eddyb @nagisa who touched librustc_trans recently (disclaimer: I don't know if that's where this problem would come from but it sounds relevant).
eddyb commentedon Jan 21, 2018
cc @pnkfelix @nikomatsakis Is this one of those "HRTB lifetimes in
rustc_transcauses distinct LLVM types" bugs? It seems like there's two distinct types for the unsized pointee ofFn(&i32).nikomatsakis commentedon Jan 25, 2018
triage: P-high
We need to figure this out.
ritiek commentedon Jan 27, 2018
So, I was testing nightly toolchains and this has been a problem since:
The code compiles OK with previous day's nightly:
dtolnay commentedon Jan 27, 2018
5041b3b...33374fa then, almost certainly something in #45225. @eddyb
eddyb commentedon Jan 27, 2018
@dtolnay I introduced it for this specific case, yeah, but it's a long-standing bug AFAICT (#36744).
We have some hacks when doing stores and calls, at least, but it's not ideal.
I'm hoping @nikomatsakis can confirm and knows of a better direction for #36744.
nikomatsakis commentedon Jan 30, 2018
So I agree with @eddyb that it's the same bug. I think my preferred longer term fix is to change our rules around subtyping and higher-ranked regions -- but in the short term, I suspect we need some bit casts.
eddyb commentedon Jan 30, 2018
This is not a new regression in its general case, only specifically trait objects outside of structs:
This fails with the LLVM error in 1.0 through 1.22, according to godbolt.
Somehow, #45225 (presumably) fixed that and introduced a different form of it.
Rollup merge of rust-lang#47891 - eddyb:issue-47638, r=nikomatsakis