Skip to content

Commit 0a706f7

Browse files
authored
Merge pull request #18700 from ChayimFriedman2/dyn-send
fix: Fix a panic with a diagnostics fix when a keyword is used as a field
2 parents dc6af80 + 8277c03 commit 0a706f7

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

crates/ide-diagnostics/src/handlers/unresolved_field.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ fn field_fix(ctx: &DiagnosticsContext<'_>, d: &hir::UnresolvedField) -> Option<A
9090
make::ty("()")
9191
};
9292

93-
if !is_editable_crate(target_module.krate(), ctx.sema.db) {
93+
if !is_editable_crate(target_module.krate(), ctx.sema.db)
94+
|| SyntaxKind::from_keyword(field_name, ctx.edition).is_some()
95+
{
9496
return None;
9597
}
9698

@@ -501,4 +503,19 @@ fn main() {}
501503
"#,
502504
)
503505
}
506+
507+
#[test]
508+
fn regression_18683() {
509+
check_diagnostics(
510+
r#"
511+
struct S;
512+
impl S {
513+
fn f(self) {
514+
self.self
515+
// ^^^^ error: no field `self` on type `S`
516+
}
517+
}
518+
"#,
519+
);
520+
}
504521
}

0 commit comments

Comments
 (0)