diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_assists/src/handlers/add_explicit_type.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/unwrap_block.rs | 221 | ||||
-rw-r--r-- | crates/ra_flycheck/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_flycheck/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/display.rs | 63 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/tests/display_source_code.rs | 27 | ||||
-rw-r--r-- | crates/ra_proc_macro_srv/Cargo.toml | 4 | ||||
-rw-r--r-- | crates/ra_proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt | 21 | ||||
-rw-r--r-- | crates/ra_proc_macro_srv/src/tests/mod.rs | 6 | ||||
-rw-r--r-- | crates/ra_proc_macro_srv/src/tests/utils.rs | 4 | ||||
-rw-r--r-- | crates/ra_project_model/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_project_model/src/cargo_workspace.rs | 14 |
12 files changed, 278 insertions, 90 deletions
diff --git a/crates/ra_assists/src/handlers/add_explicit_type.rs b/crates/ra_assists/src/handlers/add_explicit_type.rs index 146cc75df..7ced00626 100644 --- a/crates/ra_assists/src/handlers/add_explicit_type.rs +++ b/crates/ra_assists/src/handlers/add_explicit_type.rs | |||
@@ -209,7 +209,7 @@ struct Test<K, T = u8> { | |||
209 | } | 209 | } |
210 | 210 | ||
211 | fn main() { | 211 | fn main() { |
212 | let test<|>: Test<i32, u8> = Test { t: 23, k: 33 }; | 212 | let test<|>: Test<i32> = Test { t: 23, k: 33 }; |
213 | }"#, | 213 | }"#, |
214 | ); | 214 | ); |
215 | } | 215 | } |
diff --git a/crates/ra_assists/src/handlers/unwrap_block.rs b/crates/ra_assists/src/handlers/unwrap_block.rs index eba0631a4..e52ec557e 100644 --- a/crates/ra_assists/src/handlers/unwrap_block.rs +++ b/crates/ra_assists/src/handlers/unwrap_block.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use crate::{AssistContext, AssistId, Assists}; | 1 | use crate::{AssistContext, AssistId, Assists}; |
2 | 2 | ||
3 | use ast::LoopBodyOwner; | 3 | use ast::{ElseBranch, Expr, LoopBodyOwner}; |
4 | use ra_fmt::unwrap_trivial_block; | 4 | use ra_fmt::unwrap_trivial_block; |
5 | use ra_syntax::{ast, match_ast, AstNode, TextRange, T}; | 5 | use ra_syntax::{ast, match_ast, AstNode, TextRange, T}; |
6 | 6 | ||
@@ -25,19 +25,11 @@ pub(crate) fn unwrap_block(acc: &mut Assists, ctx: &AssistContext) -> Option<()> | |||
25 | let l_curly_token = ctx.find_token_at_offset(T!['{'])?; | 25 | let l_curly_token = ctx.find_token_at_offset(T!['{'])?; |
26 | let block = ast::BlockExpr::cast(l_curly_token.parent())?; | 26 | let block = ast::BlockExpr::cast(l_curly_token.parent())?; |
27 | let parent = block.syntax().parent()?; | 27 | let parent = block.syntax().parent()?; |
28 | let assist_id = AssistId("unwrap_block"); | ||
29 | let assist_label = "Unwrap block"; | ||
30 | |||
28 | let (expr, expr_to_unwrap) = match_ast! { | 31 | let (expr, expr_to_unwrap) = match_ast! { |
29 | match parent { | 32 | match parent { |
30 | ast::IfExpr(if_expr) => { | ||
31 | let expr_to_unwrap = if_expr.blocks().find_map(|expr| extract_expr(ctx.frange.range, expr)); | ||
32 | let expr_to_unwrap = expr_to_unwrap?; | ||
33 | // Find if we are in a else if block | ||
34 | let ancestor = if_expr.syntax().parent().and_then(ast::IfExpr::cast); | ||
35 | |||
36 | match ancestor { | ||
37 | None => (ast::Expr::IfExpr(if_expr), expr_to_unwrap), | ||
38 | Some(ancestor) => (ast::Expr::IfExpr(ancestor), expr_to_unwrap), | ||
39 | } | ||
40 | }, | ||
41 | ast::ForExpr(for_expr) => { | 33 | ast::ForExpr(for_expr) => { |
42 | let block_expr = for_expr.loop_body()?; | 34 | let block_expr = for_expr.loop_body()?; |
43 | let expr_to_unwrap = extract_expr(ctx.frange.range, block_expr)?; | 35 | let expr_to_unwrap = extract_expr(ctx.frange.range, block_expr)?; |
@@ -53,27 +45,62 @@ pub(crate) fn unwrap_block(acc: &mut Assists, ctx: &AssistContext) -> Option<()> | |||
53 | let expr_to_unwrap = extract_expr(ctx.frange.range, block_expr)?; | 45 | let expr_to_unwrap = extract_expr(ctx.frange.range, block_expr)?; |
54 | (ast::Expr::LoopExpr(loop_expr), expr_to_unwrap) | 46 | (ast::Expr::LoopExpr(loop_expr), expr_to_unwrap) |
55 | }, | 47 | }, |
48 | ast::IfExpr(if_expr) => { | ||
49 | let mut resp = None; | ||
50 | |||
51 | let then_branch = if_expr.then_branch()?; | ||
52 | if then_branch.l_curly_token()?.text_range().contains_range(ctx.frange.range) { | ||
53 | if let Some(ancestor) = if_expr.syntax().parent().and_then(ast::IfExpr::cast) { | ||
54 | // For `else if` blocks | ||
55 | let ancestor_then_branch = ancestor.then_branch()?; | ||
56 | let l_curly_token = then_branch.l_curly_token()?; | ||
57 | |||
58 | let target = then_branch.syntax().text_range(); | ||
59 | return acc.add(assist_id, assist_label, target, |edit| { | ||
60 | let range_to_del_else_if = TextRange::new(ancestor_then_branch.syntax().text_range().end(), l_curly_token.text_range().start()); | ||
61 | let range_to_del_rest = TextRange::new(then_branch.syntax().text_range().end(), if_expr.syntax().text_range().end()); | ||
62 | |||
63 | edit.set_cursor(ancestor_then_branch.syntax().text_range().end()); | ||
64 | edit.delete(range_to_del_rest); | ||
65 | edit.delete(range_to_del_else_if); | ||
66 | edit.replace(target, update_expr_string(then_branch.to_string(), &[' ', '{'])); | ||
67 | }); | ||
68 | } else { | ||
69 | resp = Some((ast::Expr::IfExpr(if_expr.clone()), Expr::BlockExpr(then_branch))); | ||
70 | } | ||
71 | } else if let Some(else_branch) = if_expr.else_branch() { | ||
72 | match else_branch { | ||
73 | ElseBranch::Block(else_block) => { | ||
74 | let l_curly_token = else_block.l_curly_token()?; | ||
75 | if l_curly_token.text_range().contains_range(ctx.frange.range) { | ||
76 | let target = else_block.syntax().text_range(); | ||
77 | return acc.add(assist_id, assist_label, target, |edit| { | ||
78 | let range_to_del = TextRange::new(then_branch.syntax().text_range().end(), l_curly_token.text_range().start()); | ||
79 | |||
80 | edit.set_cursor(then_branch.syntax().text_range().end()); | ||
81 | edit.delete(range_to_del); | ||
82 | edit.replace(target, update_expr_string(else_block.to_string(), &[' ', '{'])); | ||
83 | }); | ||
84 | } | ||
85 | }, | ||
86 | ElseBranch::IfExpr(_) => {}, | ||
87 | } | ||
88 | } | ||
89 | |||
90 | resp? | ||
91 | }, | ||
56 | _ => return None, | 92 | _ => return None, |
57 | } | 93 | } |
58 | }; | 94 | }; |
59 | 95 | ||
60 | let target = expr_to_unwrap.syntax().text_range(); | 96 | let target = expr_to_unwrap.syntax().text_range(); |
61 | acc.add(AssistId("unwrap_block"), "Unwrap block", target, |edit| { | 97 | acc.add(assist_id, assist_label, target, |edit| { |
62 | edit.set_cursor(expr.syntax().text_range().start()); | 98 | edit.set_cursor(expr.syntax().text_range().start()); |
63 | 99 | ||
64 | let pat_start: &[_] = &[' ', '{', '\n']; | 100 | edit.replace( |
65 | let expr_to_unwrap = expr_to_unwrap.to_string(); | 101 | expr.syntax().text_range(), |
66 | let expr_string = expr_to_unwrap.trim_start_matches(pat_start); | 102 | update_expr_string(expr_to_unwrap.to_string(), &[' ', '{', '\n']), |
67 | let mut expr_string_lines: Vec<&str> = expr_string.lines().collect(); | 103 | ); |
68 | expr_string_lines.pop(); // Delete last line | ||
69 | |||
70 | let expr_string = expr_string_lines | ||
71 | .into_iter() | ||
72 | .map(|line| line.replacen(" ", "", 1)) // Delete indentation | ||
73 | .collect::<Vec<String>>() | ||
74 | .join("\n"); | ||
75 | |||
76 | edit.replace(expr.syntax().text_range(), expr_string); | ||
77 | }) | 104 | }) |
78 | } | 105 | } |
79 | 106 | ||
@@ -87,6 +114,18 @@ fn extract_expr(cursor_range: TextRange, block: ast::BlockExpr) -> Option<ast::E | |||
87 | } | 114 | } |
88 | } | 115 | } |
89 | 116 | ||
117 | fn update_expr_string(expr_str: String, trim_start_pat: &[char]) -> String { | ||
118 | let expr_string = expr_str.trim_start_matches(trim_start_pat); | ||
119 | let mut expr_string_lines: Vec<&str> = expr_string.lines().collect(); | ||
120 | expr_string_lines.pop(); // Delete last line | ||
121 | |||
122 | expr_string_lines | ||
123 | .into_iter() | ||
124 | .map(|line| line.replacen(" ", "", 1)) // Delete indentation | ||
125 | .collect::<Vec<String>>() | ||
126 | .join("\n") | ||
127 | } | ||
128 | |||
90 | #[cfg(test)] | 129 | #[cfg(test)] |
91 | mod tests { | 130 | mod tests { |
92 | use crate::tests::{check_assist, check_assist_not_applicable}; | 131 | use crate::tests::{check_assist, check_assist_not_applicable}; |
@@ -142,7 +181,13 @@ mod tests { | |||
142 | r#" | 181 | r#" |
143 | fn main() { | 182 | fn main() { |
144 | bar(); | 183 | bar(); |
145 | <|>println!("bar"); | 184 | if true { |
185 | foo(); | ||
186 | |||
187 | //comment | ||
188 | bar(); | ||
189 | }<|> | ||
190 | println!("bar"); | ||
146 | } | 191 | } |
147 | "#, | 192 | "#, |
148 | ); | 193 | ); |
@@ -170,7 +215,127 @@ mod tests { | |||
170 | r#" | 215 | r#" |
171 | fn main() { | 216 | fn main() { |
172 | //bar(); | 217 | //bar(); |
173 | <|>println!("bar"); | 218 | if true { |
219 | println!("true"); | ||
220 | |||
221 | //comment | ||
222 | //bar(); | ||
223 | }<|> | ||
224 | println!("bar"); | ||
225 | } | ||
226 | "#, | ||
227 | ); | ||
228 | } | ||
229 | |||
230 | #[test] | ||
231 | fn simple_if_else_if_nested() { | ||
232 | check_assist( | ||
233 | unwrap_block, | ||
234 | r#" | ||
235 | fn main() { | ||
236 | //bar(); | ||
237 | if true { | ||
238 | println!("true"); | ||
239 | |||
240 | //comment | ||
241 | //bar(); | ||
242 | } else if false { | ||
243 | println!("bar"); | ||
244 | } else if true {<|> | ||
245 | println!("foo"); | ||
246 | } | ||
247 | } | ||
248 | "#, | ||
249 | r#" | ||
250 | fn main() { | ||
251 | //bar(); | ||
252 | if true { | ||
253 | println!("true"); | ||
254 | |||
255 | //comment | ||
256 | //bar(); | ||
257 | } else if false { | ||
258 | println!("bar"); | ||
259 | }<|> | ||
260 | println!("foo"); | ||
261 | } | ||
262 | "#, | ||
263 | ); | ||
264 | } | ||
265 | |||
266 | #[test] | ||
267 | fn simple_if_else_if_nested_else() { | ||
268 | check_assist( | ||
269 | unwrap_block, | ||
270 | r#" | ||
271 | fn main() { | ||
272 | //bar(); | ||
273 | if true { | ||
274 | println!("true"); | ||
275 | |||
276 | //comment | ||
277 | //bar(); | ||
278 | } else if false { | ||
279 | println!("bar"); | ||
280 | } else if true { | ||
281 | println!("foo"); | ||
282 | } else {<|> | ||
283 | println!("else"); | ||
284 | } | ||
285 | } | ||
286 | "#, | ||
287 | r#" | ||
288 | fn main() { | ||
289 | //bar(); | ||
290 | if true { | ||
291 | println!("true"); | ||
292 | |||
293 | //comment | ||
294 | //bar(); | ||
295 | } else if false { | ||
296 | println!("bar"); | ||
297 | } else if true { | ||
298 | println!("foo"); | ||
299 | }<|> | ||
300 | println!("else"); | ||
301 | } | ||
302 | "#, | ||
303 | ); | ||
304 | } | ||
305 | |||
306 | #[test] | ||
307 | fn simple_if_else_if_nested_middle() { | ||
308 | check_assist( | ||
309 | unwrap_block, | ||
310 | r#" | ||
311 | fn main() { | ||
312 | //bar(); | ||
313 | if true { | ||
314 | println!("true"); | ||
315 | |||
316 | //comment | ||
317 | //bar(); | ||
318 | } else if false { | ||
319 | println!("bar"); | ||
320 | } else if true {<|> | ||
321 | println!("foo"); | ||
322 | } else { | ||
323 | println!("else"); | ||
324 | } | ||
325 | } | ||
326 | "#, | ||
327 | r#" | ||
328 | fn main() { | ||
329 | //bar(); | ||
330 | if true { | ||
331 | println!("true"); | ||
332 | |||
333 | //comment | ||
334 | //bar(); | ||
335 | } else if false { | ||
336 | println!("bar"); | ||
337 | }<|> | ||
338 | println!("foo"); | ||
174 | } | 339 | } |
175 | "#, | 340 | "#, |
176 | ); | 341 | ); |
diff --git a/crates/ra_flycheck/Cargo.toml b/crates/ra_flycheck/Cargo.toml index 03e557148..eac502da5 100644 --- a/crates/ra_flycheck/Cargo.toml +++ b/crates/ra_flycheck/Cargo.toml | |||
@@ -11,7 +11,7 @@ doctest = false | |||
11 | crossbeam-channel = "0.4.0" | 11 | crossbeam-channel = "0.4.0" |
12 | lsp-types = { version = "0.74.0", features = ["proposed"] } | 12 | lsp-types = { version = "0.74.0", features = ["proposed"] } |
13 | log = "0.4.8" | 13 | log = "0.4.8" |
14 | cargo_metadata = "0.9.1" | 14 | cargo_metadata = "0.10.0" |
15 | serde_json = "1.0.48" | 15 | serde_json = "1.0.48" |
16 | jod-thread = "0.1.1" | 16 | jod-thread = "0.1.1" |
17 | ra_toolchain = { path = "../ra_toolchain" } | 17 | ra_toolchain = { path = "../ra_toolchain" } |
diff --git a/crates/ra_flycheck/src/lib.rs b/crates/ra_flycheck/src/lib.rs index 68dcee285..24af75c95 100644 --- a/crates/ra_flycheck/src/lib.rs +++ b/crates/ra_flycheck/src/lib.rs | |||
@@ -204,6 +204,8 @@ impl FlycheckThread { | |||
204 | } | 204 | } |
205 | 205 | ||
206 | CheckEvent::Msg(Message::BuildScriptExecuted(_msg)) => {} | 206 | CheckEvent::Msg(Message::BuildScriptExecuted(_msg)) => {} |
207 | CheckEvent::Msg(Message::BuildFinished(_)) => {} | ||
208 | CheckEvent::Msg(Message::TextLine(_)) => {} | ||
207 | CheckEvent::Msg(Message::Unknown) => {} | 209 | CheckEvent::Msg(Message::Unknown) => {} |
208 | } | 210 | } |
209 | } | 211 | } |
diff --git a/crates/ra_hir_ty/src/display.rs b/crates/ra_hir_ty/src/display.rs index f5edaea8c..b9c4d2e89 100644 --- a/crates/ra_hir_ty/src/display.rs +++ b/crates/ra_hir_ty/src/display.rs | |||
@@ -136,6 +136,12 @@ enum DisplayTarget { | |||
136 | SourceCode { module_id: ModuleId }, | 136 | SourceCode { module_id: ModuleId }, |
137 | } | 137 | } |
138 | 138 | ||
139 | impl DisplayTarget { | ||
140 | fn is_source_code(&self) -> bool { | ||
141 | matches!(self, Self::SourceCode {..}) | ||
142 | } | ||
143 | } | ||
144 | |||
139 | #[derive(Debug)] | 145 | #[derive(Debug)] |
140 | pub enum DisplaySourceCodeError { | 146 | pub enum DisplaySourceCodeError { |
141 | PathNotFound, | 147 | PathNotFound, |
@@ -303,37 +309,40 @@ impl HirDisplay for ApplicationTy { | |||
303 | 309 | ||
304 | if self.parameters.len() > 0 { | 310 | if self.parameters.len() > 0 { |
305 | let mut non_default_parameters = Vec::with_capacity(self.parameters.len()); | 311 | let mut non_default_parameters = Vec::with_capacity(self.parameters.len()); |
306 | let parameters_to_write = if f.omit_verbose_types() { | 312 | let parameters_to_write = |
307 | match self | 313 | if f.display_target.is_source_code() || f.omit_verbose_types() { |
308 | .ctor | 314 | match self |
309 | .as_generic_def() | 315 | .ctor |
310 | .map(|generic_def_id| f.db.generic_defaults(generic_def_id)) | 316 | .as_generic_def() |
311 | .filter(|defaults| !defaults.is_empty()) | 317 | .map(|generic_def_id| f.db.generic_defaults(generic_def_id)) |
312 | { | 318 | .filter(|defaults| !defaults.is_empty()) |
313 | None => self.parameters.0.as_ref(), | 319 | { |
314 | Some(default_parameters) => { | 320 | None => self.parameters.0.as_ref(), |
315 | for (i, parameter) in self.parameters.iter().enumerate() { | 321 | Some(default_parameters) => { |
316 | match (parameter, default_parameters.get(i)) { | 322 | for (i, parameter) in self.parameters.iter().enumerate() { |
317 | (&Ty::Unknown, _) | (_, None) => { | 323 | match (parameter, default_parameters.get(i)) { |
318 | non_default_parameters.push(parameter.clone()) | 324 | (&Ty::Unknown, _) | (_, None) => { |
319 | } | 325 | non_default_parameters.push(parameter.clone()) |
320 | (_, Some(default_parameter)) | 326 | } |
321 | if parameter != default_parameter => | 327 | (_, Some(default_parameter)) |
322 | { | 328 | if parameter != default_parameter => |
323 | non_default_parameters.push(parameter.clone()) | 329 | { |
330 | non_default_parameters.push(parameter.clone()) | ||
331 | } | ||
332 | _ => (), | ||
324 | } | 333 | } |
325 | _ => (), | ||
326 | } | 334 | } |
335 | &non_default_parameters | ||
327 | } | 336 | } |
328 | &non_default_parameters | ||
329 | } | 337 | } |
330 | } | 338 | } else { |
331 | } else { | 339 | self.parameters.0.as_ref() |
332 | self.parameters.0.as_ref() | 340 | }; |
333 | }; | 341 | if !parameters_to_write.is_empty() { |
334 | write!(f, "<")?; | 342 | write!(f, "<")?; |
335 | f.write_joined(parameters_to_write, ", ")?; | 343 | f.write_joined(parameters_to_write, ", ")?; |
336 | write!(f, ">")?; | 344 | write!(f, ">")?; |
345 | } | ||
337 | } | 346 | } |
338 | } | 347 | } |
339 | TypeCtor::AssociatedType(type_alias) => { | 348 | TypeCtor::AssociatedType(type_alias) => { |
diff --git a/crates/ra_hir_ty/src/tests/display_source_code.rs b/crates/ra_hir_ty/src/tests/display_source_code.rs index ca1748615..4088b1d22 100644 --- a/crates/ra_hir_ty/src/tests/display_source_code.rs +++ b/crates/ra_hir_ty/src/tests/display_source_code.rs | |||
@@ -21,3 +21,30 @@ fn bar() { | |||
21 | ); | 21 | ); |
22 | assert_eq!("foo::Foo", displayed_source_at_pos(&db, pos)); | 22 | assert_eq!("foo::Foo", displayed_source_at_pos(&db, pos)); |
23 | } | 23 | } |
24 | |||
25 | #[test] | ||
26 | fn omit_default_type_parameters() { | ||
27 | let (db, pos) = TestDB::with_position( | ||
28 | r" | ||
29 | //- /main.rs | ||
30 | struct Foo<T = u8> { t: T } | ||
31 | fn main() { | ||
32 | let foo = Foo { t: 5 }; | ||
33 | foo<|>; | ||
34 | } | ||
35 | ", | ||
36 | ); | ||
37 | assert_eq!("Foo", displayed_source_at_pos(&db, pos)); | ||
38 | |||
39 | let (db, pos) = TestDB::with_position( | ||
40 | r" | ||
41 | //- /main.rs | ||
42 | struct Foo<K, T = u8> { k: K, t: T } | ||
43 | fn main() { | ||
44 | let foo = Foo { k: 400, t: 5 }; | ||
45 | foo<|>; | ||
46 | } | ||
47 | ", | ||
48 | ); | ||
49 | assert_eq!("Foo<i32>", displayed_source_at_pos(&db, pos)); | ||
50 | } | ||
diff --git a/crates/ra_proc_macro_srv/Cargo.toml b/crates/ra_proc_macro_srv/Cargo.toml index 886e14870..bb3003278 100644 --- a/crates/ra_proc_macro_srv/Cargo.toml +++ b/crates/ra_proc_macro_srv/Cargo.toml | |||
@@ -18,7 +18,7 @@ memmap = "0.7" | |||
18 | test_utils = { path = "../test_utils" } | 18 | test_utils = { path = "../test_utils" } |
19 | 19 | ||
20 | [dev-dependencies] | 20 | [dev-dependencies] |
21 | cargo_metadata = "0.9.1" | 21 | cargo_metadata = "0.10.0" |
22 | difference = "2.0.0" | 22 | difference = "2.0.0" |
23 | # used as proc macro test target | 23 | # used as proc macro test target |
24 | serde_derive = "=1.0.106" | 24 | serde_derive = "1.0.106" |
diff --git a/crates/ra_proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt b/crates/ra_proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt index 6776f5231..bc010cfe9 100644 --- a/crates/ra_proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt +++ b/crates/ra_proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt | |||
@@ -23,23 +23,12 @@ SUBTREE $ | |||
23 | SUBTREE [] 4294967295 | 23 | SUBTREE [] 4294967295 |
24 | IDENT allow 4294967295 | 24 | IDENT allow 4294967295 |
25 | SUBTREE () 4294967295 | 25 | SUBTREE () 4294967295 |
26 | IDENT unknown_lints 4294967295 | ||
27 | PUNCH # [alone] 4294967295 | ||
28 | SUBTREE [] 4294967295 | ||
29 | IDENT cfg_attr 4294967295 | ||
30 | SUBTREE () 4294967295 | ||
31 | IDENT feature 4294967295 | ||
32 | PUNCH = [alone] 4294967295 | ||
33 | LITERAL "cargo-clippy" 0 | ||
34 | PUNCH , [alone] 4294967295 | ||
35 | IDENT allow 4294967295 | ||
36 | SUBTREE () 4294967295 | ||
37 | IDENT useless_attribute 4294967295 | ||
38 | PUNCH # [alone] 4294967295 | ||
39 | SUBTREE [] 4294967295 | ||
40 | IDENT allow 4294967295 | ||
41 | SUBTREE () 4294967295 | ||
42 | IDENT rust_2018_idioms 4294967295 | 26 | IDENT rust_2018_idioms 4294967295 |
27 | PUNCH , [alone] 4294967295 | ||
28 | IDENT clippy 4294967295 | ||
29 | PUNCH : [joint] 4294967295 | ||
30 | PUNCH : [alone] 4294967295 | ||
31 | IDENT useless_attribute 4294967295 | ||
43 | IDENT extern 4294967295 | 32 | IDENT extern 4294967295 |
44 | IDENT crate 4294967295 | 33 | IDENT crate 4294967295 |
45 | IDENT serde 4294967295 | 34 | IDENT serde 4294967295 |
diff --git a/crates/ra_proc_macro_srv/src/tests/mod.rs b/crates/ra_proc_macro_srv/src/tests/mod.rs index 9cf58511c..82cefbb29 100644 --- a/crates/ra_proc_macro_srv/src/tests/mod.rs +++ b/crates/ra_proc_macro_srv/src/tests/mod.rs | |||
@@ -10,7 +10,7 @@ fn test_derive_serialize_proc_macro() { | |||
10 | assert_expand( | 10 | assert_expand( |
11 | "serde_derive", | 11 | "serde_derive", |
12 | "Serialize", | 12 | "Serialize", |
13 | "1.0.106", | 13 | "1.0", |
14 | r##"struct Foo {}"##, | 14 | r##"struct Foo {}"##, |
15 | include_str!("fixtures/test_serialize_proc_macro.txt"), | 15 | include_str!("fixtures/test_serialize_proc_macro.txt"), |
16 | ); | 16 | ); |
@@ -21,7 +21,7 @@ fn test_derive_serialize_proc_macro_failed() { | |||
21 | assert_expand( | 21 | assert_expand( |
22 | "serde_derive", | 22 | "serde_derive", |
23 | "Serialize", | 23 | "Serialize", |
24 | "1.0.106", | 24 | "1.0", |
25 | r##" | 25 | r##" |
26 | struct {} | 26 | struct {} |
27 | "##, | 27 | "##, |
@@ -37,7 +37,7 @@ SUBTREE $ | |||
37 | 37 | ||
38 | #[test] | 38 | #[test] |
39 | fn test_derive_proc_macro_list() { | 39 | fn test_derive_proc_macro_list() { |
40 | let res = list("serde_derive", "1.0.106").join("\n"); | 40 | let res = list("serde_derive", "1.0").join("\n"); |
41 | 41 | ||
42 | assert_eq_text!( | 42 | assert_eq_text!( |
43 | &res, | 43 | &res, |
diff --git a/crates/ra_proc_macro_srv/src/tests/utils.rs b/crates/ra_proc_macro_srv/src/tests/utils.rs index 646a427c5..84348b5de 100644 --- a/crates/ra_proc_macro_srv/src/tests/utils.rs +++ b/crates/ra_proc_macro_srv/src/tests/utils.rs | |||
@@ -8,7 +8,7 @@ use std::str::FromStr; | |||
8 | use test_utils::assert_eq_text; | 8 | use test_utils::assert_eq_text; |
9 | 9 | ||
10 | mod fixtures { | 10 | mod fixtures { |
11 | use cargo_metadata::{parse_messages, Message}; | 11 | use cargo_metadata::Message; |
12 | use std::process::Command; | 12 | use std::process::Command; |
13 | 13 | ||
14 | // Use current project metadata to get the proc-macro dylib path | 14 | // Use current project metadata to get the proc-macro dylib path |
@@ -19,7 +19,7 @@ mod fixtures { | |||
19 | .unwrap() | 19 | .unwrap() |
20 | .stdout; | 20 | .stdout; |
21 | 21 | ||
22 | for message in parse_messages(command.as_slice()) { | 22 | for message in Message::parse_stream(command.as_slice()) { |
23 | match message.unwrap() { | 23 | match message.unwrap() { |
24 | Message::CompilerArtifact(artifact) => { | 24 | Message::CompilerArtifact(artifact) => { |
25 | if artifact.target.kind.contains(&"proc-macro".to_string()) { | 25 | if artifact.target.kind.contains(&"proc-macro".to_string()) { |
diff --git a/crates/ra_project_model/Cargo.toml b/crates/ra_project_model/Cargo.toml index a32a5daab..e4a60f4c0 100644 --- a/crates/ra_project_model/Cargo.toml +++ b/crates/ra_project_model/Cargo.toml | |||
@@ -11,7 +11,7 @@ doctest = false | |||
11 | log = "0.4.8" | 11 | log = "0.4.8" |
12 | rustc-hash = "1.1.0" | 12 | rustc-hash = "1.1.0" |
13 | 13 | ||
14 | cargo_metadata = "0.9.1" | 14 | cargo_metadata = "0.10.0" |
15 | 15 | ||
16 | ra_arena = { path = "../ra_arena" } | 16 | ra_arena = { path = "../ra_arena" } |
17 | ra_cfg = { path = "../ra_cfg" } | 17 | ra_cfg = { path = "../ra_cfg" } |
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs index 082af4f96..a306ce95f 100644 --- a/crates/ra_project_model/src/cargo_workspace.rs +++ b/crates/ra_project_model/src/cargo_workspace.rs | |||
@@ -161,7 +161,7 @@ impl CargoWorkspace { | |||
161 | meta.current_dir(parent); | 161 | meta.current_dir(parent); |
162 | } | 162 | } |
163 | if let Some(target) = cargo_features.target.as_ref() { | 163 | if let Some(target) = cargo_features.target.as_ref() { |
164 | meta.other_options(&[String::from("--filter-platform"), target.clone()]); | 164 | meta.other_options(vec![String::from("--filter-platform"), target.clone()]); |
165 | } | 165 | } |
166 | let meta = meta.exec().with_context(|| { | 166 | let meta = meta.exec().with_context(|| { |
167 | format!("Failed to run `cargo metadata --manifest-path {}`", cargo_toml.display()) | 167 | format!("Failed to run `cargo metadata --manifest-path {}`", cargo_toml.display()) |
@@ -304,19 +304,13 @@ pub fn load_extern_resources( | |||
304 | 304 | ||
305 | let mut res = ExternResources::default(); | 305 | let mut res = ExternResources::default(); |
306 | 306 | ||
307 | for message in cargo_metadata::parse_messages(output.stdout.as_slice()) { | 307 | for message in cargo_metadata::Message::parse_stream(output.stdout.as_slice()) { |
308 | if let Ok(message) = message { | 308 | if let Ok(message) = message { |
309 | match message { | 309 | match message { |
310 | Message::BuildScriptExecuted(BuildScript { package_id, out_dir, cfgs, .. }) => { | 310 | Message::BuildScriptExecuted(BuildScript { package_id, out_dir, cfgs, .. }) => { |
311 | res.out_dirs.insert(package_id.clone(), out_dir); | 311 | res.out_dirs.insert(package_id.clone(), out_dir); |
312 | res.cfgs.insert( | 312 | res.cfgs.insert(package_id, cfgs); |
313 | package_id, | ||
314 | // FIXME: Current `cargo_metadata` uses `PathBuf` instead of `String`, | ||
315 | // change when https://github.com/oli-obk/cargo_metadata/pulls/112 reaches crates.io | ||
316 | cfgs.iter().filter_map(|c| c.to_str().map(|s| s.to_owned())).collect(), | ||
317 | ); | ||
318 | } | 313 | } |
319 | |||
320 | Message::CompilerArtifact(message) => { | 314 | Message::CompilerArtifact(message) => { |
321 | if message.target.kind.contains(&"proc-macro".to_string()) { | 315 | if message.target.kind.contains(&"proc-macro".to_string()) { |
322 | let package_id = message.package_id; | 316 | let package_id = message.package_id; |
@@ -329,6 +323,8 @@ pub fn load_extern_resources( | |||
329 | } | 323 | } |
330 | Message::CompilerMessage(_) => (), | 324 | Message::CompilerMessage(_) => (), |
331 | Message::Unknown => (), | 325 | Message::Unknown => (), |
326 | Message::BuildFinished(_) => {} | ||
327 | Message::TextLine(_) => {} | ||
332 | } | 328 | } |
333 | } | 329 | } |
334 | } | 330 | } |