Skip to content

Commit 578faa6

Browse files
committed
---
yaml --- r: 148395 b: refs/heads/try2 c: d0f6ef0 h: refs/heads/master i: 148393: 996590e 148391: 2bf2a7f v: v3
1 parent f79290f commit 578faa6

File tree

7 files changed

+79
-7
lines changed

7 files changed

+79
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 27843133448df3315af1a07dc6700d7754709a97
8+
refs/heads/try2: d0f6ef080bb69ce4370c04c92cc92b9a860e5725
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/front/std_inject.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl fold::Folder for StandardLibraryInjector {
7373
with_version("std"),
7474
ast::DUMMY_NODE_ID),
7575
attrs: ~[],
76-
vis: ast::Private,
76+
vis: ast::Inherited,
7777
span: DUMMY_SP
7878
}];
7979

@@ -83,15 +83,15 @@ impl fold::Folder for StandardLibraryInjector {
8383
with_version("green"),
8484
ast::DUMMY_NODE_ID),
8585
attrs: ~[],
86-
vis: ast::Private,
86+
vis: ast::Inherited,
8787
span: DUMMY_SP
8888
});
8989
vis.push(ast::ViewItem {
9090
node: ast::ViewItemExternMod(self.sess.ident_of("rustuv"),
9191
with_version("rustuv"),
9292
ast::DUMMY_NODE_ID),
9393
attrs: ~[],
94-
vis: ast::Private,
94+
vis: ast::Inherited,
9595
span: DUMMY_SP
9696
});
9797
}
@@ -147,7 +147,7 @@ impl fold::Folder for StandardLibraryInjector {
147147
let vi2 = ast::ViewItem {
148148
node: ast::ViewItemUse(~[vp]),
149149
attrs: ~[],
150-
vis: ast::Private,
150+
vis: ast::Inherited,
151151
span: DUMMY_SP,
152152
};
153153

branches/try2/src/librustc/front/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ fn mk_std(cx: &TestCtxt) -> ast::ViewItem {
301301
ast::ViewItem {
302302
node: vi,
303303
attrs: ~[],
304-
vis: ast::Public,
304+
vis: ast::Inherited,
305305
span: DUMMY_SP
306306
}
307307
}

branches/try2/src/librustc/middle/privacy.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,32 @@ impl Visitor<()> for SanePrivacyVisitor {
839839
visit::walk_fn(self, fk, fd, b, s, n, ());
840840
self.in_fn = orig_in_fn;
841841
}
842+
843+
fn visit_view_item(&mut self, i: &ast::ViewItem, _: ()) {
844+
match i.vis {
845+
ast::Inherited => {}
846+
ast::Private => {
847+
self.tcx.sess.span_err(i.span, "unnecessary visibility \
848+
qualifier");
849+
}
850+
ast::Public => {
851+
if self.in_fn {
852+
self.tcx.sess.span_err(i.span, "unnecessary `pub`, imports \
853+
in functions are never \
854+
reachable");
855+
} else {
856+
match i.node {
857+
ast::ViewItemExternMod(..) => {
858+
self.tcx.sess.span_err(i.span, "`pub` visibility \
859+
is not allowed");
860+
}
861+
_ => {}
862+
}
863+
}
864+
}
865+
}
866+
visit::walk_view_item(self, i, ());
867+
}
842868
}
843869

844870
impl SanePrivacyVisitor {

branches/try2/src/libsyntax/ext/quote.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ fn expand_wrapper(cx: &ExtCtxt,
648648
sp: Span,
649649
cx_expr: @ast::Expr,
650650
expr: @ast::Expr) -> @ast::Expr {
651-
let uses = ~[ cx.view_use_glob(sp, ast::Public,
651+
let uses = ~[ cx.view_use_glob(sp, ast::Inherited,
652652
ids_ext(~[~"syntax",
653653
~"ext",
654654
~"quote",
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2014 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+
pub extern mod std; //~ ERROR: `pub` visibility is not allowed
12+
priv extern mod std; //~ ERROR: unnecessary visibility qualifier
13+
extern mod std;
14+
15+
pub use std::bool;
16+
priv use std::bool; //~ ERROR: unnecessary visibility qualifier
17+
use std::bool;
18+
19+
fn main() {
20+
pub use std::bool; //~ ERROR: imports in functions are never reachable
21+
priv use std::bool; //~ ERROR: unnecessary visibility qualifier
22+
use std::bool;
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2014 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+
struct A<'a> {
12+
a: &'a [~str],
13+
b: Option<&'a [~str]>,
14+
}
15+
16+
pub fn main() {
17+
let b = &[~"foo"];
18+
let a = A {
19+
a: &[~"test"],
20+
b: Some(b),
21+
};
22+
assert_eq!(a.b.get_ref()[0].as_slice(), "foo");
23+
}

0 commit comments

Comments
 (0)