-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Segfault related to trait bounds #9008
Comments
Note that the segfault is in a different place than #8762:
(and so on, for a zillion frames) |
I just realized that the following is bogus (since I won't be able to impl any other Shape):
(but it's still bad that the compiler crashes, of course) |
Updated example - s/float/f32/ Compiler error message task 'rustc' has overflowed its stack trait Shape {
fn n_sides(&self) -> uint;
}
trait Quadrilateral : Shape {
fn sides(&self) -> ~[f32, ..4];
}
impl<T:Quadrilateral> Shape for T {
fn n_sides(&self) -> uint {
return 4;
}
}
trait Rectangle : Quadrilateral {
//only rectangles have equal-sided diagonals
fn diagonal(&self) -> f32 {
let sides = self.sides();
return (sides[0] * sides[0] + sides[1] * sides[1]).sqrt();
}
}
struct SquareImpl {
side : f32
}
impl Quadrilateral for SquareImpl {
fn sides(&self) -> ~[f32, ..4] {
let sides : ~[f32, ..4] = ~([self.side, self.side, self.side, self.side]);
return sides;
}
}
impl Rectangle for SquareImpl {
//Rectangle's diagonal is implemented by Rectangle
}
fn main() {} |
This issue has since been fixed, and I imagine it was probably due to some random change in the internals over the years, so we probably don't need a test for this :) |
…ffate Use `RefCell` in `needless_return` tests changelog: none The stdio locks no longer fail to compile if the `return` is removed due to them now being `'static` (rust-lang#9008)
I am saying "related to trait bounds" because I have managed to get this in a few different ways, all of which involved trait bounds. But since I don't fully understand how traits work yet, I'm not really sure what is going on. Here's a few examples:
This one spits out a zillion of these before dying:
segme.rs:14:0: 14:17 error: expected Op<S,S>, but found Op<int,S> (expected struct S but found int)
segme.rs:14 impl Bar for S {}
This one just segfaults:
The text was updated successfully, but these errors were encountered: