diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-12-03 15:15:17 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-12-03 15:15:17 -0800 |
| commit | 7a2415f0e43efcbe398d883c32b53bab77986cab (patch) | |
| tree | 787e5e86bf46a318325b6970998ec00c19e94f3a | |
| parent | 69186efc199d48afca9427e448363212b0a59454 (diff) | |
| download | rust-7a2415f0e43efcbe398d883c32b53bab77986cab.tar.gz rust-7a2415f0e43efcbe398d883c32b53bab77986cab.zip | |
Fix a bug in exporting trait implementations
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.
| -rw-r--r-- | src/librustc/middle/privacy.rs | 2 | ||||
| -rw-r--r-- | src/test/auxiliary/priv-impl-prim-ty.rs | 19 | ||||
| -rw-r--r-- | src/test/run-pass/priv-impl-prim-ty.rs | 19 |
3 files changed, 39 insertions, 1 deletions
diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 2556397caf9..b5d0fad7f95 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -243,7 +243,7 @@ impl<'self> Visitor<()> for EmbargoVisitor<'self> { 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 index 00000000000..16d3ca8fa64 --- /dev/null +++ b/src/test/auxiliary/priv-impl-prim-ty.rs @@ -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 index 00000000000..4439da4f6f5 --- /dev/null +++ b/src/test/run-pass/priv-impl-prim-ty.rs @@ -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); + +} |
