From 3b57d40fe5a813ac957667ac04938753e3100f55 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 8 Feb 2016 15:04:11 +0100 Subject: [PATCH] [breaking-change] don't glob import ast::FunctionRetTy variants --- src/librustc_front/lowering.rs | 6 +++--- src/librustc_trans/save/dump_csv.rs | 6 +++--- src/libsyntax/ast.rs | 13 ++++++------- src/libsyntax/ext/build.rs | 2 +- src/libsyntax/fold.rs | 6 +++--- src/libsyntax/parse/mod.rs | 2 +- src/libsyntax/parse/parser.rs | 14 +++++++------- src/libsyntax/print/pprust.rs | 22 +++++++++++----------- src/libsyntax/test.rs | 8 ++++---- src/libsyntax/visit.rs | 2 +- 10 files changed, 40 insertions(+), 41 deletions(-) diff --git a/src/librustc_front/lowering.rs b/src/librustc_front/lowering.rs index 662eaf136c2..2862a1811fb 100644 --- a/src/librustc_front/lowering.rs +++ b/src/librustc_front/lowering.rs @@ -450,9 +450,9 @@ pub fn lower_fn_decl(lctx: &LoweringContext, decl: &FnDecl) -> P { P(hir::FnDecl { inputs: decl.inputs.iter().map(|x| lower_arg(lctx, x)).collect(), output: match decl.output { - Return(ref ty) => hir::Return(lower_ty(lctx, ty)), - DefaultReturn(span) => hir::DefaultReturn(span), - NoReturn(span) => hir::NoReturn(span), + FunctionRetTy::Ty(ref ty) => hir::Return(lower_ty(lctx, ty)), + FunctionRetTy::Default(span) => hir::DefaultReturn(span), + FunctionRetTy::None(span) => hir::NoReturn(span), }, variadic: decl.variadic, }) diff --git a/src/librustc_trans/save/dump_csv.rs b/src/librustc_trans/save/dump_csv.rs index 25c30f2476d..9714e4f02b1 100644 --- a/src/librustc_trans/save/dump_csv.rs +++ b/src/librustc_trans/save/dump_csv.rs @@ -350,7 +350,7 @@ fn process_method(&mut self, self.visit_ty(&arg.ty); } - if let ast::Return(ref ret_ty) = sig.decl.output { + if let ast::FunctionRetTy::Ty(ref ret_ty) = sig.decl.output { self.visit_ty(ret_ty); } @@ -429,7 +429,7 @@ fn process_fn(&mut self, self.visit_ty(&arg.ty); } - if let ast::Return(ref ret_ty) = decl.output { + if let ast::FunctionRetTy::Ty(ref ret_ty) = decl.output { self.visit_ty(&ret_ty); } @@ -1141,7 +1141,7 @@ fn visit_expr(&mut self, ex: &ast::Expr) { self.visit_ty(&*arg.ty); } - if let ast::Return(ref ret_ty) = decl.output { + if let ast::FunctionRetTy::Ty(ref ret_ty) = decl.output { self.visit_ty(&**ret_ty); } 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::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 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 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(P), } 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 @@ fn arg(&self, span: Span, ident: ast::Ident, ty: P) -> ast::Arg { fn fn_decl(&self, inputs: Vec, output: P) -> P { 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(decl: P, fld: &mut T) -> P { 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 @@ fn parser_done(p: Parser){ }), 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::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::{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 @@ pub fn parse_mt(&mut self) -> PResult<'a, MutTy> { 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 @@ pub fn parse_lambda_expr(&mut self, lo: BytePos, { 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 @@ fn print_expr_outer_attr_style(&mut self, try!(space(&mut self.s)); let default_return = match decl.output { - ast::DefaultReturn(..) => true, + ast::FunctionRetTy::Default(..) => true, _ => false }; @@ -2722,19 +2722,19 @@ pub fn print_fn_block_args( 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 @@ pub fn print_arg(&mut self, input: &ast::Arg, is_closure: bool) -> io::Result<() } 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 @@ pub fn print_fn_output(&mut self, decl: &ast::FnDecl) -> io::Result<()> { 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 @@ fn test_fun_to_string() { 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 has_test_signature(i: &ast::Item) -> HasTestSignature { 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 has_test_signature(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) } }