Skip to content

Commit ba43c22

Browse files
committed
Some cleanup of no longer used AST things
1 parent 21205f4 commit ba43c22

File tree

14 files changed

+19
-68
lines changed

14 files changed

+19
-68
lines changed

src/librustc_front/lowering.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -955,8 +955,8 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
955955
// might be `if let`.
956956
ExprIf(ref cond, ref blk, ref else_opt) => {
957957
let else_opt = else_opt.as_ref().map(|els| match els.node {
958-
let _old_cached = CachedIdSetter::new(lctx, e.id);
959958
ExprIfLet(..) => {
959+
let _old_cached = CachedIdSetter::new(lctx, e.id);
960960
// wrap the if-let expr in a block
961961
let span = els.span;
962962
let blk = P(hir::Block {
@@ -984,10 +984,10 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
984984
hir::ExprLoop(lower_block(lctx, body),
985985
opt_ident)
986986
}
987-
ExprMatch(ref expr, ref arms, ref source) => {
987+
ExprMatch(ref expr, ref arms) => {
988988
hir::ExprMatch(lower_expr(lctx, expr),
989989
arms.iter().map(|x| lower_arm(lctx, x)).collect(),
990-
lower_match_source(lctx, source))
990+
hir::MatchSource::Normal)
991991
}
992992
ExprClosure(capture_clause, ref decl, ref body) => {
993993
hir::ExprClosure(lower_capture_clause(lctx, capture_clause),
@@ -1310,17 +1310,6 @@ pub fn lower_stmt(_lctx: &LoweringContext, s: &Stmt) -> P<hir::Stmt> {
13101310
}
13111311
}
13121312

1313-
pub fn lower_match_source(_lctx: &LoweringContext, m: &MatchSource) -> hir::MatchSource {
1314-
match *m {
1315-
MatchSource::Normal => hir::MatchSource::Normal,
1316-
MatchSource::IfLetDesugar { contains_else_clause } => {
1317-
hir::MatchSource::IfLetDesugar { contains_else_clause: contains_else_clause }
1318-
}
1319-
MatchSource::WhileLetDesugar => hir::MatchSource::WhileLetDesugar,
1320-
MatchSource::ForLoopDesugar => hir::MatchSource::ForLoopDesugar,
1321-
}
1322-
}
1323-
13241313
pub fn lower_capture_clause(_lctx: &LoweringContext, c: CaptureClause) -> hir::CaptureClause {
13251314
match c {
13261315
CaptureByValue => hir::CaptureByValue,

src/librustc_lint/unused.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ impl EarlyLintPass for UnusedParens {
366366
ast::ExprIfLet(_, ref cond, _, _) => (cond, "`if let` head expression", true),
367367
ast::ExprWhileLet(_, ref cond, _, _) => (cond, "`while let` head expression", true),
368368
ast::ExprForLoop(_, ref cond, _, _) => (cond, "`for` head expression", true),
369-
ast::ExprMatch(ref head, _, _) => (head, "`match` head expression", true),
369+
ast::ExprMatch(ref head, _) => (head, "`match` head expression", true),
370370
ast::ExprRet(Some(ref value)) => (value, "`return` value", false),
371371
ast::ExprAssign(_, ref value) => (value, "assigned value", false),
372372
ast::ExprAssignOp(_, _, ref value) => (value, "assigned value", false),

src/librustdoc/core.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec<String>, externs: Externs,
135135

136136
let krate = driver::assign_node_ids(&sess, krate);
137137
// Lower ast -> hir.
138-
let foo = &42;
139-
let lcx = LoweringContext::new(foo, &sess, &krate);
138+
let lcx = LoweringContext::new(&sess, &krate);
140139
let mut hir_forest = hir_map::Forest::new(lower_crate(&lcx, &krate));
141140
let arenas = ty::CtxtArenas::new();
142141
let hir_map = driver::make_map(&sess, &mut hir_forest);

src/librustdoc/test.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ pub fn run(input: &str,
8383
"rustdoc-test", None)
8484
.expect("phase_2_configure_and_expand aborted in rustdoc!");
8585
let krate = driver::assign_node_ids(&sess, krate);
86-
let foo = &42;
87-
let lcx = LoweringContext::new(foo, &sess, &krate);
86+
let lcx = LoweringContext::new(&sess, &krate);
8887
let krate = lower_crate(&lcx, &krate);
8988

9089
let opts = scrape_test_config(&krate);

src/libsyntax/ast.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -855,9 +855,8 @@ pub enum Expr_ {
855855
///
856856
/// `'label: loop { block }`
857857
ExprLoop(P<Block>, Option<Ident>),
858-
/// A `match` block, with a source that indicates whether or not it is
859-
/// the result of a desugaring, and if so, which kind.
860-
ExprMatch(P<Expr>, Vec<Arm>, MatchSource),
858+
/// A `match` block.
859+
ExprMatch(P<Expr>, Vec<Arm>),
861860
/// A closure (for example, `move |a, b, c| {a + b + c}`)
862861
ExprClosure(CaptureClause, P<FnDecl>, P<Block>),
863862
/// A block (`{ ... }`)
@@ -936,14 +935,6 @@ pub struct QSelf {
936935
pub position: usize
937936
}
938937

939-
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
940-
pub enum MatchSource {
941-
Normal,
942-
IfLetDesugar { contains_else_clause: bool },
943-
WhileLetDesugar,
944-
ForLoopDesugar,
945-
}
946-
947938
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
948939
pub enum CaptureClause {
949940
CaptureByValue,

src/libsyntax/codemap.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use std::io::{self, Read};
2929

3030
use serialize::{Encodable, Decodable, Encoder, Decoder};
3131

32-
use parse::token::intern;
3332
use ast::Name;
3433

3534
// _____________________________________________________________________________
@@ -269,28 +268,8 @@ pub enum ExpnFormat {
269268
MacroAttribute(Name),
270269
/// e.g. `format!()`
271270
MacroBang(Name),
272-
/// Syntax sugar expansion performed by the compiler (libsyntax::expand).
273-
CompilerExpansion(CompilerExpansionFormat),
274271
}
275272

276-
#[derive(Clone, Copy, Hash, Debug, PartialEq, Eq)]
277-
pub enum CompilerExpansionFormat {
278-
IfLet,
279-
PlacementIn,
280-
WhileLet,
281-
ForLoop,
282-
}
283-
284-
impl CompilerExpansionFormat {
285-
pub fn name(self) -> &'static str {
286-
match self {
287-
CompilerExpansionFormat::IfLet => "if let expansion",
288-
CompilerExpansionFormat::PlacementIn => "placement-in expansion",
289-
CompilerExpansionFormat::WhileLet => "while let expansion",
290-
CompilerExpansionFormat::ForLoop => "for loop expansion",
291-
}
292-
}
293-
}
294273
#[derive(Clone, Hash, Debug)]
295274
pub struct NameAndSpan {
296275
/// The format with which the macro was invoked.
@@ -310,7 +289,6 @@ impl NameAndSpan {
310289
match self.format {
311290
ExpnFormat::MacroAttribute(s) => s,
312291
ExpnFormat::MacroBang(s) => s,
313-
ExpnFormat::CompilerExpansion(ce) => intern(ce.name()),
314292
}
315293
}
316294
}

src/libsyntax/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,10 @@ fn fold_expr<F>(cx: &mut Context<F>, expr: P<ast::Expr>) -> P<ast::Expr> where
225225
fold::noop_fold_expr(ast::Expr {
226226
id: id,
227227
node: match node {
228-
ast::ExprMatch(m, arms, source) => {
228+
ast::ExprMatch(m, arms) => {
229229
ast::ExprMatch(m, arms.into_iter()
230230
.filter(|a| (cx.in_cfg)(&a.attrs))
231-
.collect(), source)
231+
.collect())
232232
}
233233
_ => node
234234
},

src/libsyntax/diagnostic.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,6 @@ impl EmitterWriter {
737737
let (pre, post) = match ei.callee.format {
738738
codemap::MacroAttribute(..) => ("#[", "]"),
739739
codemap::MacroBang(..) => ("", "!"),
740-
codemap::CompilerExpansion(..) => ("", ""),
741740
};
742741
// Don't print recursive invocations
743742
if ei.call_site != last_span {

src/libsyntax/ext/base.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub use self::SyntaxExtension::*;
1313
use ast;
1414
use ast::Name;
1515
use codemap;
16-
use codemap::{CodeMap, Span, ExpnId, ExpnInfo, NO_EXPANSION, CompilerExpansion};
16+
use codemap::{CodeMap, Span, ExpnId, ExpnInfo, NO_EXPANSION};
1717
use ext;
1818
use ext::expand;
1919
use ext::tt::macro_rules;
@@ -651,10 +651,7 @@ impl<'a> ExtCtxt<'a> {
651651
return None;
652652
}
653653
expn_id = i.call_site.expn_id;
654-
match i.callee.format {
655-
CompilerExpansion(..) => (),
656-
_ => last_macro = Some(i.call_site),
657-
}
654+
last_macro = Some(i.call_site);
658655
return Some(());
659656
})
660657
}).is_none() {

src/libsyntax/ext/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
868868
}
869869

870870
fn expr_match(&self, span: Span, arg: P<ast::Expr>, arms: Vec<ast::Arm>) -> P<Expr> {
871-
self.expr(span, ast::ExprMatch(arg, arms, ast::MatchSource::Normal))
871+
self.expr(span, ast::ExprMatch(arg, arms))
872872
}
873873

874874
fn expr_if(&self, span: Span, cond: P<ast::Expr>,

0 commit comments

Comments
 (0)