Account for let foo = expr; to suggest const foo: Ty = expr;

This commit is contained in:
Esteban Küber
2024-07-08 19:43:20 +00:00
parent b56dc8ee90
commit cbe75486f7
13 changed files with 85 additions and 56 deletions

View File

@@ -819,7 +819,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
ResolutionError::CannotCaptureDynamicEnvironmentInFnItem => {
self.dcx().create_err(errs::CannotCaptureDynamicEnvironmentInFnItem { span })
}
ResolutionError::AttemptToUseNonConstantValueInConstant(ident, suggestion, current) => {
ResolutionError::AttemptToUseNonConstantValueInConstant {
ident,
suggestion,
current,
type_span,
} => {
// let foo =...
// ^^^ given this Span
// ------- get this Span to have an applicable suggestion
@@ -844,6 +849,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
span: sp,
suggestion,
current,
type_span,
}), Some(errs::AttemptToUseNonConstantValueInConstantLabelWithSuggestion {span})),
None,
)