-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Type aliases can be silently shadowed #20702
Comments
Ping #18101? (this worked with old closures) |
It looks like you're shadowing "CbClosure" in the "go" function so the two transmutes have different operands: the callback transmute converts from a reference to any type implementing the trait "Fn<(&'s i32,), i32> + 's", to VPtr, while the callback in "go" converts from VPtr to a reference to any Sized type (the Sized bound is implicit for template arguments, unless you opt out). The important point being that the Fn trait does not imply Sized, and only references to Sized types are implemented as "normal" pointers like VPtr: references to types which are not Sized are implemented as fat pointers, and transmuting from a fat pointer to a VPtr will fail because they are different sizes. |
Ouch, that'll teach me to blindly copy and paste. Worth a warning I feel. |
Changed the title of the issue. |
Going off track of the issue here somewhat: |
@aidanhs Yes, that sounds correct. |
I don't think so: struct T;
impl T { fn method(&self) {} }
type U = T;
fn foo<U>(x: U) {
x.method();
}
fn main() {}
|
Visiting for triage: this is still an issue |
Triage: no change |
I don't see an issue here. I agree, it may be confusing, but not more confusing than let a = 10;
{
let a = 11;
println!("{}", a); // WHY DOES IT PRINT 11, I SAID `a = 10` PREVIOUSLY?
} |
Yes, I've cooled a bit on this. I think in general hints about shadowing could be better (where the compiler detects that removing a shadow could fix something) but that sounds like a whole new set of diagnostics. |
Closing as per #20702 (comment)
For these diagnostics to work with |
check.rs
extlib.c
But if you comment out the whole unsafe block in
callback
...despite there being a conversion the other way in
go
. Surely these type cannot vary in size?To compound my confusion, you can add the line below to after
let data: [...]
ingo
and it will compile - this is exactly the same line as incallback
, with a different variable name.The text was updated successfully, but these errors were encountered: