Skip to content

Commit 314ed2d

Browse files
committed
Drop the Match prefix from the MatchSource variants
1 parent 7023bea commit 314ed2d

File tree

8 files changed

+25
-20
lines changed

8 files changed

+25
-20
lines changed

src/librustc/lint/builtin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,9 +1157,9 @@ impl LintPass for UnusedParens {
11571157
ast::ExprIf(ref cond, _, _) => (cond, "`if` condition", true),
11581158
ast::ExprWhile(ref cond, _, _) => (cond, "`while` condition", true),
11591159
ast::ExprMatch(ref head, _, source) => match source {
1160-
ast::MatchNormal => (head, "`match` head expression", true),
1161-
ast::MatchIfLetDesugar => (head, "`if let` head expression", true),
1162-
ast::MatchWhileLetDesugar => (head, "`while let` head expression", true),
1160+
ast::MatchSource::Normal => (head, "`match` head expression", true),
1161+
ast::MatchSource::IfLetDesugar { .. } => (head, "`if let` head expression", true),
1162+
ast::MatchSource::WhileLetDesugar => (head, "`while let` head expression", true),
11631163
},
11641164
ast::ExprRet(Some(ref value)) => (value, "`return` value", false),
11651165
ast::ExprAssign(_, ref value) => (value, "assigned value", false),

src/librustc/middle/check_match.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ fn check_arms(cx: &MatchCheckCtxt,
307307
match is_useful(cx, &seen, v.as_slice(), LeaveOutWitness) {
308308
NotUseful => {
309309
match source {
310-
ast::MatchIfLetDesugar => {
310+
ast::MatchSource::IfLetDesugar { .. } => {
311311
if printed_if_let_err {
312312
// we already printed an irrefutable if-let pattern error.
313313
// We don't want two, that's just confusing.
@@ -321,15 +321,15 @@ fn check_arms(cx: &MatchCheckCtxt,
321321
}
322322
},
323323

324-
ast::MatchWhileLetDesugar => {
324+
ast::MatchSource::WhileLetDesugar => {
325325
// find the first arm pattern so we can use its span
326326
let &(ref first_arm_pats, _) = &arms[0];
327327
let first_pat = &first_arm_pats[0];
328328
let span = first_pat.span;
329329
span_err!(cx.tcx.sess, span, E0165, "irrefutable while-let pattern");
330330
},
331331

332-
ast::MatchNormal => {
332+
ast::MatchSource::Normal => {
333333
span_err!(cx.tcx.sess, pat.span, E0001, "unreachable pattern")
334334
},
335335
}

src/librustc/util/ppaux.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
9393
ast::ExprMethodCall(..) => {
9494
explain_span(cx, "method call", expr.span)
9595
},
96-
ast::ExprMatch(_, _, ast::MatchIfLetDesugar) => explain_span(cx, "if let", expr.span),
97-
ast::ExprMatch(_, _, ast::MatchWhileLetDesugar) => {
96+
ast::ExprMatch(_, _, ast::MatchSource::IfLetDesugar { .. }) =>
97+
explain_span(cx, "if let", expr.span),
98+
ast::ExprMatch(_, _, ast::MatchSource::WhileLetDesugar) => {
9899
explain_span(cx, "while let", expr.span)
99100
},
100101
ast::ExprMatch(..) => explain_span(cx, "match", expr.span),

src/librustc_typeck/check/_match.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ pub fn check_match<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
293293
} else {
294294
let (origin, expected, found) = match match_src {
295295
/* if-let construct without an else block */
296-
ast::MatchIfLetDesugar(contains_else_arm) if !contains_else_arm => (
296+
ast::MatchSource::IfLetDesugar { contains_else_clause }
297+
if !contains_else_clause => (
297298
infer::IfExpressionWithNoElse(expr.span),
298299
bty,
299300
result_ty,

src/libsyntax/ast.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ pub use self::LitIntType::*;
3232
pub use self::LocalSource::*;
3333
pub use self::Mac_::*;
3434
pub use self::MacStmtStyle::*;
35-
pub use self::MatchSource::*;
3635
pub use self::MetaItem_::*;
3736
pub use self::Method_::*;
3837
pub use self::Mutability::*;
@@ -753,9 +752,9 @@ pub struct QPath {
753752

754753
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
755754
pub enum MatchSource {
756-
MatchNormal,
757-
MatchIfLetDesugar(bool /* contains_else_arm */),
758-
MatchWhileLetDesugar,
755+
Normal,
756+
IfLetDesugar { contains_else_clause: bool },
757+
WhileLetDesugar,
759758
}
760759

761760
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]

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::MatchNormal))
871+
self.expr(span, ast::ExprMatch(arg, arms, ast::MatchSource::Normal))
872872
}
873873

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

src/libsyntax/ext/expand.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
9797
// `match <expr> { ... }`
9898
let arms = vec![pat_arm, break_arm];
9999
let match_expr = fld.cx.expr(span,
100-
ast::ExprMatch(expr, arms, ast::MatchWhileLetDesugar));
100+
ast::ExprMatch(expr, arms, ast::MatchSource::WhileLetDesugar));
101101

102102
// `[opt_ident]: loop { ... }`
103103
let loop_block = fld.cx.block_expr(match_expr);
@@ -158,6 +158,8 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
158158
arms
159159
};
160160

161+
let contains_else_clause = elseopt.is_some();
162+
161163
// `_ => [<elseopt> | ()]`
162164
let else_arm = {
163165
let pat_under = fld.cx.pat_wild(span);
@@ -170,9 +172,11 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
170172
arms.extend(else_if_arms.into_iter());
171173
arms.push(else_arm);
172174

173-
let match_expr = fld.cx.expr(span, ast::ExprMatch(expr,
174-
arms,
175-
ast::MatchIfLetDesugar(elseopt.is_some())));
175+
let match_expr = fld.cx.expr(span,
176+
ast::ExprMatch(expr, arms,
177+
ast::MatchSource::IfLetDesugar {
178+
contains_else_clause: contains_else_clause,
179+
}));
176180
fld.fold_expr(match_expr)
177181
}
178182

src/libsyntax/parse/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use ast::{LifetimeDef, Lit, Lit_};
4141
use ast::{LitBool, LitChar, LitByte, LitBinary};
4242
use ast::{LitStr, LitInt, Local, LocalLet};
4343
use ast::{MacStmtWithBraces, MacStmtWithSemicolon, MacStmtWithoutBraces};
44-
use ast::{MutImmutable, MutMutable, Mac_, MacInvocTT, MatchNormal};
44+
use ast::{MutImmutable, MutMutable, Mac_, MacInvocTT, MatchSource};
4545
use ast::{Method, MutTy, BiMul, Mutability};
4646
use ast::{MethodImplItem, NamedField, UnNeg, NoReturn, NodeId, UnNot};
4747
use ast::{Pat, PatEnum, PatIdent, PatLit, PatRange, PatRegion, PatStruct};
@@ -3114,7 +3114,7 @@ impl<'a> Parser<'a> {
31143114
}
31153115
let hi = self.span.hi;
31163116
self.bump();
3117-
return self.mk_expr(lo, hi, ExprMatch(discriminant, arms, MatchNormal));
3117+
return self.mk_expr(lo, hi, ExprMatch(discriminant, arms, MatchSource::Normal));
31183118
}
31193119

31203120
pub fn parse_arm(&mut self) -> Arm {

0 commit comments

Comments
 (0)