Skip to content

Commit a969510

Browse files
committed
auto merge of #11245 : alexcrichton/rust/issue-11225, r=pcwalton
Commit messages are a little more descriptive.
2 parents b3b49d9 + aca1749 commit a969510

File tree

10 files changed

+160
-0
lines changed

10 files changed

+160
-0
lines changed

src/librustc/middle/privacy.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,23 @@ struct EmbargoVisitor<'a> {
167167
reexports: HashSet<ast::NodeId>,
168168
}
169169

170+
impl<'a> EmbargoVisitor<'a> {
171+
// There are checks inside of privacy which depend on knowing whether a
172+
// trait should be exported or not. The two current consumers of this are:
173+
//
174+
// 1. Should default methods of a trait be exported?
175+
// 2. Should the methods of an implementation of a trait be exported?
176+
//
177+
// The answer to both of these questions partly rely on whether the trait
178+
// itself is exported or not. If the trait is somehow exported, then the
179+
// answers to both questions must be yes. Right now this question involves
180+
// more analysis than is currently done in rustc, so we conservatively
181+
// answer "yes" so that all traits need to be exported.
182+
fn exported_trait(&self, _id: ast::NodeId) -> bool {
183+
true
184+
}
185+
}
186+
170187
impl<'a> Visitor<()> for EmbargoVisitor<'a> {
171188
fn visit_item(&mut self, item: @ast::item, _: ()) {
172189
let orig_all_pub = self.prev_exported;
@@ -175,6 +192,12 @@ impl<'a> Visitor<()> for EmbargoVisitor<'a> {
175192
// cannot have visibility qualifiers on them anyway
176193
ast::item_impl(..) | ast::item_foreign_mod(..) => {}
177194

195+
// Traits are a little special in that even if they themselves are
196+
// not public they may still be exported.
197+
ast::item_trait(..) => {
198+
self.prev_exported = self.exported_trait(item.id);
199+
}
200+
178201
// Private by default, hence we only retain the "public chain" if
179202
// `pub` is explicitly listed.
180203
_ => {

src/libstd/io/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Some examples of obvious things you might want to do
5353
# let _g = ::std::io::ignore_io_error();
5454
let mut file = File::create(&Path::new("message.txt"));
5555
file.write(bytes!("hello, file!\n"));
56+
# drop(file);
57+
# ::std::io::fs::unlink(&Path::new("message.txt"));
5658
```
5759
5860
* Iterate over the lines of a file

src/libstd/local_data.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ pub type Key<T> = &'static KeyValue<T>;
6262
#[allow(missing_doc)]
6363
pub enum KeyValue<T> { Key }
6464

65+
#[allow(missing_doc)]
6566
trait LocalData {}
6667
impl<T: 'static> LocalData for T {}
6768

src/test/auxiliary/issue-11224.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
#[deny(dead_code)];
12+
13+
mod inner {
14+
pub trait Trait {
15+
fn f(&self) { f(); }
16+
}
17+
18+
impl Trait for int {}
19+
20+
fn f() {}
21+
}
22+
23+
pub fn foo() {
24+
let a = &1 as &inner::Trait;
25+
a.f();
26+
}

src/test/auxiliary/issue-11225-1.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
mod inner {
12+
pub trait Trait {
13+
fn f(&self) { f(); }
14+
}
15+
16+
impl Trait for int {}
17+
18+
fn f() {}
19+
}
20+
21+
pub fn foo<T: inner::Trait>(t: T) {
22+
t.f();
23+
}

src/test/auxiliary/issue-11225-2.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
use inner::Trait;
12+
13+
mod inner {
14+
pub struct Foo;
15+
pub trait Trait {
16+
fn f(&self);
17+
}
18+
19+
impl Trait for Foo {
20+
fn f(&self) { }
21+
}
22+
}
23+
24+
pub trait Outer {
25+
fn foo<T: Trait>(&self, t: T) { t.f(); }
26+
}
27+
28+
impl Outer for int {}
29+
30+
pub fn foo<T: Outer>(t: T) {
31+
t.foo(inner::Foo);
32+
}

src/test/compile-fail/lint-missing-doc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pub trait A {
5050
/// dox
5151
fn foo_with_impl() {}
5252
}
53+
#[allow(missing_doc)]
5354
trait B {
5455
fn foo();
5556
fn foo_with_impl() {}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
// aux-build:issue-11224.rs
12+
// xfail-fast
13+
14+
extern mod unused = "issue-11224";
15+
16+
fn main() {}

src/test/run-pass/issue-11225-1.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
// aux-build:issue-11225-1.rs
12+
// xfail-fast
13+
14+
extern mod foo = "issue-11225-1";
15+
16+
fn main() {
17+
foo::foo(1);
18+
}

src/test/run-pass/issue-11225-2.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
// aux-build:issue-11225-2.rs
12+
// xfail-fast
13+
14+
extern mod foo = "issue-11225-2";
15+
16+
fn main() {
17+
foo::foo(1);
18+
}

0 commit comments

Comments
 (0)