Skip to content

Commit adfdbc4

Browse files
committed
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`.
1 parent 7276d8b commit adfdbc4

File tree

6 files changed

+4
-25
lines changed

6 files changed

+4
-25
lines changed

src/librustc/middle/check_match.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,16 +1016,10 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
10161016
fn check_local(cx: &mut MatchCheckCtxt, loc: &ast::Local) {
10171017
visit::walk_local(cx, loc);
10181018

1019-
let name = match loc.source {
1020-
ast::LocalLet => "local",
1021-
ast::LocalFor => "`for` loop"
1022-
};
1023-
10241019
let mut static_inliner = StaticInliner::new(cx.tcx, None);
10251020
is_refutable(cx, &*static_inliner.fold_pat(loc.pat.clone()), |pat| {
10261021
span_err!(cx.tcx.sess, loc.pat.span, E0005,
1027-
"refutable pattern in {} binding: `{}` not covered",
1028-
name, pat_to_string(pat)
1022+
"refutable pattern in local binding: `{}` not covered", pat_to_string(pat)
10291023
);
10301024
});
10311025

src/libsyntax/ast.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ pub use self::Item_::*;
2929
pub use self::KleeneOp::*;
3030
pub use self::Lit_::*;
3131
pub use self::LitIntType::*;
32-
pub use self::LocalSource::*;
3332
pub use self::Mac_::*;
3433
pub use self::MacStmtStyle::*;
3534
pub use self::MetaItem_::*;
@@ -756,14 +755,6 @@ pub enum MacStmtStyle {
756755
MacStmtWithoutBraces,
757756
}
758757

759-
/// Where a local declaration came from: either a true `let ... =
760-
/// ...;`, or one desugared from the pattern of a for loop.
761-
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
762-
pub enum LocalSource {
763-
LocalLet,
764-
LocalFor,
765-
}
766-
767758
// FIXME (pending discussion of #1697, #2178...): local should really be
768759
// a refinement on pat.
769760
/// Local represents a `let` statement, e.g., `let <pat>:<ty> = <expr>;`
@@ -775,7 +766,6 @@ pub struct Local {
775766
pub init: Option<P<Expr>>,
776767
pub id: NodeId,
777768
pub span: Span,
778-
pub source: LocalSource,
779769
}
780770

781771
pub type Decl = Spanned<Decl_>;

src/libsyntax/ext/build.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
538538
init: Some(ex),
539539
id: ast::DUMMY_NODE_ID,
540540
span: sp,
541-
source: ast::LocalLet,
542541
});
543542
let decl = respan(sp, ast::DeclLocal(local));
544543
P(respan(sp, ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID)))
@@ -562,7 +561,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
562561
init: Some(ex),
563562
id: ast::DUMMY_NODE_ID,
564563
span: sp,
565-
source: ast::LocalLet,
566564
});
567565
let decl = respan(sp, ast::DeclLocal(local));
568566
P(respan(sp, ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID)))

src/libsyntax/ext/expand.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroE
911911
StmtDecl(decl, node_id) => decl.and_then(|Spanned {node: decl, span}| match decl {
912912
DeclLocal(local) => {
913913
// take it apart:
914-
let rewritten_local = local.map(|Local {id, pat, ty, init, source, span}| {
914+
let rewritten_local = local.map(|Local {id, pat, ty, init, span}| {
915915
// expand the ty since TyFixedLengthVec contains an Expr
916916
// and thus may have a macro use
917917
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
941941
pat: rewritten_pat,
942942
// also, don't forget to expand the init:
943943
init: init.map(|e| fld.fold_expr(e)),
944-
source: source,
945944
span: span
946945
}
947946
});

src/libsyntax/fold.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,12 +515,11 @@ pub fn noop_fold_parenthesized_parameter_data<T: Folder>(data: ParenthesizedPara
515515
}
516516

517517
pub fn noop_fold_local<T: Folder>(l: P<Local>, fld: &mut T) -> P<Local> {
518-
l.map(|Local {id, pat, ty, init, source, span}| Local {
518+
l.map(|Local {id, pat, ty, init, span}| Local {
519519
id: fld.new_id(id),
520520
ty: ty.map(|t| fld.fold_ty(t)),
521521
pat: fld.fold_pat(pat),
522522
init: init.map(|e| fld.fold_expr(e)),
523-
source: source,
524523
span: fld.new_span(span)
525524
})
526525
}

src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use ast::{ItemMac, ItemMod, ItemStruct, ItemTrait, ItemTy, ItemDefaultImpl};
3535
use ast::{ItemExternCrate, ItemUse};
3636
use ast::{LifetimeDef, Lit, Lit_};
3737
use ast::{LitBool, LitChar, LitByte, LitBinary};
38-
use ast::{LitStr, LitInt, Local, LocalLet};
38+
use ast::{LitStr, LitInt, Local};
3939
use ast::{MacStmtWithBraces, MacStmtWithSemicolon, MacStmtWithoutBraces};
4040
use ast::{MutImmutable, MutMutable, Mac_, MacInvocTT, MatchSource};
4141
use ast::{MutTy, BiMul, Mutability};
@@ -3432,7 +3432,6 @@ impl<'a> Parser<'a> {
34323432
init: init,
34333433
id: ast::DUMMY_NODE_ID,
34343434
span: mk_sp(lo, self.last_span.hi),
3435-
source: LocalLet,
34363435
}))
34373436
}
34383437

0 commit comments

Comments
 (0)