Remove ast::LocalSource with only one used variant

`LocalSource` indicated wether a let binding originated from for-loop desugaring to enable specialized error messages, but for-loop expansion has changed and this is now achieved through `MatchSource::ForLoopDesugar`.
This commit is contained in:
mitaa 2015-07-25 22:43:35 +02:00
parent 7276d8b761
commit adfdbc4bd7
6 changed files with 4 additions and 25 deletions

View File

@ -1016,16 +1016,10 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
fn check_local(cx: &mut MatchCheckCtxt, loc: &ast::Local) {
visit::walk_local(cx, loc);
let name = match loc.source {
ast::LocalLet => "local",
ast::LocalFor => "`for` loop"
};
let mut static_inliner = StaticInliner::new(cx.tcx, None);
is_refutable(cx, &*static_inliner.fold_pat(loc.pat.clone()), |pat| {
span_err!(cx.tcx.sess, loc.pat.span, E0005,
"refutable pattern in {} binding: `{}` not covered",
name, pat_to_string(pat)
"refutable pattern in local binding: `{}` not covered", pat_to_string(pat)
);
});

View File

@ -29,7 +29,6 @@ pub use self::Item_::*;
pub use self::KleeneOp::*;
pub use self::Lit_::*;
pub use self::LitIntType::*;
pub use self::LocalSource::*;
pub use self::Mac_::*;
pub use self::MacStmtStyle::*;
pub use self::MetaItem_::*;
@ -756,14 +755,6 @@ pub enum MacStmtStyle {
MacStmtWithoutBraces,
}
/// Where a local declaration came from: either a true `let ... =
/// ...;`, or one desugared from the pattern of a for loop.
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
pub enum LocalSource {
LocalLet,
LocalFor,
}
// FIXME (pending discussion of #1697, #2178...): local should really be
// a refinement on pat.
/// Local represents a `let` statement, e.g., `let <pat>:<ty> = <expr>;`
@ -775,7 +766,6 @@ pub struct Local {
pub init: Option<P<Expr>>,
pub id: NodeId,
pub span: Span,
pub source: LocalSource,
}
pub type Decl = Spanned<Decl_>;

View File

@ -538,7 +538,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
init: Some(ex),
id: ast::DUMMY_NODE_ID,
span: sp,
source: ast::LocalLet,
});
let decl = respan(sp, ast::DeclLocal(local));
P(respan(sp, ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID)))
@ -562,7 +561,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
init: Some(ex),
id: ast::DUMMY_NODE_ID,
span: sp,
source: ast::LocalLet,
});
let decl = respan(sp, ast::DeclLocal(local));
P(respan(sp, ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID)))

View File

@ -911,7 +911,7 @@ fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroE
StmtDecl(decl, node_id) => decl.and_then(|Spanned {node: decl, span}| match decl {
DeclLocal(local) => {
// take it apart:
let rewritten_local = local.map(|Local {id, pat, ty, init, source, span}| {
let rewritten_local = local.map(|Local {id, pat, ty, init, span}| {
// expand the ty since TyFixedLengthVec contains an Expr
// and thus may have a macro use
let expanded_ty = ty.map(|t| fld.fold_ty(t));
@ -941,7 +941,6 @@ fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroE
pat: rewritten_pat,
// also, don't forget to expand the init:
init: init.map(|e| fld.fold_expr(e)),
source: source,
span: span
}
});

View File

@ -515,12 +515,11 @@ pub fn noop_fold_parenthesized_parameter_data<T: Folder>(data: ParenthesizedPara
}
pub fn noop_fold_local<T: Folder>(l: P<Local>, fld: &mut T) -> P<Local> {
l.map(|Local {id, pat, ty, init, source, span}| Local {
l.map(|Local {id, pat, ty, init, span}| Local {
id: fld.new_id(id),
ty: ty.map(|t| fld.fold_ty(t)),
pat: fld.fold_pat(pat),
init: init.map(|e| fld.fold_expr(e)),
source: source,
span: fld.new_span(span)
})
}

View File

@ -35,7 +35,7 @@ use ast::{ItemMac, ItemMod, ItemStruct, ItemTrait, ItemTy, ItemDefaultImpl};
use ast::{ItemExternCrate, ItemUse};
use ast::{LifetimeDef, Lit, Lit_};
use ast::{LitBool, LitChar, LitByte, LitBinary};
use ast::{LitStr, LitInt, Local, LocalLet};
use ast::{LitStr, LitInt, Local};
use ast::{MacStmtWithBraces, MacStmtWithSemicolon, MacStmtWithoutBraces};
use ast::{MutImmutable, MutMutable, Mac_, MacInvocTT, MatchSource};
use ast::{MutTy, BiMul, Mutability};
@ -3432,7 +3432,6 @@ impl<'a> Parser<'a> {
init: init,
id: ast::DUMMY_NODE_ID,
span: mk_sp(lo, self.last_span.hi),
source: LocalLet,
}))
}