From 7a2415f0e43efcbe398d883c32b53bab77986cab Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 3 Dec 2013 15:15:17 -0800 Subject: [PATCH] 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. --- src/librustc/middle/privacy.rs | 2 +- src/test/auxiliary/priv-impl-prim-ty.rs | 19 +++++++++++++++++++ src/test/run-pass/priv-impl-prim-ty.rs | 19 +++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/test/auxiliary/priv-impl-prim-ty.rs create mode 100644 src/test/run-pass/priv-impl-prim-ty.rs 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 or the MIT license +// , 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: 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 or the MIT license +// , 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); + +}