diff options
14 files changed, 103 insertions, 96 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 9e2fa03f8..2854631c6 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -227,11 +227,9 @@ impl Module { | |||
227 | Some((name, def)) | 227 | Some((name, def)) |
228 | } | 228 | } |
229 | }) | 229 | }) |
230 | .flat_map(|(name, def)| | 230 | .flat_map(|(name, def)| { |
231 | ScopeDef::all_items(def) | 231 | ScopeDef::all_items(def).into_iter().map(move |item| (name.clone(), item)) |
232 | .into_iter() | 232 | }) |
233 | .map(move |item| (name.clone(), item)) | ||
234 | ) | ||
235 | .collect() | 233 | .collect() |
236 | } | 234 | } |
237 | 235 | ||
@@ -1298,10 +1296,8 @@ impl ScopeDef { | |||
1298 | let mut items = ArrayVec::new(); | 1296 | let mut items = ArrayVec::new(); |
1299 | 1297 | ||
1300 | match (def.take_types(), def.take_values()) { | 1298 | match (def.take_types(), def.take_values()) { |
1301 | (Some(m1), None) => | 1299 | (Some(m1), None) => items.push(ScopeDef::ModuleDef(m1.into())), |
1302 | items.push(ScopeDef::ModuleDef(m1.into())), | 1300 | (None, Some(m2)) => items.push(ScopeDef::ModuleDef(m2.into())), |
1303 | (None, Some(m2)) => | ||
1304 | items.push(ScopeDef::ModuleDef(m2.into())), | ||
1305 | (Some(m1), Some(m2)) => { | 1301 | (Some(m1), Some(m2)) => { |
1306 | // Some items, like unit structs and enum variants, are | 1302 | // Some items, like unit structs and enum variants, are |
1307 | // returned as both a type and a value. Here we want | 1303 | // returned as both a type and a value. Here we want |
@@ -1312,8 +1308,8 @@ impl ScopeDef { | |||
1312 | } else { | 1308 | } else { |
1313 | items.push(ScopeDef::ModuleDef(m1.into())); | 1309 | items.push(ScopeDef::ModuleDef(m1.into())); |
1314 | } | 1310 | } |
1315 | }, | 1311 | } |
1316 | (None, None) => {}, | 1312 | (None, None) => {} |
1317 | }; | 1313 | }; |
1318 | 1314 | ||
1319 | if let Some(macro_def_id) = def.take_macros() { | 1315 | if let Some(macro_def_id) = def.take_macros() { |
diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index e83eb1fdc..788bb3eb7 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs | |||
@@ -349,8 +349,8 @@ impl<'a, DB: HirDatabase> SemanticsScope<'a, DB> { | |||
349 | for item in items { | 349 | for item in items { |
350 | f(name.clone(), item); | 350 | f(name.clone(), item); |
351 | } | 351 | } |
352 | return | 352 | return; |
353 | }, | 353 | } |
354 | resolver::ScopeDef::ImplSelfType(it) => ScopeDef::ImplSelfType(it.into()), | 354 | resolver::ScopeDef::ImplSelfType(it) => ScopeDef::ImplSelfType(it.into()), |
355 | resolver::ScopeDef::AdtSelfType(it) => ScopeDef::AdtSelfType(it.into()), | 355 | resolver::ScopeDef::AdtSelfType(it) => ScopeDef::AdtSelfType(it.into()), |
356 | resolver::ScopeDef::GenericParam(id) => ScopeDef::GenericParam(TypeParam { id }), | 356 | resolver::ScopeDef::GenericParam(id) => ScopeDef::GenericParam(TypeParam { id }), |
diff --git a/crates/ra_ide/src/completion/complete_path.rs b/crates/ra_ide/src/completion/complete_path.rs index 648c1d39b..65b3bf6e6 100644 --- a/crates/ra_ide/src/completion/complete_path.rs +++ b/crates/ra_ide/src/completion/complete_path.rs | |||
@@ -1005,5 +1005,4 @@ mod tests { | |||
1005 | "### | 1005 | "### |
1006 | ); | 1006 | ); |
1007 | } | 1007 | } |
1008 | |||
1009 | } | 1008 | } |
diff --git a/crates/ra_parser/src/grammar/params.rs b/crates/ra_parser/src/grammar/params.rs index 272661b1d..3ca32185c 100644 --- a/crates/ra_parser/src/grammar/params.rs +++ b/crates/ra_parser/src/grammar/params.rs | |||
@@ -82,26 +82,8 @@ const VALUE_PARAMETER_FIRST: TokenSet = patterns::PATTERN_FIRST.union(types::TYP | |||
82 | fn value_parameter(p: &mut Parser, flavor: Flavor) { | 82 | fn value_parameter(p: &mut Parser, flavor: Flavor) { |
83 | let m = p.start(); | 83 | let m = p.start(); |
84 | match flavor { | 84 | match flavor { |
85 | // test trait_fn_placeholder_parameter | 85 | // test fn_def_param |
86 | // trait Foo { | 86 | // fn foo((x, y): (i32, i32)) {} |
87 | // fn bar(_: u64, mut x: i32); | ||
88 | // } | ||
89 | |||
90 | // test trait_fn_patterns | ||
91 | // trait T { | ||
92 | // fn f1((a, b): (usize, usize)) {} | ||
93 | // fn f2(S { a, b }: S) {} | ||
94 | // fn f3(NewType(a): NewType) {} | ||
95 | // fn f4(&&a: &&usize) {} | ||
96 | // } | ||
97 | |||
98 | // test fn_patterns | ||
99 | // impl U { | ||
100 | // fn f1((a, b): (usize, usize)) {} | ||
101 | // fn f2(S { a, b }: S) {} | ||
102 | // fn f3(NewType(a): NewType) {} | ||
103 | // fn f4(&&a: &&usize) {} | ||
104 | // } | ||
105 | Flavor::FnDef => { | 87 | Flavor::FnDef => { |
106 | patterns::pattern(p); | 88 | patterns::pattern(p); |
107 | types::ascription(p); | 89 | types::ascription(p); |
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0116_trait_fn_placeholder_parameter.rs b/crates/ra_syntax/test_data/parser/inline/ok/0116_trait_fn_placeholder_parameter.rs deleted file mode 100644 index 472cb8803..000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0116_trait_fn_placeholder_parameter.rs +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | trait Foo { | ||
2 | fn bar(_: u64, mut x: i32); | ||
3 | } | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0116_trait_fn_placeholder_parameter.txt b/crates/ra_syntax/test_data/parser/inline/ok/0116_trait_fn_placeholder_parameter.txt deleted file mode 100644 index 158236c5a..000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0116_trait_fn_placeholder_parameter.txt +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | SOURCE_FILE@[0; 46) | ||
2 | TRAIT_DEF@[0; 45) | ||
3 | TRAIT_KW@[0; 5) "trait" | ||
4 | WHITESPACE@[5; 6) " " | ||
5 | NAME@[6; 9) | ||
6 | IDENT@[6; 9) "Foo" | ||
7 | WHITESPACE@[9; 10) " " | ||
8 | ITEM_LIST@[10; 45) | ||
9 | L_CURLY@[10; 11) "{" | ||
10 | WHITESPACE@[11; 16) "\n " | ||
11 | FN_DEF@[16; 43) | ||
12 | FN_KW@[16; 18) "fn" | ||
13 | WHITESPACE@[18; 19) " " | ||
14 | NAME@[19; 22) | ||
15 | IDENT@[19; 22) "bar" | ||
16 | PARAM_LIST@[22; 42) | ||
17 | L_PAREN@[22; 23) "(" | ||
18 | PARAM@[23; 29) | ||
19 | PLACEHOLDER_PAT@[23; 24) | ||
20 | UNDERSCORE@[23; 24) "_" | ||
21 | COLON@[24; 25) ":" | ||
22 | WHITESPACE@[25; 26) " " | ||
23 | PATH_TYPE@[26; 29) | ||
24 | PATH@[26; 29) | ||
25 | PATH_SEGMENT@[26; 29) | ||
26 | NAME_REF@[26; 29) | ||
27 | IDENT@[26; 29) "u64" | ||
28 | COMMA@[29; 30) "," | ||
29 | WHITESPACE@[30; 31) " " | ||
30 | PARAM@[31; 41) | ||
31 | BIND_PAT@[31; 36) | ||
32 | MUT_KW@[31; 34) "mut" | ||
33 | WHITESPACE@[34; 35) " " | ||
34 | NAME@[35; 36) | ||
35 | IDENT@[35; 36) "x" | ||
36 | COLON@[36; 37) ":" | ||
37 | WHITESPACE@[37; 38) " " | ||
38 | PATH_TYPE@[38; 41) | ||
39 | PATH@[38; 41) | ||
40 | PATH_SEGMENT@[38; 41) | ||
41 | NAME_REF@[38; 41) | ||
42 | IDENT@[38; 41) "i32" | ||
43 | R_PAREN@[41; 42) ")" | ||
44 | SEMI@[42; 43) ";" | ||
45 | WHITESPACE@[43; 44) "\n" | ||
46 | R_CURLY@[44; 45) "}" | ||
47 | WHITESPACE@[45; 46) "\n" | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.rs b/crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.rs new file mode 100644 index 000000000..7b277c16b --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.rs | |||
@@ -0,0 +1 @@ | |||
fn foo((x, y): (i32, i32)) {} | |||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.txt b/crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.txt new file mode 100644 index 000000000..103e254a6 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.txt | |||
@@ -0,0 +1,44 @@ | |||
1 | SOURCE_FILE@[0; 30) | ||
2 | FN_DEF@[0; 29) | ||
3 | FN_KW@[0; 2) "fn" | ||
4 | WHITESPACE@[2; 3) " " | ||
5 | NAME@[3; 6) | ||
6 | IDENT@[3; 6) "foo" | ||
7 | PARAM_LIST@[6; 26) | ||
8 | L_PAREN@[6; 7) "(" | ||
9 | PARAM@[7; 25) | ||
10 | TUPLE_PAT@[7; 13) | ||
11 | L_PAREN@[7; 8) "(" | ||
12 | BIND_PAT@[8; 9) | ||
13 | NAME@[8; 9) | ||
14 | IDENT@[8; 9) "x" | ||
15 | COMMA@[9; 10) "," | ||
16 | WHITESPACE@[10; 11) " " | ||
17 | BIND_PAT@[11; 12) | ||
18 | NAME@[11; 12) | ||
19 | IDENT@[11; 12) "y" | ||
20 | R_PAREN@[12; 13) ")" | ||
21 | COLON@[13; 14) ":" | ||
22 | WHITESPACE@[14; 15) " " | ||
23 | TUPLE_TYPE@[15; 25) | ||
24 | L_PAREN@[15; 16) "(" | ||
25 | PATH_TYPE@[16; 19) | ||
26 | PATH@[16; 19) | ||
27 | PATH_SEGMENT@[16; 19) | ||
28 | NAME_REF@[16; 19) | ||
29 | IDENT@[16; 19) "i32" | ||
30 | COMMA@[19; 20) "," | ||
31 | WHITESPACE@[20; 21) " " | ||
32 | PATH_TYPE@[21; 24) | ||
33 | PATH@[21; 24) | ||
34 | PATH_SEGMENT@[21; 24) | ||
35 | NAME_REF@[21; 24) | ||
36 | IDENT@[21; 24) "i32" | ||
37 | R_PAREN@[24; 25) ")" | ||
38 | R_PAREN@[25; 26) ")" | ||
39 | WHITESPACE@[26; 27) " " | ||
40 | BLOCK_EXPR@[27; 29) | ||
41 | BLOCK@[27; 29) | ||
42 | L_CURLY@[27; 28) "{" | ||
43 | R_CURLY@[28; 29) "}" | ||
44 | WHITESPACE@[29; 30) "\n" | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0153_trait_fn_patterns.rs b/crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.rs index a94bf378a..3b666af8e 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0153_trait_fn_patterns.rs +++ b/crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.rs | |||
@@ -3,4 +3,5 @@ trait T { | |||
3 | fn f2(S { a, b }: S) {} | 3 | fn f2(S { a, b }: S) {} |
4 | fn f3(NewType(a): NewType) {} | 4 | fn f3(NewType(a): NewType) {} |
5 | fn f4(&&a: &&usize) {} | 5 | fn f4(&&a: &&usize) {} |
6 | fn bar(_: u64, mut x: i32); | ||
6 | } | 7 | } |
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0153_trait_fn_patterns.txt b/crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.txt index b22df8dbe..eb2e3a503 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0153_trait_fn_patterns.txt +++ b/crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.txt | |||
@@ -1,11 +1,11 @@ | |||
1 | SOURCE_FILE@[0; 138) | 1 | SOURCE_FILE@[0; 170) |
2 | TRAIT_DEF@[0; 137) | 2 | TRAIT_DEF@[0; 169) |
3 | TRAIT_KW@[0; 5) "trait" | 3 | TRAIT_KW@[0; 5) "trait" |
4 | WHITESPACE@[5; 6) " " | 4 | WHITESPACE@[5; 6) " " |
5 | NAME@[6; 7) | 5 | NAME@[6; 7) |
6 | IDENT@[6; 7) "T" | 6 | IDENT@[6; 7) "T" |
7 | WHITESPACE@[7; 8) " " | 7 | WHITESPACE@[7; 8) " " |
8 | ITEM_LIST@[8; 137) | 8 | ITEM_LIST@[8; 169) |
9 | L_CURLY@[8; 9) "{" | 9 | L_CURLY@[8; 9) "{" |
10 | WHITESPACE@[9; 14) "\n " | 10 | WHITESPACE@[9; 14) "\n " |
11 | FN_DEF@[14; 46) | 11 | FN_DEF@[14; 46) |
@@ -156,6 +156,41 @@ SOURCE_FILE@[0; 138) | |||
156 | BLOCK@[133; 135) | 156 | BLOCK@[133; 135) |
157 | L_CURLY@[133; 134) "{" | 157 | L_CURLY@[133; 134) "{" |
158 | R_CURLY@[134; 135) "}" | 158 | R_CURLY@[134; 135) "}" |
159 | WHITESPACE@[135; 136) "\n" | 159 | WHITESPACE@[135; 140) "\n " |
160 | R_CURLY@[136; 137) "}" | 160 | FN_DEF@[140; 167) |
161 | WHITESPACE@[137; 138) "\n" | 161 | FN_KW@[140; 142) "fn" |
162 | WHITESPACE@[142; 143) " " | ||
163 | NAME@[143; 146) | ||
164 | IDENT@[143; 146) "bar" | ||
165 | PARAM_LIST@[146; 166) | ||
166 | L_PAREN@[146; 147) "(" | ||
167 | PARAM@[147; 153) | ||
168 | PLACEHOLDER_PAT@[147; 148) | ||
169 | UNDERSCORE@[147; 148) "_" | ||
170 | COLON@[148; 149) ":" | ||
171 | WHITESPACE@[149; 150) " " | ||
172 | PATH_TYPE@[150; 153) | ||
173 | PATH@[150; 153) | ||
174 | PATH_SEGMENT@[150; 153) | ||
175 | NAME_REF@[150; 153) | ||
176 | IDENT@[150; 153) "u64" | ||
177 | COMMA@[153; 154) "," | ||
178 | WHITESPACE@[154; 155) " " | ||
179 | PARAM@[155; 165) | ||
180 | BIND_PAT@[155; 160) | ||
181 | MUT_KW@[155; 158) "mut" | ||
182 | WHITESPACE@[158; 159) " " | ||
183 | NAME@[159; 160) | ||
184 | IDENT@[159; 160) "x" | ||
185 | COLON@[160; 161) ":" | ||
186 | WHITESPACE@[161; 162) " " | ||
187 | PATH_TYPE@[162; 165) | ||
188 | PATH@[162; 165) | ||
189 | PATH_SEGMENT@[162; 165) | ||
190 | NAME_REF@[162; 165) | ||
191 | IDENT@[162; 165) "i32" | ||
192 | R_PAREN@[165; 166) ")" | ||
193 | SEMI@[166; 167) ";" | ||
194 | WHITESPACE@[167; 168) "\n" | ||
195 | R_CURLY@[168; 169) "}" | ||
196 | WHITESPACE@[169; 170) "\n" | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0152_fn_patterns.rs b/crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.rs index b49e872d7..b49e872d7 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0152_fn_patterns.rs +++ b/crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.rs | |||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0152_fn_patterns.txt b/crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.txt index b30030de3..b30030de3 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0152_fn_patterns.txt +++ b/crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.txt | |||
diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index a0d8f4d37..db03df1c4 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs | |||
@@ -397,6 +397,8 @@ pub fn skip_slow_tests() -> bool { | |||
397 | should_skip | 397 | should_skip |
398 | } | 398 | } |
399 | 399 | ||
400 | const REWRITE: bool = false; | ||
401 | |||
400 | /// Asserts that `expected` and `actual` strings are equal. If they differ only | 402 | /// Asserts that `expected` and `actual` strings are equal. If they differ only |
401 | /// in trailing or leading whitespace the test won't fail and | 403 | /// in trailing or leading whitespace the test won't fail and |
402 | /// the contents of `actual` will be written to the file located at `path`. | 404 | /// the contents of `actual` will be written to the file located at `path`. |
@@ -412,7 +414,6 @@ fn assert_equal_text(expected: &str, actual: &str, path: &Path) { | |||
412 | fs::write(path, actual).unwrap(); | 414 | fs::write(path, actual).unwrap(); |
413 | return; | 415 | return; |
414 | } | 416 | } |
415 | const REWRITE: bool = false; | ||
416 | if REWRITE { | 417 | if REWRITE { |
417 | println!("rewriting {}", pretty_path.display()); | 418 | println!("rewriting {}", pretty_path.display()); |
418 | fs::write(path, actual).unwrap(); | 419 | fs::write(path, actual).unwrap(); |
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index 014b61b37..e1472e85d 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs | |||
@@ -38,13 +38,11 @@ pub fn project_root() -> PathBuf { | |||
38 | } | 38 | } |
39 | 39 | ||
40 | pub fn run_rustfmt(mode: Mode) -> Result<()> { | 40 | pub fn run_rustfmt(mode: Mode) -> Result<()> { |
41 | let _dir = pushd(project_root()); | ||
41 | ensure_rustfmt()?; | 42 | ensure_rustfmt()?; |
42 | 43 | ||
43 | if mode == Mode::Verify { | 44 | let check = if mode == Mode::Verify { "--check" } else { "" }; |
44 | run!("rustup run {} -- cargo fmt -- --check", TOOLCHAIN)?; | 45 | run!("rustup run {} -- cargo fmt -- {}", TOOLCHAIN, check)?; |
45 | } else { | ||
46 | run!("rustup run {} -- cargo fmt", TOOLCHAIN)?; | ||
47 | } | ||
48 | Ok(()) | 46 | Ok(()) |
49 | } | 47 | } |
50 | 48 | ||