1
Fork 0

[breaking-change] don't glob export ast::Visibility variants

This commit is contained in:
Oliver 'ker' Schneider 2016-02-09 17:57:49 +01:00 committed by Oliver Schneider
parent dfe35da6b8
commit d844bfb196
12 changed files with 45 additions and 46 deletions

View file

@ -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 { pub fn lower_visibility(_lctx: &LoweringContext, v: Visibility) -> hir::Visibility {
match v { match v {
Public => hir::Public, Visibility::Public => hir::Public,
Inherited => hir::Inherited, Visibility::Inherited => hir::Inherited,
} }
} }

View file

@ -17,7 +17,6 @@ pub use self::StructFieldKind::*;
pub use self::TyParamBound::*; pub use self::TyParamBound::*;
pub use self::UnsafeSource::*; pub use self::UnsafeSource::*;
pub use self::ViewPath_::*; pub use self::ViewPath_::*;
pub use self::Visibility::*;
pub use self::PathParameters::*; pub use self::PathParameters::*;
use attr::ThinAttributes; use attr::ThinAttributes;
@ -1851,8 +1850,8 @@ pub enum Visibility {
impl Visibility { impl Visibility {
pub fn inherit_from(&self, parent_visibility: Visibility) -> Visibility { pub fn inherit_from(&self, parent_visibility: Visibility) -> Visibility {
match *self { match *self {
Inherited => parent_visibility, Visibility::Inherited => parent_visibility,
Public => *self Visibility::Public => *self
} }
} }
} }

View file

@ -230,7 +230,7 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
ty, ty,
expr, expr,
), ),
vis: ast::Public, vis: ast::Visibility::Public,
span: span, span: span,
}) })
])) ]))

View file

@ -962,7 +962,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
attrs: attrs, attrs: attrs,
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
node: node, node: node,
vis: ast::Inherited, vis: ast::Visibility::Inherited,
span: span span: span
}) })
} }
@ -1005,7 +1005,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
let fields: Vec<_> = tys.into_iter().map(|ty| { let fields: Vec<_> = tys.into_iter().map(|ty| {
Spanned { span: ty.span, node: ast::StructField_ { Spanned { span: ty.span, node: ast::StructField_ {
ty: ty, ty: ty,
kind: ast::UnnamedField(ast::Inherited), kind: ast::UnnamedField(ast::Visibility::Inherited),
attrs: Vec::new(), attrs: Vec::new(),
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
}} }}

View file

@ -906,7 +906,7 @@ fn expand_wrapper(cx: &ExtCtxt,
let stmts = imports.iter().map(|path| { let stmts = imports.iter().map(|path| {
// make item: `use ...;` // make item: `use ...;`
let path = path.iter().map(|s| s.to_string()).collect(); 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(); }).chain(Some(stmt_let_ext_cx)).collect();
cx.expr_block(cx.block_all(sp, stmts, Some(expr))) cx.expr_block(cx.block_all(sp, stmts, Some(expr)))

View file

@ -1023,7 +1023,7 @@ pub fn noop_fold_crate<T: Folder>(Crate {module, attrs, config, mut exported_mac
ident: token::special_idents::invalid, ident: token::special_idents::invalid,
attrs: attrs, attrs: attrs,
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
vis: ast::Public, vis: ast::Visibility::Public,
span: span, span: span,
node: ast::ItemKind::Mod(module), node: ast::ItemKind::Mod(module),
})).into_iter(); })).into_iter();

View file

@ -983,7 +983,7 @@ mod tests {
rules: ast::BlockCheckMode::Default, // no idea rules: ast::BlockCheckMode::Default, // no idea
span: sp(15,21), span: sp(15,21),
})), })),
vis: ast::Inherited, vis: ast::Visibility::Inherited,
span: sp(0,21)}))); span: sp(0,21)})));
} }

View file

