aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_diagnostics/src/handlers/missing_fields.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_diagnostics/src/handlers/missing_fields.rs')
-rw-r--r--crates/ide_diagnostics/src/handlers/missing_fields.rs33
1 files changed, 31 insertions, 2 deletions
diff --git a/crates/ide_diagnostics/src/handlers/missing_fields.rs b/crates/ide_diagnostics/src/handlers/missing_fields.rs
index bc82c0e4a..bc56e0342 100644
--- a/crates/ide_diagnostics/src/handlers/missing_fields.rs
+++ b/crates/ide_diagnostics/src/handlers/missing_fields.rs
@@ -19,7 +19,7 @@ use crate::{fix, Diagnostic, DiagnosticsContext};
19// let a = A { a: 10 }; 19// let a = A { a: 10 };
20// ``` 20// ```
21pub(crate) fn missing_fields(ctx: &DiagnosticsContext<'_>, d: &hir::MissingFields) -> Diagnostic { 21pub(crate) fn missing_fields(ctx: &DiagnosticsContext<'_>, d: &hir::MissingFields) -> Diagnostic {
22 let mut message = String::from("Missing structure fields:\n"); 22 let mut message = String::from("missing structure fields:\n");
23 for field in &d.missed_fields { 23 for field in &d.missed_fields {
24 format_to!(message, "- {}\n", field); 24 format_to!(message, "- {}\n", field);
25 } 25 }
@@ -85,7 +85,7 @@ mod tests {
85struct S { foo: i32, bar: () } 85struct S { foo: i32, bar: () }
86fn baz(s: S) { 86fn baz(s: S) {
87 let S { foo: _ } = s; 87 let S { foo: _ } = s;
88 //^ Missing structure fields: 88 //^ error: missing structure fields:
89 //| - bar 89 //| - bar
90} 90}
91"#, 91"#,
@@ -323,4 +323,33 @@ fn f() {
323"#, 323"#,
324 ); 324 );
325 } 325 }
326
327 #[test]
328 fn import_extern_crate_clash_with_inner_item() {
329 // This is more of a resolver test, but doesn't really work with the hir_def testsuite.
330
331 check_diagnostics(
332 r#"
333//- /lib.rs crate:lib deps:jwt
334mod permissions;
335
336use permissions::jwt;
337
338fn f() {
339 fn inner() {}
340 jwt::Claims {}; // should resolve to the local one with 0 fields, and not get a diagnostic
341}
342
343//- /permissions.rs
344pub mod jwt {
345 pub struct Claims {}
346}
347
348//- /jwt/lib.rs crate:jwt
349pub struct Claims {
350 field: u8,
351}
352 "#,
353 );
354 }
326} 355}