X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc%2Fhir%2Fmod.rs;h=64d22ae9435712dbdf4be923e25c8274bc15f2d8;hb=6d523ee501a1ae30428d22ce4fc3c1f720e896e6;hp=1f605711c8a8e97bc6630ac20dc30e3f0b77de67;hpb=a449535bbc7912c4adc1bbf2ab2738d0442f212c;p=rust.git diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 1f605711c8a..64d22ae9435 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", } }