-
Notifications
You must be signed in to change notification settings - Fork 13.3k
fix for https://github.com/mozilla/rust/issues/9394 #9464
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
Conversation
@@ -372,7 +372,7 @@ impl<'self> LookupContext<'self> { | |||
// to a trait and its supertraits. | |||
fn get_method_index(&self, | |||
trait_ref: @TraitRef, | |||
subtrait_id: ast::DefId, | |||
subtrait: @TraitRef, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you indent this like it was?
Thanks for the fix! If you wouldn't mind, it'd be nice to have these things done as well:
Thanks again for fixing this! |
This needs to be rebased to not have a merge commit, and the formatting of the testcase is wrong. We use 4-space tabs. See https://github.com/mozilla/rust/wiki/Note-style-guide |
Also feel free to comment on the pull request when you update it. Sadly github doesn't send out notifications for rebasings (or maybe thankfully...), and it's much more likely to pick up changes through notifications than general poking at the queue. |
Ah , I have messed things so it seems. Need to do it again ;( |
I hope now everything is ok. |
Added spaces for -> |
The problem is just with the windows test runner, the test function must be |
This solves problem of incorrect indexing into vtable when method from super trait was called through pointer to derived trait. Problem was that offset of super trait vtables was not calculated at all. Now it works, correct offset is calculated by traversing all super traits up to super trait where method belongs. That is how it is intended to work.
Added pub fn main |
I have tried this fix and it seems to work either with single or multiple trait inheritance. trait Base:Base2 + Base3{ fn foo(&self); } trait Base2 { fn baz(&self); } trait Base3{ fn root(&self); } trait Super: Base{ fn bar(&self); } struct X; impl Base for X { fn foo(&self) { println("base foo"); } } impl Base2 for X { fn baz(&self) { println("base2 baz"); } } impl Base3 for X { fn root(&self) { println("base3 root"); } } impl Super for X { fn bar(&self) { println("super bar"); } } fn main() { let n = X; let s = &n as &Super; s.bar(); s.foo(); // super bar s.baz(); s.root(); } bmaxa@maxa:~/examples/rust$ rustc error.rs bmaxa@maxa:~/examples/rust$ ./error super bar base foo base2 baz base3 root
Don't panic on invalid shift while constfolding Instead of panicking on invalid shifts while folding constants we simply give up. Fixes rust-lang#9463 Notice the "attempt to shift right by `1316134912_u32`", which seems weird. AFAICS it comes from rustc itself. changelog: none
I have tried this fix and it seems to work either with single or multiple trait inheritance.
trait Base:Base2 + Base3{
fn foo(&self);
}
trait Base2 {
fn baz(&self);
}
trait Base3{
fn root(&self);
}
trait Super: Base{
fn bar(&self);
}
struct X;
impl Base for X {
fn foo(&self) {
println("base foo");
}
}
impl Base2 for X {
fn baz(&self) {
println("base2 baz");
}
}
impl Base3 for X {
fn root(&self) {
println("base3 root");
}
}
impl Super for X {
fn bar(&self) {
println("super bar");
}
}
fn main() {
let n = X;
let s = &n as &Super;
s.bar();
s.foo(); // super bar
s.baz();
s.root();
}
bmaxa@maxa:
/examples/rust$ rustc error.rs/examples/rust$ ./errorbmaxa@maxa:
super bar
base foo
base2 baz
base3 root