Skip to content

Commit 7a2415f

Browse files
committed
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.
1 parent 69186ef commit 7a2415f

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

Diff for: src/librustc/middle/privacy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ impl<'self> Visitor<()> for EmbargoVisitor<'self> {
243243
ast::sty_static => public_ty,
244244
_ => true,
245245
} && method.vis == ast::public;
246-
if meth_public || public_trait {
246+
if meth_public || tr.is_some() {
247247
self.exported_items.insert(method.id);
248248
}
249249
}

Diff for: src/test/auxiliary/priv-impl-prim-ty.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
trait A {
12+
fn frob(&self);
13+
}
14+
15+
impl A for int { fn frob(&self) {} }
16+
17+
pub fn frob<T:A>(t: T) {
18+
t.frob();
19+
}

Diff for: src/test/run-pass/priv-impl-prim-ty.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// xfail-fast
12+
// aux-build:priv-impl-prim-ty.rs
13+
14+
extern mod bar(name = "priv-impl-prim-ty");
15+
16+
fn main() {
17+
bar::frob(1i);
18+
19+
}

0 commit comments

Comments
 (0)