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 .
This commit is contained in:
parent
06754d8852
commit
34e9e6dff1
8 changed files with 12 additions and 24 deletions
|
@ -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 {
|
||||
|
|
|
@ -461,6 +461,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
|||
forward!(pub fn set_is_lint(&mut self,) -> &mut Self);
|
||||
|
||||
forward!(pub fn disable_suggestions(&mut self,) -> &mut Self);
|
||||
forward!(pub fn clear_suggestions(&mut self,) -> &mut Self);
|
||||
|
||||
forward!(pub fn multipart_suggestion(
|
||||
&mut self,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue