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
{{ message }}
Repository navigation
Compiler out of stack on generic base trait impl restricted to a derived trait #5988
use std::io;traitB{fnf(&self);}traitT:B{}structA;impl<U:T>BforU{fnf(&self){ io::println("Hey, I'm a T!");}}implTforA{}fnmain(){let a = A;let br = &a as&B;// let tr = &a as &T;// let br = tr as &B;
br.f();}
The inheritance of trait T from B seemingly triggers the recursion: without it, the program compiles and runs fine.
P.S. The commented-out lines illustrate what I was actually trying to achieve: upcasting a trait pointer to the base trait. That didn't work for other reasons.
use std::io;
trait B {
fn f(&self);
}
trait T : B { }
impl<U: T> B for U {
fn f(&self) { io::println("Hey, I'm a T!"); }
}
impl T for int { }
fn main() {
let _br = @0 as @B;
}
The stack overflow is a cycle between lookup_vtables, lookup_vtable, back to lookup_vtables, and each_bound_trait_and_supertraits.
Activity
bblum commentedon Jul 3, 2013
A little more minimal:
The stack overflow is a cycle between
lookup_vtables,lookup_vtable, back tolookup_vtables, andeach_bound_trait_and_supertraits.bblum commentedon Jul 3, 2013
nominating well-covered milestone
graydon commentedon Aug 22, 2013
accepted for production-ready milestone
pnkfelix commentedon Mar 13, 2014
just a bug, assigning P-low.
japaric commentedon Nov 2, 2014
Both examples compile on:
@nikomatsakis Can we close this? Or should we add a test (if it's not covered in the test suite already)?
alexcrichton commentedon Nov 3, 2014
Flagging as needstest (just in case)
nikomatsakis commentedon Nov 4, 2014
Wacky. I don't think there is a test specifically covering this scenario.
rollup merge of rust-lang#19780: jakub-/e-needstest
rollup merge of rust-lang#19780: jakub-/e-needstest
Auto merge of rust-lang#5988 - camelid:patch-2, r=ebroto
Auto merge of rust-lang#13216 - DesmondWillowbrook:move_format_string…
Merge rust-lang#5988