diff options
| author | Maybe Waffle <waffle.lapkin@gmail.com> | 2023-01-30 11:03:32 +0000 |
|---|---|---|
| committer | Maybe Waffle <waffle.lapkin@gmail.com> | 2023-01-30 12:26:26 +0000 |
| commit | fd649a3cc5e9f17c8aee070227e8c71f094560b7 (patch) | |
| tree | b2d741c4f018a744f79877a8ca669a2617c652e1 /compiler/rustc_errors/src | |
| parent | f55b0022db8dccc6aa6bf3f650b562eaec0fdc54 (diff) | |
| download | rust-fd649a3cc5e9f17c8aee070227e8c71f094560b7.tar.gz rust-fd649a3cc5e9f17c8aee070227e8c71f094560b7.zip | |
Replace enum `==`s with `match`es where it makes sense
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/emitter.rs | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 628e1999921..faeaa548619 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -2113,30 +2113,38 @@ impl EmitterWriter { } } for sugg in suggestions { - if sugg.style == SuggestionStyle::CompletelyHidden { - // do not display this suggestion, it is meant only for tools - } else if sugg.style == SuggestionStyle::HideCodeAlways { - if let Err(e) = self.emit_message_default( - &MultiSpan::new(), - &[(sugg.msg.to_owned(), Style::HeaderMsg)], - args, - &None, - &Level::Help, - max_line_num_len, - true, - None, - ) { - panic!("failed to emit error: {}", e); + match sugg.style { + SuggestionStyle::CompletelyHidden => { + // do not display this suggestion, it is meant only for tools } - } else if let Err(e) = self.emit_suggestion_default( - span, - sugg, - args, - &Level::Help, - max_line_num_len, - ) { - panic!("failed to emit error: {}", e); - }; + SuggestionStyle::HideCodeAlways => { + if let Err(e) = self.emit_message_default( + &MultiSpan::new(), + &[(sugg.msg.to_owned(), Style::HeaderMsg)], + args, + &None, + &Level::Help, + max_line_num_len, + true, + None, + ) { + panic!("failed to emit error: {}", e); + } + } + SuggestionStyle::HideCodeInline + | SuggestionStyle::ShowCode + | SuggestionStyle::ShowAlways => { + if let Err(e) = self.emit_suggestion_default( + span, + sugg, + args, + &Level::Help, + max_line_num_len, + ) { + panic!("failed to emit error: {}", e); + } + } + } } } } |
