Skip to content

Commit f4b9dc7

Browse files
Make name work for MatchSource
1 parent 929ff68 commit f4b9dc7

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/librustc/hir/mod.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -1749,6 +1749,20 @@ pub enum MatchSource {
17491749
AwaitDesugar,
17501750
}
17511751

1752+
impl MatchSource {
1753+
pub fn name(self) -> &'static str {
1754+
use MatchSource::*;
1755+
match self {
1756+
Normal => "match",
1757+
IfDesugar { .. } | IfLetDesugar { .. } => "if",
1758+
WhileDesugar | WhileLetDesugar => "while",
1759+
ForLoopDesugar => "for",
1760+
TryDesugar => "?",
1761+
AwaitDesugar => ".await",
1762+
}
1763+
}
1764+
}
1765+
17521766
/// The loop type that yielded an `ExprKind::Loop`.
17531767
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable)]
17541768
pub enum LoopSource {
@@ -1766,8 +1780,7 @@ impl LoopSource {
17661780
pub fn name(self) -> &'static str {
17671781
match self {
17681782
LoopSource::Loop => "loop",
1769-
LoopSource::While => "while",
1770-
LoopSource::WhileLet => "while let",
1783+
LoopSource::While | LoopSource::WhileLet => "while",
17711784
LoopSource::ForLoop => "for",
17721785
}
17731786
}

0 commit comments

Comments
 (0)