about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-07-20 07:28:36 -0700
committerbors <bors@rust-lang.org>2013-07-20 07:28:36 -0700
commit3a1db2d1e631feede472396fced1806dfd3cf677 (patch)
tree22cdb1e335e8b20c45ebdb994e43260cdb0bec1d /src/test
parentec53efa64dcd449c78381b680a7184d9876d4f29 (diff)
parent002bfd796648547839d0f3740308995b4a926f50 (diff)
downloadrust-3a1db2d1e631feede472396fced1806dfd3cf677.tar.gz
rust-3a1db2d1e631feede472396fced1806dfd3cf677.zip
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?
Diffstat (limited to 'src/test')
-rw-r--r--src/test/auxiliary/trait_default_method_xc_aux_2.rs17
-rw-r--r--src/test/run-pass/trait-default-method-xc-2.rs25
2 files changed, 42 insertions, 0 deletions
diff --git a/src/test/auxiliary/trait_default_method_xc_aux_2.rs b/src/test/auxiliary/trait_default_method_xc_aux_2.rs
new file mode 100644
index 00000000000..2d4f539f82b
--- /dev/null
+++ b/src/test/auxiliary/trait_default_method_xc_aux_2.rs
@@ -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
+}
diff --git a/src/test/run-pass/trait-default-method-xc-2.rs b/src/test/run-pass/trait-default-method-xc-2.rs
new file mode 100644
index 00000000000..1dad5d23b88
--- /dev/null
+++ b/src/test/run-pass/trait-default-method-xc-2.rs
@@ -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);
+}