@ -23,7 +23,7 @@ use ast::{EMPTY_CTXT, EnumDef, ExplicitSelf};
use ast::{Expr, ExprKind}; use ast::{Expr, ExprKind};
use ast::{Field, FnDecl}; use ast::{Field, FnDecl};
use ast::{ForeignItem, ForeignItemKind, FunctionRetTy}; 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::{Lit, LitKind, UintTy};
use ast::Local; use ast::Local;
use ast::MacStmtStyle; use ast::MacStmtStyle;
@ -3631,8 +3631,8 @@ impl<'a> Parser<'a> {
fn parse_name_and_ty(&mut self, pr: Visibility, fn parse_name_and_ty(&mut self, pr: Visibility,
attrs: Vec<Attribute> ) -> PResult<'a, StructField> { attrs: Vec<Attribute> ) -> PResult<'a, StructField> {
let lo = match pr { let lo = match pr {
Inherited => self.span.lo, Visibility::Inherited => self.span.lo,
Public => self.last_span.lo, Visibility::Public => self.last_span.lo,
}; };
if !self.token.is_plain_ident() { if !self.token.is_plain_ident() {
return Err(self.fatal("expected ident")); return Err(self.fatal("expected ident"));
@ -3749,7 +3749,7 @@ impl<'a> Parser<'a> {
lo, hi, id /*id is good here*/, lo, hi, id /*id is good here*/,
ItemKind::Mac(spanned(lo, hi, ItemKind::Mac(spanned(lo, hi,
Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT })), Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT })),
Inherited, attrs)))), Visibility::Inherited, attrs)))),
ast::DUMMY_NODE_ID)) ast::DUMMY_NODE_ID))
} }
} else { } else {
@ -4686,7 +4686,7 @@ impl<'a> Parser<'a> {
fn complain_if_pub_macro(&mut self, visa: Visibility, span: Span) { fn complain_if_pub_macro(&mut self, visa: Visibility, span: Span) {
match visa { match visa {
Public => { Visibility::Public => {
let is_macro_rules: bool = match self.token { let is_macro_rules: bool = match self.token {
token::Ident(sid, _) => sid.name == intern("macro_rules"), token::Ident(sid, _) => sid.name == intern("macro_rules"),
_ => false, _ => false,
@ -4704,7 +4704,7 @@ impl<'a> Parser<'a> {
.emit(); .emit();
} }
} }
Inherited => (), Visibility::Inherited => (),
} }
} }
@ -4974,7 +4974,7 @@ impl<'a> Parser<'a> {
if parse_pub == ParsePub::Yes { if parse_pub == ParsePub::Yes {
try!(p.parse_visibility()) try!(p.parse_visibility())
} else { } else {
Inherited Visibility::Inherited
} }
), ),
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
@ -5020,16 +5020,16 @@ impl<'a> Parser<'a> {
let span = self.last_span; let span = self.last_span;
self.span_err(span, "`pub` is not allowed here"); 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 /// Parse visibility: PUB or nothing
fn parse_visibility(&mut self) -> PResult<'a, Visibility> { fn parse_visibility(&mut self) -> PResult<'a, Visibility> {
if self.eat_keyword(keywords::Pub) { Ok(Public) } if self.eat_keyword(keywords::Pub) { Ok(Visibility::Public) }
else { Ok(Inherited) } else { Ok(Visibility::Inherited) }
} }
/// Given a termination token, parse all of the items in a module /// Given a termination token, parse all of the items in a module
@ -5304,7 +5304,7 @@ impl<'a> Parser<'a> {
let last_span = self.last_span; let last_span = self.last_span;
if visibility == ast::Public { if visibility == ast::Visibility::Public {
self.span_warn(mk_sp(lo, last_span.hi), self.span_warn(mk_sp(lo, last_span.hi),
"`pub extern crate` does not work as expected and should not be used. \ "`pub extern crate` does not work as expected and should not be used. \
Likely to become an error. Prefer `extern crate` and `pub use`."); Likely to become an error. Prefer `extern crate` and `pub use`.");
@ -5819,8 +5819,8 @@ impl<'a> Parser<'a> {
// FAILURE TO PARSE ITEM // FAILURE TO PARSE ITEM
match visibility { match visibility {
Inherited => {} Visibility::Inherited => {}
Public => { Visibility::Public => {
let last_span = self.last_span; let last_span = self.last_span;
return Err(self.span_fatal(last_span, "unmatched visibility `pub`")); return Err(self.span_fatal(last_span, "unmatched visibility `pub`"));
} }

View file

@ -388,7 +388,7 @@ pub fn fun_to_string(decl: &ast::FnDecl,
to_string(|s| { to_string(|s| {
try!(s.head("")); try!(s.head(""));
try!(s.print_fn(decl, unsafety, constness, Abi::Rust, Some(name), 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 try!(s.end()); // Close the head box
s.end() // Close the outer box s.end() // Close the outer box
}) })
@ -434,8 +434,8 @@ pub fn mac_to_string(arg: &ast::Mac) -> String {
pub fn visibility_qualified(vis: ast::Visibility, s: &str) -> String { pub fn visibility_qualified(vis: ast::Visibility, s: &str) -> String {
match vis { match vis {
ast::Public => format!("pub {}", s), ast::Visibility::Public => format!("pub {}", s),
ast::Inherited => s.to_string() ast::Visibility::Inherited => s.to_string()
} }
} }
@ -1388,8 +1388,8 @@ impl<'a> State<'a> {
pub fn print_visibility(&mut self, vis: ast::Visibility) -> io::Result<()> { pub fn print_visibility(&mut self, vis: ast::Visibility) -> io::Result<()> {
match vis { match vis {
ast::Public => self.word_nbsp("pub"), ast::Visibility::Public => self.word_nbsp("pub"),
ast::Inherited => Ok(()) ast::Visibility::Inherited => Ok(())
} }
} }
@ -1555,13 +1555,13 @@ impl<'a> State<'a> {
ast::TraitItemKind::Const(ref ty, ref default) => { ast::TraitItemKind::Const(ref ty, ref default) => {
try!(self.print_associated_const(ti.ident, &ty, try!(self.print_associated_const(ti.ident, &ty,
default.as_ref().map(|expr| &**expr), default.as_ref().map(|expr| &**expr),
ast::Inherited)); ast::Visibility::Inherited));
} }
ast::TraitItemKind::Method(ref sig, ref body) => { ast::TraitItemKind::Method(ref sig, ref body) => {
if body.is_some() { if body.is_some() {
try!(self.head("")); 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 { if let Some(ref body) = *body {
try!(self.nbsp()); try!(self.nbsp());
try!(self.print_block_with_attrs(body, &ti.attrs)); try!(self.print_block_with_attrs(body, &ti.attrs));
@ -3030,7 +3030,7 @@ impl<'a> State<'a> {
name, name,
&generics, &generics,
opt_explicit_self, opt_explicit_self,
ast::Inherited)); ast::Visibility::Inherited));
self.end() self.end()
} }

View file

@ -90,7 +90,7 @@ impl fold::Folder for CrateInjector {
attr::mk_attr_outer(attr::mk_attr_id(), attr::mk_word_item( attr::mk_attr_outer(attr::mk_attr_id(), attr::mk_word_item(
InternedString::new("macro_use")))), InternedString::new("macro_use")))),
node: ast::ItemKind::ExternCrate(Some(self.crate_name)), node: ast::ItemKind::ExternCrate(Some(self.crate_name)),
vis: ast::Inherited, vis: ast::Visibility::Inherited,
span: DUMMY_SP span: DUMMY_SP
})); }));
@ -162,7 +162,7 @@ impl fold::Folder for PreludeInjector {
is_sugared_doc: false, is_sugared_doc: false,
}, },
}], }],
vis: ast::Inherited, vis: ast::Visibility::Inherited,
span: self.span, span: self.span,
})); }));

