diff options
| author | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2019-11-18 12:58:28 -0800 |
|---|---|---|
| committer | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2019-11-21 14:20:00 -0800 |
| commit | f4b9dc7d59ca4ebcf4841a80e83feb8fcaf353cc (patch) | |
| tree | 3e2fbdfd50d5237ee8de1b5dfbd578325395315f /src | |
| parent | 929ff68376e62b10f71df27481b97c42bb7a69d5 (diff) | |
| download | rust-f4b9dc7d59ca4ebcf4841a80e83feb8fcaf353cc.tar.gz rust-f4b9dc7d59ca4ebcf4841a80e83feb8fcaf353cc.zip | |
Make `name` work for `MatchSource`
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/hir/mod.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 17b13dae37f..6f34b42d91c 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -1749,6 +1749,20 @@ pub enum MatchSource { 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`. #[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable)] pub enum LoopSource { @@ -1766,8 +1780,7 @@ impl LoopSource { pub fn name(self) -> &'static str { match self { LoopSource::Loop => "loop", - LoopSource::While => "while", - LoopSource::WhileLet => "while let", + LoopSource::While | LoopSource::WhileLet => "while", LoopSource::ForLoop => "for", } } |
