[breaking-change] don't glob import ast::FunctionRetTy variants
This commit is contained in:
parent
05e25de4f0
commit
3b57d40fe5
|
@ -450,9 +450,9 @@ pub fn lower_fn_decl(lctx: &LoweringContext, decl: &FnDecl) -> P<hir::FnDecl> {
|
|||
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,
|
||||
})
|
||||
|
|
|
@ -350,7 +350,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
|
|||
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 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
|
|||
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 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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
|
||||
})
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue