Make name
work for MatchSource
This commit is contained in:
parent
929ff68376
commit
f4b9dc7d59
1 changed files with 15 additions and 2 deletions
|
@ -1749,6 +1749,20 @@ pub enum MatchSource {
|
||||||
AwaitDesugar,
|
AwaitDesugar,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl MatchSource {
|
||||||
|
pub fn name(self) -> &'static str {
|
||||||
|
use MatchSource::*;
|
||||||
|
match self {
|
||||||
|
Normal => "match",
|
||||||
|
IfDesugar { .. } | IfLetDesugar { .. } => "if",
|
||||||
|
WhileDesugar | WhileLetDesugar => "while",
|
||||||
|
ForLoopDesugar => "for",
|
||||||
|
TryDesugar => "?",
|
||||||
|
AwaitDesugar => ".await",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The loop type that yielded an `ExprKind::Loop`.
|
/// The loop type that yielded an `ExprKind::Loop`.
|
||||||
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable)]
|
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable)]
|
||||||
pub enum LoopSource {
|
pub enum LoopSource {
|
||||||
|
@ -1766,8 +1780,7 @@ impl LoopSource {
|
||||||
pub fn name(self) -> &'static str {
|
pub fn name(self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
LoopSource::Loop => "loop",
|
LoopSource::Loop => "loop",
|
||||||
LoopSource::While => "while",
|
LoopSource::While | LoopSource::WhileLet => "while",
|
||||||
LoopSource::WhileLet => "while let",
|
|
||||||
LoopSource::ForLoop => "for",
|
LoopSource::ForLoop => "for",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue