Skip to content

Commit

Permalink
Merge pull request #18700 from ChayimFriedman2/dyn-send
Browse files Browse the repository at this point in the history
fix: Fix a panic with a diagnostics fix when a keyword is used as a field
  • Loading branch information
Veykril authored Dec 16, 2024
2 parents dc6af80 + 8277c03 commit 0a706f7
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion crates/ide-diagnostics/src/handlers/unresolved_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ fn field_fix(ctx: &DiagnosticsContext<'_>, d: &hir::UnresolvedField) -> Option<A
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;
}

Expand Down Expand Up @@ -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`
}
}
"#,
);
}
}

0 comments on commit 0a706f7

Please sign in to comment.