Skip to content

Commit

Permalink
[breaking-change] don't glob export ast::Visibility variants
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Feb 11, 2016
1 parent dfe35da commit d844bfb
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 46 deletions.
4 changes: 2 additions & 2 deletions src/librustc_front/lowering.rs
Expand Up @@ -1565,8 +1565,8 @@ pub fn lower_capture_clause(_lctx: &LoweringContext, c: CaptureBy) -> hir::Captu

pub fn lower_visibility(_lctx: &LoweringContext, v: Visibility) -> hir::Visibility {
match v {
Public => hir::Public,
Inherited => hir::Inherited,
Visibility::Public => hir::Public,
Visibility::Inherited => hir::Inherited,
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/libsyntax/ast.rs
Expand Up @@ -17,7 +17,6 @@ pub use self::StructFieldKind::*;
pub use self::TyParamBound::*;
pub use self::UnsafeSource::*;
pub use self::ViewPath_::*;
pub use self::Visibility::*;
pub use self::PathParameters::*;

use attr::ThinAttributes;
Expand Down Expand Up @@ -1851,8 +1850,8 @@ pub enum Visibility {
impl Visibility {
pub fn inherit_from(&self, parent_visibility: Visibility) -> Visibility {
match *self {
Inherited => parent_visibility,
Public => *self
Visibility::Inherited => parent_visibility,
Visibility::Public => *self
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/diagnostics/plugin.rs
Expand Up @@ -230,7 +230,7 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
ty,
expr,
),
vis: ast::Public,
vis: ast::Visibility::Public,
span: span,
})
]))
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ext/build.rs
Expand Up @@ -962,7 +962,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
attrs: attrs,
id: ast::DUMMY_NODE_ID,
node: node,
vis: ast::Inherited,
vis: ast::Visibility::Inherited,
span: span
})
}
Expand Down Expand Up @@ -1005,7 +1005,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
let fields: Vec<_> = tys.into_iter().map(|ty| {
Spanned { span: ty.span, node: ast::StructField_ {
ty: ty,
kind: ast::UnnamedField(ast::Inherited),
kind: ast::UnnamedField(ast::Visibility::Inherited),
attrs: Vec::new(),
id: ast::DUMMY_NODE_ID,
}}
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/quote.rs
Expand Up @@ -906,7 +906,7 @@ fn expand_wrapper(cx: &ExtCtxt,
let stmts = imports.iter().map(|path| {
// make item: `use ...;`
let path = path.iter().map(|s| s.to_string()).collect();
cx.stmt_item(sp, cx.item_use_glob(sp, ast::Inherited, ids_ext(path)))
cx.stmt_item(sp, cx.item_use_glob(sp, ast::Visibility::Inherited, ids_ext(path)))
}).chain(Some(stmt_let_ext_cx)).collect();

cx.expr_block(cx.block_all(sp, stmts, Some(expr)))
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/fold.rs
Expand Up @@ -1023,7 +1023,7 @@ pub fn noop_fold_crate<T: Folder>(Crate {module, attrs, config, mut exported_mac
ident: token::special_idents::invalid,
attrs: attrs,
id: ast::DUMMY_NODE_ID,
vis: ast::Public,
vis: ast::Visibility::Public,
span: span,
node: ast::ItemKind::Mod(module),
})).into_iter();
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/parse/mod.rs
Expand Up @@ -983,7 +983,7 @@ mod tests {
rules: ast::BlockCheckMode::Default, // no idea
span: sp(15,21),
})),
vis: ast::Inherited,
vis: ast::Visibility::Inherited,
span: sp(0,21)})));
}

Expand Down
28 changes: 14 additions & 14 deletions src/libsyntax/parse/parser.rs
Expand Up @@ -23,7 +23,7 @@ use ast::{EMPTY_CTXT, EnumDef, ExplicitSelf};
use ast::{Expr, ExprKind};
use ast::{Field, FnDecl};
use ast::{ForeignItem, ForeignItemKind, FunctionRetTy};
use ast::{Ident, Inherited, ImplItem, Item, ItemKind};
use ast::{Ident, ImplItem, Item, ItemKind};
use ast::{Lit, LitKind, UintTy};
use ast::Local;
use ast::MacStmtStyle;
Expand Down Expand Up @@ -3631,8 +3631,8 @@ impl<'a> Parser<'a> {
fn parse_name_and_ty(&mut self, pr: Visibility,
attrs: Vec<Attribute> ) -> PResult<'a, StructField> {
let lo = match pr {
Inherited => self.span.lo,
Public => self.last_span.lo,
Visibility::Inherited => self.span.lo,
Visibility::Public => self.last_span.lo,
};
if !self.token.is_plain_ident() {
return Err(self.fatal("expected ident"));
Expand Down Expand Up @@ -3749,7 +3749,7 @@ impl<'a> Parser<'a> {
lo, hi, id /*id is good here*/,
ItemKind::Mac(spanned(lo, hi,
Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT })),
Inherited, attrs)))),
Visibility::Inherited, attrs)))),
ast::DUMMY_NODE_ID))
}
} else {
Expand Down Expand Up @@ -4686,7 +4686,7 @@ impl<'a> Parser<'a> {

fn complain_if_pub_macro(&mut self, visa: Visibility, span: Span) {
match visa {
Public => {
Visibility::Public => {
let is_macro_rules: bool = match self.token {
token::Ident(sid, _) => sid.name == intern("macro_rules"),
_ => false,
Expand All @@ -4704,7 +4704,7 @@ impl<'a> Parser<'a> {
.emit();
}
}
Inherited => (),
Visibility::Inherited => (),
}
}

Expand Down Expand Up @@ -4974,7 +4974,7 @@ impl<'a> Parser<'a> {
if parse_pub == ParsePub::Yes {
try!(p.parse_visibility())
} else {
Inherited
Visibility::Inherited
}
),
id: ast::DUMMY_NODE_ID,
Expand Down Expand Up @@ -5020,16 +5020,16 @@ impl<'a> Parser<'a> {
let span = self.last_span;
self.span_err(span, "`pub` is not allowed here");
}
return self.parse_single_struct_field(Public, attrs);
return self.parse_single_struct_field(Visibility::Public, attrs);
}

return self.parse_single_struct_field(Inherited, attrs);
return self.parse_single_struct_field(Visibility::Inherited, attrs);
}

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

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

let last_span = self.last_span;

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

// FAILURE TO PARSE ITEM
match visibility {
Inherited => {}
Public => {
Visibility::Inherited => {}
Visibility::Public => {
let last_span = self.last_span;
return Err(self.span_fatal(last_span, "unmatched visibility `pub`"));
}
Expand Down
16 changes: 8 additions & 8 deletions src/libsyntax/print/pprust.rs
Expand Up @@ -388,7 +388,7 @@ pub fn fun_to_string(decl: &ast::FnDecl,
to_string(|s| {
try!(s.head(""));
try!(s.print_fn(decl, unsafety, constness, Abi::Rust, Some(name),
generics, opt_explicit_self, ast::Inherited));
generics, opt_explicit_self, ast::Visibility::Inherited));
try!(s.end()); // Close the head box
s.end() // Close the outer box
})
Expand Down Expand Up @@ -434,8 +434,8 @@ pub fn mac_to_string(arg: &ast::Mac) -> String {

pub fn visibility_qualified(vis: ast::Visibility, s: &str) -> String {
match vis {
ast::Public => format!("pub {}", s),
ast::Inherited => s.to_string()
ast::Visibility::Public => format!("pub {}", s),
ast::Visibility::Inherited => s.to_string()
}
}

Expand Down Expand Up @@ -1388,8 +1388,8 @@ impl<'a> State<'a> {

pub fn print_visibility(&mut self, vis: ast::Visibility) -> io::Result<()> {
match vis {
ast::Public => self.word_nbsp("pub"),
ast::Inherited => Ok(())
ast::Visibility::Public => self.word_nbsp("pub"),
ast::Visibility::Inherited => Ok(())
}
}

Expand Down Expand Up @@ -1555,13 +1555,13 @@ impl<'a> State<'a> {
ast::TraitItemKind::Const(ref ty, ref default) => {
try!(self.print_associated_const(ti.ident, &ty,
default.as_ref().map(|expr| &**expr),
ast::Inherited));
ast::Visibility::Inherited));
}
ast::TraitItemKind::Method(ref sig, ref body) => {
if body.is_some() {
try!(self.head(""));
}
try!(self.print_method_sig(ti.ident, sig, ast::Inherited));
try!(self.print_method_sig(ti.ident, sig, ast::Visibility::Inherited));
if let Some(ref body) = *body {
try!(self.nbsp());
try!(self.print_block_with_attrs(body, &ti.attrs));
Expand Down Expand Up @@ -3030,7 +3030,7 @@ impl<'a> State<'a> {
name,
&generics,
opt_explicit_self,
ast::Inherited));
ast::Visibility::Inherited));
self.end()
}

Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/std_inject.rs
Expand Up @@ -90,7 +90,7 @@ impl fold::Folder for CrateInjector {
attr::mk_attr_outer(attr::mk_attr_id(), attr::mk_word_item(
InternedString::new("macro_use")))),
node: ast::ItemKind::ExternCrate(Some(self.crate_name)),
vis: ast::Inherited,
vis: ast::Visibility::Inherited,
span: DUMMY_SP
}));

Expand Down Expand Up @@ -162,7 +162,7 @@ impl fold::Folder for PreludeInjector {
is_sugared_doc: false,
},
}],
vis: ast::Inherited,
vis: ast::Visibility::Inherited,
span: self.span,
}));

Expand Down
18 changes: 9 additions & 9 deletions src/libsyntax/test.rs
Expand Up @@ -147,7 +147,7 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> {
// the module (note that the tests are re-exported and must
// be made public themselves to avoid privacy errors).
i.map(|mut i| {
i.vis = ast::Public;
i.vis = ast::Visibility::Public;
i
})
}
Expand Down Expand Up @@ -245,11 +245,11 @@ fn mk_reexport_mod(cx: &mut TestCtxt, tests: Vec<ast::Ident>,
let super_ = token::str_to_ident("super");

let items = tests.into_iter().map(|r| {
cx.ext_cx.item_use_simple(DUMMY_SP, ast::Public,
cx.ext_cx.item_use_simple(DUMMY_SP, ast::Visibility::Public,
cx.ext_cx.path(DUMMY_SP, vec![super_, r]))
}).chain(tested_submods.into_iter().map(|(r, sym)| {
let path = cx.ext_cx.path(DUMMY_SP, vec![super_, r, sym]);
cx.ext_cx.item_use_simple_(DUMMY_SP, ast::Public, r, path)
cx.ext_cx.item_use_simple_(DUMMY_SP, ast::Visibility::Public, r, path)
}));

let reexport_mod = ast::Mod {
Expand All @@ -263,7 +263,7 @@ fn mk_reexport_mod(cx: &mut TestCtxt, tests: Vec<ast::Ident>,
attrs: Vec::new(),
id: ast::DUMMY_NODE_ID,
node: ast::ItemKind::Mod(reexport_mod),
vis: ast::Public,
vis: ast::Visibility::Public,
span: DUMMY_SP,
});

Expand Down Expand Up @@ -456,9 +456,9 @@ fn mk_std(cx: &TestCtxt) -> P<ast::Item> {
(ast::ItemKind::Use(
P(nospan(ast::ViewPathSimple(id_test,
path_node(vec!(id_test)))))),
ast::Public, token::special_idents::invalid)
ast::Visibility::Public, token::special_idents::invalid)
} else {
(ast::ItemKind::ExternCrate(None), ast::Inherited, id_test)
(ast::ItemKind::ExternCrate(None), ast::Visibility::Inherited, id_test)
};
P(ast::Item {
id: ast::DUMMY_NODE_ID,
Expand Down Expand Up @@ -505,7 +505,7 @@ fn mk_main(cx: &mut TestCtxt) -> P<ast::Item> {
attrs: vec![main_attr],
id: ast::DUMMY_NODE_ID,
node: main,
vis: ast::Public,
vis: ast::Visibility::Public,
span: sp
});

Expand Down Expand Up @@ -535,7 +535,7 @@ fn mk_test_module(cx: &mut TestCtxt) -> (P<ast::Item>, Option<P<ast::Item>>) {
ident: mod_ident,
attrs: vec![],
node: item_,
vis: ast::Public,
vis: ast::Visibility::Public,
span: DUMMY_SP,
});
let reexport = cx.reexport_test_harness_main.as_ref().map(|s| {
Expand All @@ -551,7 +551,7 @@ fn mk_test_module(cx: &mut TestCtxt) -> (P<ast::Item>, Option<P<ast::Item>>) {
ident: token::special_idents::invalid,
attrs: vec![],
node: ast::ItemKind::Use(P(use_path)),
vis: ast::Inherited,
vis: ast::Visibility::Inherited,
span: DUMMY_SP
})
});
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax_ext/deriving/generic/mod.rs
Expand Up @@ -475,7 +475,7 @@ impl<'a> TraitDef<'a> {
id: ast::DUMMY_NODE_ID,
span: self.span,
ident: ident,
vis: ast::Inherited,
vis: ast::Visibility::Inherited,
attrs: Vec::new(),
node: ast::ImplItemKind::Type(type_def.to_ty(cx,
self.span,
Expand Down Expand Up @@ -892,7 +892,7 @@ impl<'a> MethodDef<'a> {
id: ast::DUMMY_NODE_ID,
attrs: self.attributes.clone(),
span: trait_.span,
vis: ast::Inherited,
vis: ast::Visibility::Inherited,
ident: method_ident,
node: ast::ImplItemKind::Method(ast::MethodSig {
generics: fn_generics,
Expand Down

0 comments on commit d844bfb

Please sign in to comment.