auto merge of #7886 : msullivan/rust/default-methods, r=pcwalton

This does a bunch of cleanup on the data structures for the trait system. (Unfortunately it doesn't remove `provided_method_sources`. Maybe later.)

It also changes how cross crate methods are handled, so that information about them is exported in metadata, instead of having the methods regenerated by every crate that imports an impl.

r? @nikomatsakis, maybe?
This commit is contained in:
bors 2013-07-20 07:28:36 -07:00
commit 3a1db2d1e6
20 changed files with 384 additions and 616 deletions

View file

@ -0,0 +1,17 @@
// aux-build:trait_default_method_xc_aux.rs
extern mod aux(name = "trait_default_method_xc_aux");
use aux::A;
pub struct a_struct { x: int }
impl A for a_struct {
fn f(&self) -> int { 10 }
}
// This function will need to get inlined, and badness may result.
pub fn welp<A>(x: A) -> A {
let a = a_struct { x: 0 };
a.g();
x
}

View file

@ -0,0 +1,25 @@
// xfail-fast
// aux-build:trait_default_method_xc_aux.rs
// aux-build:trait_default_method_xc_aux_2.rs
extern mod aux(name = "trait_default_method_xc_aux");
extern mod aux2(name = "trait_default_method_xc_aux_2");
use aux::A;
use aux2::{a_struct, welp};
fn main () {
let a = a_struct { x: 0 };
let b = a_struct { x: 1 };
assert_eq!(0i.g(), 10);
assert_eq!(a.g(), 10);
assert_eq!(a.h(), 11);
assert_eq!(b.g(), 10);
assert_eq!(b.h(), 11);
assert_eq!(A::lurr(&a, &b), 21);
welp(&0);
}