Fix #131471, range misleading field access
Fixes #131471 by checking if the range-start is a literal.
This commit is contained in:
parent
1350eead10
commit
8f2273e518
@ -4011,6 +4011,7 @@ fn smart_resolve_path_fragment(
|
||||
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);
|
||||
|
8
tests/ui/range/misleading-field-access-hint.rs
Normal file
8
tests/ui/range/misleading-field-access-hint.rs
Normal file
@ -0,0 +1,8 @@
|
||||
// Check if rustc still displays the misleading hint to write `.` instead of `..`
|
||||
fn main() {
|
||||
let width = 10;
|
||||
// ...
|
||||
for _ in 0..w {
|
||||
//~^ ERROR cannot find value `w`
|
||||
}
|
||||
}
|
9
tests/ui/range/misleading-field-access-hint.stderr
Normal file
9
tests/ui/range/misleading-field-access-hint.stderr
Normal file
@ -0,0 +1,9 @@
|
||||
error[E0425]: cannot find value `w` in this scope
|
||||
--> $DIR/misleading-field-access-hint.rs:5:17
|
||||
|
|
||||
LL | for _ in 0..w {
|
||||
| ^ not found in this scope
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0425`.
|
Loading…
Reference in New Issue
Block a user