// 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)),
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),
});
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 {
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());
+++ /dev/null
-// 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; }
- }
-}
--- /dev/null
+// 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; }
+ }
+}
--- /dev/null
+// 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; }
+ }
+}
+++ /dev/null
-// 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);
-}
--- /dev/null
+// 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);
+}
--- /dev/null
+// 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);
+}