]> git.lizzy.rs Git - rust.git/commitdiff
Rebasing and review changes
authorNick Cameron <ncameron@mozilla.com>
Thu, 30 Oct 2014 03:33:37 +0000 (16:33 +1300)
committerNick Cameron <ncameron@mozilla.com>
Fri, 31 Oct 2014 22:05:12 +0000 (11:05 +1300)
src/librustc/metadata/decoder.rs
src/librustc/metadata/encoder.rs
src/test/auxiliary/method_self_arg.rs [deleted file]
src/test/auxiliary/method_self_arg1.rs [new file with mode: 0644]
src/test/auxiliary/method_self_arg2.rs [new file with mode: 0644]
src/test/run-pass/method-self-arg-aux.rs [deleted file]
src/test/run-pass/method-self-arg-aux1.rs [new file with mode: 0644]
src/test/run-pass/method-self-arg-aux2.rs [new file with mode: 0644]

index 5403f91645a9b1732fffd4185165a70bc911a29a..213f32a1d182c5759724aa98724ef374b35675d9 100644 (file)
@@ -327,7 +327,7 @@ fn item_to_def_like(item: rbml::Doc, did: ast::DefId, cnum: ast::CrateNum)
                 // We don't bother to get encode/decode the trait id, we don't need it.
                 Method => DlDef(def::DefMethod(did, None, provenance)),
                 StaticMethod => DlDef(def::DefStaticMethod(did, provenance)),
-                _ => fail!()
+                _ => panic!()
             }
         }
         Type | ForeignType => DlDef(def::DefTy(did, false)),
