Skip to content

Commit f4f95eb

Browse files
author
Eljay
committed
Remove unnecessary trait accessibility check.
1 parent fb5de8c commit f4f95eb

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

src/librustc_privacy/lib.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -847,12 +847,8 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
847847
ty::ImplContainer(_) => {
848848
self.check_static_method(span, method_def_id, name)
849849
}
850-
// Trait methods are always all public. The only controlling factor
851-
// is whether the trait itself is accessible or not.
852-
ty::TraitContainer(trait_def_id) => {
853-
self.report_error(self.ensure_public(span, trait_def_id,
854-
None, "source trait"));
855-
}
850+
// Trait methods are always accessible if the trait is in scope.
851+
ty::TraitContainer(_) => {}
856852
}
857853
}
858854
}

src/test/run-pass/issue-16264.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2015 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+
use outer::Foo;
12+
13+
mod outer {
14+
pub use self::inner::Foo;
15+
16+
mod inner {
17+
pub trait Foo {
18+
fn bar(&self) {}
19+
}
20+
impl Foo for i32 {}
21+
}
22+
}
23+
24+
fn main() {
25+
let x: i32 = 0;
26+
x.bar();
27+
}

0 commit comments

Comments
 (0)