1
Fork 0

Use verbose style when suggesting changing const with let

This commit is contained in:
Esteban Küber 2024-07-05 19:32:17 +00:00
parent bcf1f6db45
commit b56dc8ee90
20 changed files with 153 additions and 82 deletions

View file

@ -836,11 +836,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
let ((with, with_label), without) = match sp {
Some(sp) if !self.tcx.sess.source_map().is_multiline(sp) => {
let sp = sp.with_lo(BytePos(sp.lo().0 - (current.len() as u32)));
let sp = sp
.with_lo(BytePos(sp.lo().0 - (current.len() as u32)))
.until(ident.span);
(
(Some(errs::AttemptToUseNonConstantValueInConstantWithSuggestion {
span: sp,
ident,
suggestion,
current,
}), Some(errs::AttemptToUseNonConstantValueInConstantLabelWithSuggestion {span})),

View file

@ -242,13 +242,13 @@ pub(crate) struct AttemptToUseNonConstantValueInConstant<'a> {
#[derive(Subdiagnostic)]
#[suggestion(
resolve_attempt_to_use_non_constant_value_in_constant_with_suggestion,
code = "{suggestion} {ident}",
code = "{suggestion} ",
style = "verbose",
applicability = "maybe-incorrect"
)]
pub(crate) struct AttemptToUseNonConstantValueInConstantWithSuggestion<'a> {
#[primary_span]
pub(crate) span: Span,
pub(crate) ident: Ident,
pub(crate) suggestion: &'a str,
pub(crate) current: &'a str,
}