diff options
| author | Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> | 2016-02-08 15:04:11 +0100 |
|---|---|---|
| committer | Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> | 2016-02-11 12:34:48 +0100 |
| commit | 3b57d40fe5a813ac957667ac04938753e3100f55 (patch) | |
| tree | 315ed7442c8ba2e503c57a1f09d3e9a1cde41145 /src/libsyntax | |
| parent | 05e25de4f0add7ae3cd0e8f66cd4558c5bfa42aa (diff) | |
[breaking-change] don't glob import ast::FunctionRetTy variants
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 13 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 14 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 22 | ||||
| -rw-r--r-- | src/libsyntax/test.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 2 |
8 files changed, 34 insertions, 35 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index be6d65a01b5..9d49fb3be4f 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -16,7 +16,6 @@ pub use self::Decl_::*; pub use self::ExplicitSelf_::*; pub use self::Expr_::*; pub use self::FloatTy::*; -pub use self::FunctionRetTy::*; pub use self::ForeignItem_::*; pub use self::IntTy::*; pub use self::Item_::*; @@ -1727,23 +1726,23 @@ impl fmt::Debug for ImplPolarity { pub enum FunctionRetTy { /// Functions with return type `!`that always /// raise an error or exit (i.e. never return to the caller) - NoReturn(Span), + None(Span), /// Return type is not specified. /// /// Functions default to `()` and /// closures default to inference. Span points to where return /// type would be inserted. - DefaultReturn(Span), + Default(Span), /// Everything else - Return(P<Ty>), + Ty(P<Ty>), } impl FunctionRetTy { pub fn span(&self) -> Span { match *self { - NoReturn(span) => span, - DefaultReturn(span) => span, - Return(ref ty) => ty.span + FunctionRetTy::None(span) => span, + FunctionRetTy::Default(span) => span, + FunctionRetTy::Ty(ref ty) => ty.span, } } } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index a5f6454cb38..91ced6eb076 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -941,7 +941,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn fn_decl(&self, inputs: Vec<ast::Arg>, output: P<ast::Ty>) -> P<ast::FnDecl> { P(ast::FnDecl { inputs: inputs, - output: ast::Return(output), + output: ast::FunctionRetTy::Ty(output), variadic: false }) } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 1de6d6c002f..dc96e9ecc09 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -685,9 +685,9 @@ pub fn noop_fold_fn_decl<T: Folder>(decl: P<FnDecl>, fld: &mut T) -> P<FnDecl> { decl.map(|FnDecl {inputs, output, variadic}| FnDecl { inputs: inputs.move_map(|x| fld.fold_arg(x)), output: match output { - Return(ty) => Return(fld.fold_ty(ty)), - DefaultReturn(span) => DefaultReturn(span), - NoReturn(span) => NoReturn(span) + FunctionRetTy::Ty(ty) => FunctionRetTy::Ty(fld.fold_ty(ty)), + FunctionRetTy::Default(span) => FunctionRetTy::Default(span), + FunctionRetTy::None(span) => FunctionRetTy::None(span), }, variadic: variadic }) diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 32372ccc13b..becce9ba7d9 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -950,7 +950,7 @@ mod tests { }), id: ast::DUMMY_NODE_ID }), - output: ast::DefaultReturn(sp(15, 15)), + output: ast::FunctionRetTy::Default(sp(15, 15)), variadic: false }), ast::Unsafety::Normal, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index d6d0a35f2ce..3f7173b179c 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -18,7 +18,7 @@ use ast::{Mod, Arg, Arm, Attribute, BindingMode}; use ast::Block; use ast::{BlockCheckMode, CaptureByRef, CaptureByValue, CaptureClause}; use ast::{Constness, ConstTraitItem, Crate, CrateConfig}; -use ast::{Decl, DeclItem, DeclLocal, DefaultBlock, DefaultReturn}; +use ast::{Decl, DeclItem, DeclLocal, DefaultBlock}; use ast::{EMPTY_CTXT, EnumDef, ExplicitSelf}; use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain}; use ast::{ExprAssign, ExprAssignOp, ExprBinary, ExprBlock, ExprBox}; @@ -39,11 +39,11 @@ use ast::{LitStr, LitInt, Local}; use ast::{MacStmtWithBraces, MacStmtWithSemicolon, MacStmtWithoutBraces}; use ast::{MutImmutable, MutMutable, Mac_}; use ast::{MutTy, Mutability}; -use ast::{NamedField, NoReturn}; +use ast::NamedField; use ast::{Pat, PatBox, PatEnum, PatIdent, PatLit, PatQPath, PatMac, PatRange}; use ast::{PatRegion, PatStruct, PatTup, PatVec, PatWild}; use ast::{PolyTraitRef, QSelf}; -use ast::{Return, Stmt, StmtDecl}; +use ast::{Stmt, StmtDecl}; use ast::{StmtExpr, StmtSemi, StmtMac, VariantData, StructField}; use ast::StrStyle; use ast::{SelfExplicit, SelfRegion, SelfStatic, SelfValue}; @@ -1283,13 +1283,13 @@ impl<'a> Parser<'a> { pub fn parse_ret_ty(&mut self) -> PResult<'a, FunctionRetTy> { if self.eat(&token::RArrow) { if self.eat(&token::Not) { - Ok(NoReturn(self.last_span)) + Ok(FunctionRetTy::None(self.last_span)) } else { - Ok(Return(try!(self.parse_ty()))) + Ok(FunctionRetTy::Ty(try!(self.parse_ty()))) } } else { let pos = self.span.lo; - Ok(DefaultReturn(mk_sp(pos, pos))) + Ok(FunctionRetTy::Default(mk_sp(pos, pos))) } } @@ -3053,7 +3053,7 @@ impl<'a> Parser<'a> { { let decl = try!(self.parse_fn_block_decl()); let body = match decl.output { - DefaultReturn(_) => { + FunctionRetTy::Default(_) => { // If no explicit return type is given, parse any // expr and wrap it up in a dummy block: let body_expr = try!(self.parse_expr()); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 759b16c5738..4e1f761c51a 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2108,7 +2108,7 @@ impl<'a> State<'a> { try!(space(&mut self.s)); let default_return = match decl.output { - ast::DefaultReturn(..) => true, + ast::FunctionRetTy::Default(..) => true, _ => false }; @@ -2722,19 +2722,19 @@ impl<'a> State<'a> { try!(self.print_fn_args(decl, None, true)); try!(word(&mut self.s, "|")); - if let ast::DefaultReturn(..) = decl.output { + if let ast::FunctionRetTy::Default(..) = decl.output { return Ok(()); } try!(self.space_if_not_bol()); try!(self.word_space("->")); match decl.output { - ast::Return(ref ty) => { + ast::FunctionRetTy::Ty(ref ty) => { try!(self.print_type(&**ty)); self.maybe_print_comment(ty.span.lo) } - ast::DefaultReturn(..) => unreachable!(), - ast::NoReturn(span) => { + ast::FunctionRetTy::Default(..) => unreachable!(), + ast::FunctionRetTy::None(span) => { try!(self.word_nbsp("!")); self.maybe_print_comment(span.lo) } @@ -2988,7 +2988,7 @@ impl<'a> State<'a> { } pub fn print_fn_output(&mut self, decl: &ast::FnDecl) -> io::Result<()> { - if let ast::DefaultReturn(..) = decl.output { + if let ast::FunctionRetTy::Default(..) = decl.output { return Ok(()); } @@ -2996,16 +2996,16 @@ impl<'a> State<'a> { try!(self.ibox(INDENT_UNIT)); try!(self.word_space("->")); match decl.output { - ast::NoReturn(_) => + ast::FunctionRetTy::None(_) => try!(self.word_nbsp("!")), - ast::DefaultReturn(..) => unreachable!(), - ast::Return(ref ty) => + ast::FunctionRetTy::Default(..) => unreachable!(), + ast::FunctionRetTy::Ty(ref ty) => try!(self.print_type(&**ty)) } try!(self.end()); match decl.output { - ast::Return(ref output) => self.maybe_print_comment(output.span.lo), + ast::FunctionRetTy::Ty(ref output) => self.maybe_print_comment(output.span.lo), _ => Ok(()) } } @@ -3155,7 +3155,7 @@ mod tests { let decl = ast::FnDecl { inputs: Vec::new(), - output: ast::DefaultReturn(codemap::DUMMY_SP), + output: ast::FunctionRetTy::Default(codemap::DUMMY_SP), variadic: false }; let generics = ast::Generics::default(); diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 9a6d1f8fdab..054d57e90ea 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -357,8 +357,8 @@ fn is_test_fn(cx: &TestCtxt, i: &ast::Item) -> bool { match i.node { ast::ItemFn(ref decl, _, _, _, ref generics, _) => { let no_output = match decl.output { - ast::DefaultReturn(..) => true, - ast::Return(ref t) if t.node == ast::TyTup(vec![]) => true, + ast::FunctionRetTy::Default(..) => true, + ast::FunctionRetTy::Ty(ref t) if t.node == ast::TyTup(vec![]) => true, _ => false }; if decl.inputs.is_empty() @@ -394,8 +394,8 @@ fn is_bench_fn(cx: &TestCtxt, i: &ast::Item) -> bool { ast::ItemFn(ref decl, _, _, _, ref generics, _) => { let input_cnt = decl.inputs.len(); let no_output = match decl.output { - ast::DefaultReturn(..) => true, - ast::Return(ref t) if t.node == ast::TyTup(vec![]) => true, + ast::FunctionRetTy::Default(..) => true, + ast::FunctionRetTy::Ty(ref t) if t.node == ast::TyTup(vec![]) => true, _ => false }; let tparm_cnt = generics.ty_params.len(); diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 9b102cd99f3..834291dd561 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -524,7 +524,7 @@ pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics } pub fn walk_fn_ret_ty<'v, V: Visitor<'v>>(visitor: &mut V, ret_ty: &'v FunctionRetTy) { - if let Return(ref output_ty) = *ret_ty { + if let FunctionRetTy::Ty(ref output_ty) = *ret_ty { visitor.visit_ty(output_ty) } } |
