]> git.lizzy.rs Git - rust.git/commitdiff
Fix a bug in exporting trait implementations
authorAlex Crichton <alex@alexcrichton.com>
Tue, 3 Dec 2013 23:15:17 +0000 (15:15 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 3 Dec 2013 23:15:17 +0000 (15:15 -0800)
I used the wrong condition where I was looking for "is this method public or is
this implementation a trait" rather than what was being checked.

src/librustc/middle/privacy.rs
src/test/auxiliary/priv-impl-prim-ty.rs [new file with mode: 0644]
src/test/run-pass/priv-impl-prim-ty.rs [new file with mode: 0644]

index 2556397caf907467f0ae1662f3cf8d978f84b43e..b5d0fad7f95883e02c33dc5856d68d06f653d2a6 100644 (file)
@@ -243,7 +243,7 @@ fn visit_item(&mut self, item: @ast::item, _: ()) {
                             ast::sty_static => public_ty,
                             _ => true,
                         } && method.vis == ast::public;
-                        if meth_public || public_trait {
+                        if meth_public || tr.is_some() {
                             self.exported_items.insert(method.id);
                         }
                     }
diff --git a/src/test/auxiliary/priv-impl-prim-ty.rs b/src/test/auxiliary/priv-impl-prim-ty.rs
new file mode 100644 (file)
index 0000000..16d3ca8
--- /dev/null
@@ -0,0 +1,19 @@
+// Copyright 2013 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.
+
+trait A {
+    fn frob(&self);
+}
+
+impl A for int { fn frob(&self) {} }
+
+pub fn frob<T:A>(t: T) {
+    t.frob();
+}
diff --git a/src/test/run-pass/priv-impl-prim-ty.rs b/src/test/run-pass/priv-impl-prim-ty.rs
new file mode 100644 (file)
index 0000000..4439da4
--- /dev/null
@@ -0,0 +1,19 @@
+// Copyright 2013 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.
+
+// xfail-fast
+// aux-build:priv-impl-prim-ty.rs
+
+extern mod bar(name = "priv-impl-prim-ty");
+
+fn main() {
+    bar::frob(1i);
+
+}