@@ -931,7 +931,7 @@ pub fn get_methods_if_impl(intr: Rc<IdentInterner>,
         match family {
             StaticMethod | Method => {
                 impl_methods.push(MethodInfo {
-                    ident: item_name(&*intr, impl_method_doc),
+                    name: item_name(&*intr, impl_method_doc),
                     def_id: item_def_id(impl_method_doc, cdata),
                     vis: item_visibility(impl_method_doc),
                 });
index f3f802f35baea47ac16d5b668c9a2823526b2927..a5d3cc1f12c29cc6118abcf793f91697d988d83b 100644 (file)
@@ -1418,7 +1418,7 @@ fn add_to_index(item: &Item, rbml_w: &Encoder,
             encode_parent_sort(rbml_w, 't');
 
             let trait_item = &ms[i];
-            let foo = |rbml_w: &mut Encoder| {
+            let encode_trait_item = |rbml_w: &mut Encoder| {
                 // If this is a static method, we've already
                 // encoded this.
                 if is_nonstatic_method {
@@ -1431,14 +1431,14 @@ fn add_to_index(item: &Item, rbml_w: &Encoder,
             match trait_item {
                 &RequiredMethod(ref m) => {
                     encode_attributes(rbml_w, m.attrs.as_slice());
-                    foo(rbml_w);
+                    encode_trait_item(rbml_w);
                     encode_item_sort(rbml_w, 'r');
                     encode_method_argument_names(rbml_w, &*m.decl);
                 }
 
                 &ProvidedMethod(ref m) => {
                     encode_attributes(rbml_w, m.attrs.as_slice());
-                    foo(rbml_w);
+                    encode_trait_item(rbml_w);
                     encode_item_sort(rbml_w, 'p');
                     encode_inlined_item(ecx, rbml_w, IITraitItemRef(def_id, trait_item));
                     encode_method_argument_names(rbml_w, &*m.pe_fn_decl());
diff --git a/src/test/auxiliary/method_self_arg.rs b/src/test/auxiliary/method_self_arg.rs
deleted file mode 100644 (file)
index 8e48ded..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![crate_type = "lib"]
-
-static mut COUNT: u64 = 1;
-
-pub fn get_count() -> u64 { unsafe { COUNT } }
-pub fn reset_count() { unsafe { COUNT = 1; } }
-
-pub struct Foo;
-
-impl Foo {
-    pub fn foo(self, x: &Foo) {
-        unsafe { COUNT *= 2; }
-        // Test internal call.
-        Foo::bar(&self);
-        Foo::bar(x);
-
-        Foo::baz(self);
-        Foo::baz(*x);
-
-        Foo::qux(box self);
-        Foo::qux(box *x);
-    }
-
-    pub fn bar(&self) {
-        unsafe { COUNT *= 3; }
-    }
-
-    pub fn baz(self) {
-        unsafe { COUNT *= 5; }
-    }
-
-    pub fn qux(self: Box<Foo>) {
-        unsafe { COUNT *= 7; }
-    }
-
-    pub fn run_trait(self) {
-        unsafe { COUNT *= 17; }
-        // Test internal call.
-        Bar::foo1(&self);
-        Bar::foo2(self);
-        Bar::foo3(box self);
-
-        Bar::bar1(&self);
-        Bar::bar2(self);
-        Bar::bar3(box self);
-    }
-}
-
-pub trait Bar {
-    fn foo1(&self);
-    fn foo2(self);
-    fn foo3(self: Box<Self>);
-
-    fn bar1(&self) {
-        unsafe { COUNT *= 7; }
-    }
-    fn bar2(self) {
-        unsafe { COUNT *= 11; }
-    }
-    fn bar3(self: Box<Self>) {
-        unsafe { COUNT *= 13; }
-    }
-}
-
-impl Bar for Foo {
-    fn foo1(&self) {
-        unsafe { COUNT *= 2; }
-    }
-
-    fn foo2(self) {
-        unsafe { COUNT *= 3; }
-    }
-
-    fn foo3(self: Box<Foo>) {
-        unsafe { COUNT *= 5; }
-    }
-}
diff --git a/src/test/auxiliary/method_self_arg1.rs b/src/test/auxiliary/method_self_arg1.rs
new file mode 100644 (file)
index 0000000..d022229
--- /dev/null
@@ -0,0 +1,44 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![crate_type = "lib"]
+
+static mut COUNT: u64 = 1;
+
+pub fn get_count() -> u64 { unsafe { COUNT } }
+
+pub struct Foo;
+
+impl Foo {
+    pub fn foo(self, x: &Foo) {
+        unsafe { COUNT *= 2; }
+        // Test internal call.
+        Foo::bar(&self);
+        Foo::bar(x);
+
+        Foo::baz(self);
+        Foo::baz(*x);
+
+        Foo::qux(box self);
+        Foo::qux(box *x);
+    }
+
+    pub fn bar(&self) {
+        unsafe { COUNT *= 3; }
+    }
+
+    pub fn baz(self) {
+        unsafe { COUNT *= 5; }
+    }
+
+    pub fn qux(self: Box<Foo>) {
+        unsafe { COUNT *= 7; }
+    }
+}
diff --git a/src/test/auxiliary/method_self_arg2.rs b/src/test/auxiliary/method_self_arg2.rs
new file mode 100644 (file)
index 0000000..99eb665
--- /dev/null
@@ -0,0 +1,61 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![crate_type = "lib"]
+
+static mut COUNT: u64 = 1;
+
+pub fn get_count() -> u64 { unsafe { COUNT } }
+
+pub struct Foo;
+
+impl Foo {
+    pub fn run_trait(self) {
+        unsafe { COUNT *= 17; }
+        // Test internal call.
+        Bar::foo1(&self);
+        Bar::foo2(self);
+        Bar::foo3(box self);
+
+        Bar::bar1(&self);
+        Bar::bar2(self);
+        Bar::bar3(box self);
+    }
+}
+
+pub trait Bar {
+    fn foo1(&self);
+    fn foo2(self);
+    fn foo3(self: Box<Self>);
+
+    fn bar1(&self) {
+        unsafe { COUNT *= 7; }
+    }
+    fn bar2(self) {
+        unsafe { COUNT *= 11; }
+    }
+    fn bar3(self: Box<Self>) {
+        unsafe { COUNT *= 13; }
+    }
+}
+
+impl Bar for Foo {
+    fn foo1(&self) {
+        unsafe { COUNT *= 2; }
+    }
+
+    fn foo2(self) {
+        unsafe { COUNT *= 3; }
+    }
+
+    fn foo3(self: Box<Foo>) {
+        unsafe { COUNT *= 5; }
+    }
+}
diff --git a/src/test/run-pass/method-self-arg-aux.rs b/src/test/run-pass/method-self-arg-aux.rs
deleted file mode 100644 (file)
index 9c08185..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Test method calls with self as an argument (cross-crate)
-
-// aux-build:method_self_arg.rs
-extern crate method_self_arg;
-use method_self_arg::{Foo, Bar};
-
-fn main() {
-    let x = Foo;
-    // Test external call.
-    Foo::bar(&x);
-    Foo::baz(x);
-    Foo::qux(box x);
-
-    x.foo(&x);
-
-    assert!(method_self_arg::get_count() == 2u64*3*3*3*5*5*5*7*7*7);
-
-    method_self_arg::reset_count();
-    // Test external call.
-    Bar::foo1(&x);
-    Bar::foo2(x);
-    Bar::foo3(box x);
-
-    Bar::bar1(&x);
-    Bar::bar2(x);
-    Bar::bar3(box x);
-
-    x.run_trait();
-
-    println!("{}, {}", method_self_arg::get_count(), 2u64*2*3*3*5*5*7*7*11*11*13*13*17);
-    assert!(method_self_arg::get_count() == 2u64*2*3*3*5*5*7*7*11*11*13*13*17);
-}
diff --git a/src/test/run-pass/method-self-arg-aux1.rs b/src/test/run-pass/method-self-arg-aux1.rs
new file mode 100644 (file)
index 0000000..d4a0d51
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test method calls with self as an argument (cross-crate)
+
+// aux-build:method_self_arg1.rs
+extern crate method_self_arg1;
+use method_self_arg1::Foo;
+
+fn main() {
+    let x = Foo;
+    // Test external call.
+    Foo::bar(&x);
+    Foo::baz(x);
+    Foo::qux(box x);
+
+    x.foo(&x);
+
+    assert!(method_self_arg1::get_count() == 2u64*3*3*3*5*5*5*7*7*7);
+}
diff --git a/src/test/run-pass/method-self-arg-aux2.rs b/src/test/run-pass/method-self-arg-aux2.rs
new file mode 100644 (file)
index 0000000..b94f1ae
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test method calls with self as an argument (cross-crate)
+
+// aux-build:method_self_arg2.rs
+extern crate method_self_arg2;
+use method_self_arg2::{Foo, Bar};
+
+fn main() {
+    let x = Foo;
+    // Test external call.
+    Bar::foo1(&x);
+    Bar::foo2(x);
+    Bar::foo3(box x);
+
+    Bar::bar1(&x);
+    Bar::bar2(x);
+    Bar::bar3(box x);
+
+    x.run_trait();
+
+    assert!(method_self_arg2::get_count() == 2u64*2*3*3*5*5*7*7*11*11*13*13*17);
+}