Fix #131471, range misleading field access

Fixes #131471 by checking if the range-start is a literal.
This commit is contained in:
Falco Hirschenberger 2024-10-11 10:46:38 +02:00
parent 1350eead10
commit 8f2273e518
3 changed files with 18 additions and 0 deletions

View file

@ -4011,6 +4011,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
let instead = res.is_some();
let suggestion = if let Some((start, end)) = this.diag_metadata.in_range
&& path[0].ident.span.lo() == end.span.lo()
&& !matches!(start.kind, ExprKind::Lit(_))
{
let mut sugg = ".";
let mut span = start.span.between(end.span);