Skip to content

Commit d844bfb

Browse files
committed
[breaking-change] don't glob export ast::Visibility variants
1 parent dfe35da commit d844bfb

File tree

12 files changed

+45
-46
lines changed

12 files changed

+45
-46
lines changed

src/librustc_front/lowering.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,8 +1565,8 @@ pub fn lower_capture_clause(_lctx: &LoweringContext, c: CaptureBy) -> hir::Captu
15651565

15661566
pub fn lower_visibility(_lctx: &LoweringContext, v: Visibility) -> hir::Visibility {
15671567
match v {
1568-
Public => hir::Public,
1569-
Inherited => hir::Inherited,
1568+
Visibility::Public => hir::Public,
1569+
Visibility::Inherited => hir::Inherited,
15701570
}
15711571
}
15721572

src/libsyntax/ast.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ pub use self::StructFieldKind::*;
1717
pub use self::TyParamBound::*;
1818
pub use self::UnsafeSource::*;
1919
pub use self::ViewPath_::*;
20-
pub use self::Visibility::*;
2120
pub use self::PathParameters::*;
2221

2322
use attr::ThinAttributes;
@@ -1851,8 +1850,8 @@ pub enum Visibility {
18511850
impl Visibility {
18521851
pub fn inherit_from(&self, parent_visibility: Visibility) -> Visibility {
18531852
match *self {
1854-
Inherited => parent_visibility,
1855-
Public => *self
1853+
Visibility::Inherited => parent_visibility,
1854+
Visibility::Public => *self
18561855
}
18571856
}
18581857
}

src/libsyntax/diagnostics/plugin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
230230
ty,
231231
expr,
232232
),
233-
vis: ast::Public,
233+
vis: ast::Visibility::Public,
234234
span: span,
235235
})
236236
]))

src/libsyntax/ext/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
962962
attrs: attrs,
963963
id: ast::DUMMY_NODE_ID,
964964
node: node,
965-
vis: ast::Inherited,
965+
vis: ast::Visibility::Inherited,
966966
span: span
967967
})
968968
}
@@ -1005,7 +1005,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
10051005
let fields: Vec<_> = tys.into_iter().map(|ty| {
10061006
Spanned { span: ty.span, node: ast::StructField_ {
10071007
ty: ty,
1008-
kind: ast::UnnamedField(ast::Inherited),
1008+
kind: ast::UnnamedField(ast::Visibility::Inherited),
10091009
attrs: Vec::new(),
10101010
id: ast::DUMMY_NODE_ID,
10111011
}}

src/libsyntax/ext/quote.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ fn expand_wrapper(cx: &ExtCtxt,
906906
let stmts = imports.iter().map(|path| {
907907
// make item: `use ...;`
908908
let path = path.iter().map(|s| s.to_string()).collect();
909-
cx.stmt_item(sp, cx.item_use_glob(sp, ast::Inherited, ids_ext(path)))
909+
cx.stmt_item(sp, cx.item_use_glob(sp, ast::Visibility::Inherited, ids_ext(path)))
910910
}).chain(Some(stmt_let_ext_cx)).collect();
911911

912912
cx.expr_block(cx.block_all(sp, stmts, Some(expr)))

src/libsyntax/fold.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ pub fn noop_fold_crate<T: Folder>(Crate {module, attrs, config, mut exported_mac
10231023
ident: token::special_idents::invalid,
10241024
attrs: attrs,
10251025
id: ast::DUMMY_NODE_ID,
1026-
vis: ast::Public,
1026+
vis: ast::Visibility::Public,
10271027
span: span,
10281028
node: ast::ItemKind::Mod(module),
10291029
})).into_iter();

src/libsyntax/parse/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ mod tests {
983983
rules: ast::BlockCheckMode::Default, // no idea
984984
span: sp(15,21),
985985
})),
986-
vis: ast::Inherited,
986+
vis: ast::Visibility::Inherited,
987987
span: sp(0,21)})));
988988
}
989989

