Auto merge of #110041 - fmease:diag-sugg-adding-const-param, r=compiler-errors

Suggest defining const parameter when appropriate

Helps a bit with #91119.
Following #105523's lead, I use placeholder `/* Type */` instead of `_` in the suggestion.
It should be easier for newcomers to parse.

`@rustbot` label A-diagnostics
r? diagnostics
This commit is contained in:
bors
2023-04-09 10:54:04 +00:00
4 changed files with 100 additions and 7 deletions

View File

@@ -3467,8 +3467,8 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
sugg.to_string(),
Applicability::MaybeIncorrect,
))
} else if res.is_none() && matches!(source, PathSource::Type) {
this.report_missing_type_error(path)
} else if res.is_none() && let PathSource::Type | PathSource::Expr(_) = source {
this.suggest_adding_generic_parameter(path, source)
} else {
None
};