View file

@ -147,7 +147,7 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> {
// the module (note that the tests are re-exported and must // the module (note that the tests are re-exported and must
// be made public themselves to avoid privacy errors). // be made public themselves to avoid privacy errors).
i.map(|mut i| { i.map(|mut i| {
i.vis = ast::Public; i.vis = ast::Visibility::Public;
i i
}) })
} }
@ -245,11 +245,11 @@ fn mk_reexport_mod(cx: &mut TestCtxt, tests: Vec<ast::Ident>,
let super_ = token::str_to_ident("super"); let super_ = token::str_to_ident("super");
let items = tests.into_iter().map(|r| { 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])) cx.ext_cx.path(DUMMY_SP, vec![super_, r]))
}).chain(tested_submods.into_iter().map(|(r, sym)| { }).chain(tested_submods.into_iter().map(|(r, sym)| {
let path = cx.ext_cx.path(DUMMY_SP, vec![super_, 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 { let reexport_mod = ast::Mod {
@ -263,7 +263,7 @@ fn mk_reexport_mod(cx: &mut TestCtxt, tests: Vec<ast::Ident>,
attrs: Vec::new(), attrs: Vec::new(),
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
node: ast::ItemKind::Mod(reexport_mod), node: ast::ItemKind::Mod(reexport_mod),
vis: ast::Public, vis: ast::Visibility::Public,
span: DUMMY_SP, span: DUMMY_SP,
}); });
@ -456,9 +456,9 @@ fn mk_std(cx: &TestCtxt) -> P<ast::Item> {
(ast::ItemKind::Use( (ast::ItemKind::Use(
P(nospan(ast::ViewPathSimple(id_test, P(nospan(ast::ViewPathSimple(id_test,
path_node(vec!(id_test)))))), path_node(vec!(id_test)))))),
ast::Public, token::special_idents::invalid) ast::Visibility::Public, token::special_idents::invalid)
} else { } else {
(ast::ItemKind::ExternCrate(None), ast::Inherited, id_test) (ast::ItemKind::ExternCrate(None), ast::Visibility::Inherited, id_test)
}; };
P(ast::Item { P(ast::Item {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
@ -505,7 +505,7 @@ fn mk_main(cx: &mut TestCtxt) -> P<ast::Item> {
attrs: vec![main_attr], attrs: vec![main_attr],
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
node: main, node: main,
vis: ast::Public, vis: ast::Visibility::Public,
span: sp span: sp
}); });
@ -535,7 +535,7 @@ fn mk_test_module(cx: &mut TestCtxt) -> (P<ast::Item>, Option<P<ast::Item>>) {
ident: mod_ident, ident: mod_ident,
attrs: vec![], attrs: vec![],
node: item_, node: item_,
vis: ast::Public, vis: ast::Visibility::Public,
span: DUMMY_SP, span: DUMMY_SP,
}); });
let reexport = cx.reexport_test_harness_main.as_ref().map(|s| { let reexport = cx.reexport_test_harness_main.as_ref().map(|s| {
@ -551,7 +551,7 @@ fn mk_test_module(cx: &mut TestCtxt) -> (P<ast::Item>, Option<P<ast::Item>>) {
ident: token::special_idents::invalid, ident: token::special_idents::invalid,
attrs: vec![], attrs: vec![],
node: ast::ItemKind::Use(P(use_path)), node: ast::ItemKind::Use(P(use_path)),
vis: ast::Inherited, vis: ast::Visibility::Inherited,
span: DUMMY_SP span: DUMMY_SP
}) })
}); });

View file

@ -475,7 +475,7 @@ impl<'a> TraitDef<'a> {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
span: self.span, span: self.span,
ident: ident, ident: ident,
vis: ast::Inherited, vis: ast::Visibility::Inherited,
attrs: Vec::new(), attrs: Vec::new(),
node: ast::ImplItemKind::Type(type_def.to_ty(cx, node: ast::ImplItemKind::Type(type_def.to_ty(cx,
self.span, self.span,
@ -892,7 +892,7 @@ impl<'a> MethodDef<'a> {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
attrs: self.attributes.clone(), attrs: self.attributes.clone(),
span: trait_.span, span: trait_.span,
vis: ast::Inherited, vis: ast::Visibility::Inherited,
ident: method_ident, ident: method_ident,
node: ast::ImplItemKind::Method(ast::MethodSig { node: ast::ImplItemKind::Method(ast::MethodSig {
generics: fn_generics, generics: fn_generics,