src/libsyntax/parse/parser.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use ast::{EMPTY_CTXT, EnumDef, ExplicitSelf};
2323
use ast::{Expr, ExprKind};
2424
use ast::{Field, FnDecl};
2525
use ast::{ForeignItem, ForeignItemKind, FunctionRetTy};
26-
use ast::{Ident, Inherited, ImplItem, Item, ItemKind};
26+
use ast::{Ident, ImplItem, Item, ItemKind};
2727
use ast::{Lit, LitKind, UintTy};
2828
use ast::Local;
2929
use ast::MacStmtStyle;
@@ -3631,8 +3631,8 @@ impl<'a> Parser<'a> {
36313631
fn parse_name_and_ty(&mut self, pr: Visibility,
36323632
attrs: Vec<Attribute> ) -> PResult<'a, StructField> {
36333633
let lo = match pr {
3634-
Inherited => self.span.lo,
3635-
Public => self.last_span.lo,
3634+
Visibility::Inherited => self.span.lo,
3635+
Visibility::Public => self.last_span.lo,
36363636
};
36373637
if !self.token.is_plain_ident() {
36383638
return Err(self.fatal("expected ident"));
@@ -3749,7 +3749,7 @@ impl<'a> Parser<'a> {
37493749
lo, hi, id /*id is good here*/,
37503750
ItemKind::Mac(spanned(lo, hi,
37513751
Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT })),
3752-
Inherited, attrs)))),
3752+
Visibility::Inherited, attrs)))),
37533753
ast::DUMMY_NODE_ID))
37543754
}
37553755
} else {
@@ -4686,7 +4686,7 @@ impl<'a> Parser<'a> {
46864686

46874687
fn complain_if_pub_macro(&mut self, visa: Visibility, span: Span) {
46884688
match visa {
4689-
Public => {
4689+
Visibility::Public => {
46904690
let is_macro_rules: bool = match self.token {
46914691
token::Ident(sid, _) => sid.name == intern("macro_rules"),
46924692
_ => false,
@@ -4704,7 +4704,7 @@ impl<'a> Parser<'a> {
47044704
.emit();
47054705
}
47064706
}
4707-
Inherited => (),
4707+
Visibility::Inherited => (),
47084708
}
47094709
}
47104710

@@ -4974,7 +4974,7 @@ impl<'a> Parser<'a> {
49744974
if parse_pub == ParsePub::Yes {
49754975
try!(p.parse_visibility())
49764976
} else {
4977-
Inherited
4977+
Visibility::Inherited
49784978
}
49794979
),
49804980
id: ast::DUMMY_NODE_ID,
@@ -5020,16 +5020,16 @@ impl<'a> Parser<'a> {
50205020
let span = self.last_span;
50215021
self.span_err(span, "`pub` is not allowed here");
50225022
}
5023-
return self.parse_single_struct_field(Public, attrs);
5023+
return self.parse_single_struct_field(Visibility::Public, attrs);
50245024
}
50255025

5026-
return self.parse_single_struct_field(Inherited, attrs);
5026+
return self.parse_single_struct_field(Visibility::Inherited, attrs);
50275027
}
50285028

50295029
/// Parse visibility: PUB or nothing
50305030
fn parse_visibility(&mut self) -> PResult<'a, Visibility> {
5031-
if self.eat_keyword(keywords::Pub) { Ok(Public) }
5032-
else { Ok(Inherited) }
5031+
if self.eat_keyword(keywords::Pub) { Ok(Visibility::Public) }
5032+
else { Ok(Visibility::Inherited) }
50335033
}
50345034

50355035
/// Given a termination token, parse all of the items in a module
@@ -5304,7 +5304,7 @@ impl<'a> Parser<'a> {
53045304

53055305
let last_span = self.last_span;
53065306

5307-
if visibility == ast::Public {
5307+
if visibility == ast::Visibility::Public {
53085308
self.span_warn(mk_sp(lo, last_span.hi),
53095309
"`pub extern crate` does not work as expected and should not be used. \
53105310
Likely to become an error. Prefer `extern crate` and `pub use`.");
@@ -5819,8 +5819,8 @@ impl<'a> Parser<'a> {
58195819

58205820
// FAILURE TO PARSE ITEM
58215821
match visibility {
5822-
Inherited => {}
5823-
Public => {
5822+
Visibility::Inherited => {}
5823+
Visibility::Public => {
58245824
let last_span = self.last_span;
58255825
return Err(self.span_fatal(last_span, "unmatched visibility `pub`"));
58265826
}

src/libsyntax/print/pprust.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ pub fn fun_to_string(decl: &ast::FnDecl,
388388
to_string(|s| {
389389
try!(s.head(""));
390390
try!(s.print_fn(decl, unsafety, constness, Abi::Rust, Some(name),
391-
generics, opt_explicit_self, ast::Inherited));
391+
generics, opt_explicit_self, ast::Visibility::Inherited));
392392
try!(s.end()); // Close the head box
393393
s.end() // Close the outer box
394394
})
@@ -434,8 +434,8 @@ pub fn mac_to_string(arg: &ast::Mac) -> String {
434434

435435
pub fn visibility_qualified(vis: ast::Visibility, s: &str) -> String {
436436
match vis {
437-
ast::Public => format!("pub {}", s),
438-
ast::Inherited => s.to_string()
437+
ast::Visibility::Public => format!("pub {}", s),
438+
ast::Visibility::Inherited => s.to_string()
439439
}
440440
}
441441

@@ -1388,8 +1388,8 @@ impl<'a> State<'a> {
13881388

13891389
pub fn print_visibility(&mut self, vis: ast::Visibility) -> io::Result<()> {
13901390
match vis {
1391-
ast::Public => self.word_nbsp("pub"),
1392-
ast::Inherited => Ok(())
1391+
ast::Visibility::Public => self.word_nbsp("pub"),
1392+
ast::Visibility::Inherited => Ok(())
13931393
}
13941394
}
13951395

@@ -1555,13 +1555,13 @@ impl<'a> State<'a> {
15551555
ast::TraitItemKind::Const(ref ty, ref default) => {
15561556
try!(self.print_associated_const(ti.ident, &ty,
15571557
default.as_ref().map(|expr| &**expr),
1558-
ast::Inherited));
1558+
ast::Visibility::Inherited));
15591559
}
15601560
ast::TraitItemKind::Method(ref sig, ref body) => {
15611561
if body.is_some() {
15621562
try!(self.head(""));
15631563
}
1564-
try!(self.print_method_sig(ti.ident, sig, ast::Inherited));
1564+
try!(self.print_method_sig(ti.ident, sig, ast::Visibility::Inherited));
15651565
if let Some(ref body) = *body {
15661566
try!(self.nbsp());
15671567
try!(self.print_block_with_attrs(body, &ti.attrs));
@@ -3030,7 +3030,7 @@ impl<'a> State<'a> {
30303030
name,
30313031
&generics,
30323032
opt_explicit_self,
3033-
ast::Inherited));
3033+
ast::Visibility::Inherited));
30343034
self.end()
30353035
}
30363036

src/libsyntax/std_inject.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl fold::Folder for CrateInjector {
9090
attr::mk_attr_outer(attr::mk_attr_id(), attr::mk_word_item(
9191
InternedString::new("macro_use")))),
9292
node: ast::ItemKind::ExternCrate(Some(self.crate_name)),
93-
vis: ast::Inherited,
93+
vis: ast::Visibility::Inherited,
9494
span: DUMMY_SP
9595
}));
9696

@@ -162,7 +162,7 @@ impl fold::Folder for PreludeInjector {
162162
is_sugared_doc: false,
163163
},
164164
}],
165-
vis: ast::Inherited,
165+
vis: ast::Visibility::Inherited,
166166
span: self.span,
167167
}));
168168

0 commit comments

Comments
 (0)