Skip to content

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

Merged
merged 1 commit into from
Sep 26, 2013

Conversation

bmaxa
Copy link

@bmaxa bmaxa commented Sep 24, 2013

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

@@ -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,
Copy link
Member

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?

@alexcrichton
Copy link
Member

Thanks for the fix! If you wouldn't mind, it'd be nice to have these things done as well:

  • This should have a test in the src/test/run-pass test suite to ensure that this never breaks again
  • Could you rebase all your commits into just one?
  • Could you expand the message in the commit itself? Github recognizes the magical string Closes #XXXX, I'm not sure if it will recognize the URL. A short description of what you fixed and how you fixed it in the commit message would also be nice.

Thanks again for fixing this!

@emberian
Copy link
Member

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

@alexcrichton
Copy link
Member

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.

@bmaxa
Copy link
Author

bmaxa commented Sep 25, 2013

Ah , I have messed things so it seems. Need to do it again ;(

@bmaxa
Copy link
Author

bmaxa commented Sep 25, 2013

I hope now everything is ok.

@bmaxa
Copy link
Author

bmaxa commented Sep 25, 2013

Added spaces for ->

@alexcrichton
Copy link
Member

The problem is just with the windows test runner, the test function must be pub fn main instead of just fn main

    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.
@bmaxa
Copy link
Author

bmaxa commented Sep 26, 2013

Added pub fn main

bors added a commit that referenced this pull request Sep 26, 2013
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
@bors bors closed this Sep 26, 2013
@bors bors merged commit 56d415a into rust-lang:master Sep 26, 2013
djkoloski pushed a commit to djkoloski/rust that referenced this pull request Sep 21, 2022
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants