mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Fix a panic with a diagnostics fix when a keyword is used as a field
I found it easiest to fix in the quickfix code, and not deeper (e.g. body lowering).
This commit is contained in:
parent
27e824fad4
commit
8277c0336e
1 changed files with 18 additions and 1 deletions
|
@ -90,7 +90,9 @@ fn field_fix(ctx: &DiagnosticsContext<'_>, d: &hir::UnresolvedField) -> Option<A
|
||||||
make::ty("()")
|
make::ty("()")
|
||||||
};
|
};
|
||||||
|
|
||||||
if !is_editable_crate(target_module.krate(), ctx.sema.db) {
|
if !is_editable_crate(target_module.krate(), ctx.sema.db)
|
||||||
|
|| SyntaxKind::from_keyword(field_name, ctx.edition).is_some()
|
||||||
|
{
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,4 +503,19 @@ fn main() {}
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn regression_18683() {
|
||||||
|
check_diagnostics(
|
||||||
|
r#"
|
||||||
|
struct S;
|
||||||
|
impl S {
|
||||||
|
fn f(self) {
|
||||||
|
self.self
|
||||||
|
// ^^^^ error: no field `self` on type `S`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue