Fix ICE caused by suggestion with no code substitutions
Change suggestion logic to filter and checking _before_ creating specific resolution suggestion. Assert earlier that suggestions contain code substitions to make it easier in the future to debug invalid uses. If we find this becomes too noisy in the wild, we can always make the emitter resilient to these cases and remove the assertions. Fix #78651.
This commit is contained in:
parent
178108bf81
commit
04c2454b1e
4 changed files with 39 additions and 20 deletions
|
@ -295,6 +295,7 @@ impl Diagnostic {
|
|||
suggestion: Vec<(Span, String)>,
|
||||
applicability: Applicability,
|
||||
) -> &mut Self {
|
||||
assert!(!suggestion.is_empty());
|
||||
self.suggestions.push(CodeSuggestion {
|
||||
substitutions: vec![Substitution {
|
||||
parts: suggestion
|
||||
|
@ -318,6 +319,10 @@ impl Diagnostic {
|
|||
suggestions: Vec<Vec<(Span, String)>>,
|
||||
applicability: Applicability,
|
||||
) -> &mut Self {
|
||||
assert!(!suggestions.is_empty());
|
||||
for s in &suggestions {
|
||||
assert!(!s.is_empty());
|
||||
}
|
||||
self.suggestions.push(CodeSuggestion {
|
||||
substitutions: suggestions
|
||||
.into_iter()
|
||||
|
@ -348,6 +353,7 @@ impl Diagnostic {
|
|||
suggestion: Vec<(Span, String)>,
|
||||
applicability: Applicability,
|
||||
) -> &mut Self {
|
||||
assert!(!suggestion.is_empty());
|
||||
self.suggestions.push(CodeSuggestion {
|
||||
substitutions: vec![Substitution {
|
||||
parts: suggestion
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue