aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/diagnostics/missing_fields.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src/diagnostics/missing_fields.rs')
-rw-r--r--crates/ide/src/diagnostics/missing_fields.rs71
1 files changed, 71 insertions, 0 deletions
diff --git a/crates/ide/src/diagnostics/missing_fields.rs b/crates/ide/src/diagnostics/missing_fields.rs
index 95cd64956..d01f05041 100644
--- a/crates/ide/src/diagnostics/missing_fields.rs
+++ b/crates/ide/src/diagnostics/missing_fields.rs
@@ -94,6 +94,77 @@ fn baz(s: S) {
94 } 94 }
95 95
96 #[test] 96 #[test]
97 fn missing_record_pat_field_no_diagnostic_if_not_exhaustive() {
98 check_diagnostics(
99 r"
100struct S { foo: i32, bar: () }
101fn baz(s: S) -> i32 {
102 match s {
103 S { foo, .. } => foo,
104 }
105}
106",
107 )
108 }
109
110 #[test]
111 fn missing_record_pat_field_box() {
112 check_diagnostics(
113 r"
114struct S { s: Box<u32> }
115fn x(a: S) {
116 let S { box s } = a;
117}
118",
119 )
120 }
121
122 #[test]
123 fn missing_record_pat_field_ref() {
124 check_diagnostics(
125 r"
126struct S { s: u32 }
127fn x(a: S) {
128 let S { ref s } = a;
129}
130",
131 )
132 }
133
134 #[test]
135 fn range_mapping_out_of_macros() {
136 // FIXME: this is very wrong, but somewhat tricky to fix.
137 check_fix(
138 r#"
139fn some() {}
140fn items() {}
141fn here() {}
142
143macro_rules! id { ($($tt:tt)*) => { $($tt)*}; }
144
145fn main() {
146 let _x = id![Foo { a: $042 }];
147}
148
149pub struct Foo { pub a: i32, pub b: i32 }
150"#,
151 r#"
152fn some(, b: () ) {}
153fn items() {}
154fn here() {}
155
156macro_rules! id { ($($tt:tt)*) => { $($tt)*}; }
157
158fn main() {
159 let _x = id![Foo { a: 42 }];
160}
161
162pub struct Foo { pub a: i32, pub b: i32 }
163"#,
164 );
165 }
166
167 #[test]
97 fn test_fill_struct_fields_empty() { 168 fn test_fill_struct_fields_empty() {
98 check_fix( 169 check_fix(
99 r#" 170 r#"