diff options
| author | Daniel Xu <dxu@dxuuu.xyz> | 2022-07-08 21:03:03 -0500 |
|---|---|---|
| committer | Daniel Xu <dxu@dxuuu.xyz> | 2022-07-08 21:03:03 -0500 |
| commit | 34e9e6dff1449bddd9a66e744423797e01aec43c (patch) | |
| tree | 3fa4ba6ab1c5b3b8f83b698e480fca9f29ff2dff /compiler/rustc_errors/src/diagnostic.rs | |
| parent | 06754d8852bea286a3a76d373ccd17e66afb5a8b (diff) | |
| download | rust-34e9e6dff1449bddd9a66e744423797e01aec43c.tar.gz rust-34e9e6dff1449bddd9a66e744423797e01aec43c.zip | |
Fix duplicated type annotation suggestion
Before, there was more or less duplicated suggestions to add type hints. Fix by clearing more generic suggestions when a more specific suggestion is possible. This fixes #93506 .
Diffstat (limited to 'compiler/rustc_errors/src/diagnostic.rs')
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 9429ad1a897..da321c45875 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -614,6 +614,14 @@ impl Diagnostic { self } + /// Clear any existing suggestions. + pub fn clear_suggestions(&mut self) -> &mut Self { + if let Ok(suggestions) = &mut self.suggestions { + suggestions.clear(); + } + self + } + /// Helper for pushing to `self.suggestions`, if available (not disable). fn push_suggestion(&mut self, suggestion: CodeSuggestion) { if let Ok(suggestions) = &mut self.suggestions { |
