diff options
Diffstat (limited to 'crates/ide')
28 files changed, 65 insertions, 49 deletions
diff --git a/crates/ide/Cargo.toml b/crates/ide/Cargo.toml index e4b970c73..336e9d2aa 100644 --- a/crates/ide/Cargo.toml +++ b/crates/ide/Cargo.toml | |||
@@ -1,6 +1,7 @@ | |||
1 | [package] | 1 | [package] |
2 | name = "ide" | 2 | name = "ide" |
3 | version = "0.0.0" | 3 | version = "0.0.0" |
4 | description = "TBD" | ||
4 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
5 | authors = ["rust-analyzer developers"] | 6 | authors = ["rust-analyzer developers"] |
6 | edition = "2018" | 7 | edition = "2018" |
@@ -16,20 +17,20 @@ log = "0.4.8" | |||
16 | rustc-hash = "1.1.0" | 17 | rustc-hash = "1.1.0" |
17 | oorandom = "11.1.2" | 18 | oorandom = "11.1.2" |
18 | 19 | ||
19 | stdx = { path = "../stdx" } | 20 | stdx = { path = "../stdx", version = "0.0.0" } |
20 | syntax = { path = "../syntax" } | 21 | syntax = { path = "../syntax", version = "0.0.0" } |
21 | text_edit = { path = "../text_edit" } | 22 | text_edit = { path = "../text_edit", version = "0.0.0" } |
22 | base_db = { path = "../base_db" } | 23 | base_db = { path = "../base_db", version = "0.0.0" } |
23 | ide_db = { path = "../ide_db" } | 24 | ide_db = { path = "../ide_db", version = "0.0.0" } |
24 | cfg = { path = "../cfg" } | 25 | cfg = { path = "../cfg", version = "0.0.0" } |
25 | profile = { path = "../profile" } | 26 | profile = { path = "../profile", version = "0.0.0" } |
26 | test_utils = { path = "../test_utils" } | 27 | test_utils = { path = "../test_utils", version = "0.0.0" } |
27 | assists = { path = "../assists" } | 28 | assists = { path = "../assists", version = "0.0.0" } |
28 | ssr = { path = "../ssr" } | 29 | ssr = { path = "../ssr", version = "0.0.0" } |
29 | 30 | ||
30 | # ide should depend only on the top-level `hir` package. if you need | 31 | # ide should depend only on the top-level `hir` package. if you need |
31 | # something from some `hir_xxx` subpackage, reexport the API via `hir`. | 32 | # something from some `hir_xxx` subpackage, reexport the API via `hir`. |
32 | hir = { path = "../hir" } | 33 | hir = { path = "../hir", version = "0.0.0" } |
33 | 34 | ||
34 | [dev-dependencies] | 35 | [dev-dependencies] |
35 | expect = { path = "../expect" } | 36 | expect-test = "0.1" |
diff --git a/crates/ide/src/call_info.rs b/crates/ide/src/call_info.rs index 86abd2d8c..7e83a2381 100644 --- a/crates/ide/src/call_info.rs +++ b/crates/ide/src/call_info.rs | |||
@@ -229,7 +229,7 @@ impl FnCallNode { | |||
229 | 229 | ||
230 | #[cfg(test)] | 230 | #[cfg(test)] |
231 | mod tests { | 231 | mod tests { |
232 | use expect::{expect, Expect}; | 232 | use expect_test::{expect, Expect}; |
233 | use test_utils::mark; | 233 | use test_utils::mark; |
234 | 234 | ||
235 | use crate::mock_analysis::analysis_and_position; | 235 | use crate::mock_analysis::analysis_and_position; |
diff --git a/crates/ide/src/completion.rs b/crates/ide/src/completion.rs index 25e580d80..33bed6991 100644 --- a/crates/ide/src/completion.rs +++ b/crates/ide/src/completion.rs | |||
@@ -92,7 +92,7 @@ pub use crate::completion::{ | |||
92 | /// already present, it should give all possible variants for the identifier at | 92 | /// already present, it should give all possible variants for the identifier at |
93 | /// the caret. In other words, for | 93 | /// the caret. In other words, for |
94 | /// | 94 | /// |
95 | /// ```no-run | 95 | /// ```no_run |
96 | /// fn f() { | 96 | /// fn f() { |
97 | /// let foo = 92; | 97 | /// let foo = 92; |
98 | /// let _ = bar<|> | 98 | /// let _ = bar<|> |
diff --git a/crates/ide/src/completion/complete_attribute.rs b/crates/ide/src/completion/complete_attribute.rs index 042c3ecef..0abfaebcb 100644 --- a/crates/ide/src/completion/complete_attribute.rs +++ b/crates/ide/src/completion/complete_attribute.rs | |||
@@ -383,7 +383,7 @@ const DEFAULT_LINT_COMPLETIONS: &[LintCompletion] = &[ | |||
383 | 383 | ||
384 | #[cfg(test)] | 384 | #[cfg(test)] |
385 | mod tests { | 385 | mod tests { |
386 | use expect::{expect, Expect}; | 386 | use expect_test::{expect, Expect}; |
387 | 387 | ||
388 | use crate::completion::{test_utils::completion_list, CompletionKind}; | 388 | use crate::completion::{test_utils::completion_list, CompletionKind}; |
389 | 389 | ||
diff --git a/crates/ide/src/completion/complete_dot.rs b/crates/ide/src/completion/complete_dot.rs index 5488db43f..0b9f1798a 100644 --- a/crates/ide/src/completion/complete_dot.rs +++ b/crates/ide/src/completion/complete_dot.rs | |||
@@ -61,7 +61,7 @@ fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: &T | |||
61 | 61 | ||
62 | #[cfg(test)] | 62 | #[cfg(test)] |
63 | mod tests { | 63 | mod tests { |
64 | use expect::{expect, Expect}; | 64 | use expect_test::{expect, Expect}; |
65 | use test_utils::mark; | 65 | use test_utils::mark; |
66 | 66 | ||
67 | use crate::completion::{test_utils::completion_list, CompletionKind}; | 67 | use crate::completion::{test_utils::completion_list, CompletionKind}; |
diff --git a/crates/ide/src/completion/complete_fn_param.rs b/crates/ide/src/completion/complete_fn_param.rs index 7c63ce58f..9efe25461 100644 --- a/crates/ide/src/completion/complete_fn_param.rs +++ b/crates/ide/src/completion/complete_fn_param.rs | |||
@@ -66,7 +66,7 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext) | |||
66 | 66 | ||
67 | #[cfg(test)] | 67 | #[cfg(test)] |
68 | mod tests { | 68 | mod tests { |
69 | use expect::{expect, Expect}; | 69 | use expect_test::{expect, Expect}; |
70 | 70 | ||
71 | use crate::completion::{test_utils::completion_list, CompletionKind}; | 71 | use crate::completion::{test_utils::completion_list, CompletionKind}; |
72 | 72 | ||
diff --git a/crates/ide/src/completion/complete_keyword.rs b/crates/ide/src/completion/complete_keyword.rs index 22ada3cf2..95e4ff1ac 100644 --- a/crates/ide/src/completion/complete_keyword.rs +++ b/crates/ide/src/completion/complete_keyword.rs | |||
@@ -174,7 +174,7 @@ fn complete_return( | |||
174 | 174 | ||
175 | #[cfg(test)] | 175 | #[cfg(test)] |
176 | mod tests { | 176 | mod tests { |
177 | use expect::{expect, Expect}; | 177 | use expect_test::{expect, Expect}; |
178 | 178 | ||
179 | use crate::completion::{ | 179 | use crate::completion::{ |
180 | test_utils::{check_edit, completion_list}, | 180 | test_utils::{check_edit, completion_list}, |
diff --git a/crates/ide/src/completion/complete_macro_in_item_position.rs b/crates/ide/src/completion/complete_macro_in_item_position.rs index 0447f0511..fc8625d8e 100644 --- a/crates/ide/src/completion/complete_macro_in_item_position.rs +++ b/crates/ide/src/completion/complete_macro_in_item_position.rs | |||
@@ -15,7 +15,7 @@ pub(super) fn complete_macro_in_item_position(acc: &mut Completions, ctx: &Compl | |||
15 | 15 | ||
16 | #[cfg(test)] | 16 | #[cfg(test)] |
17 | mod tests { | 17 | mod tests { |
18 | use expect::{expect, Expect}; | 18 | use expect_test::{expect, Expect}; |
19 | 19 | ||
20 | use crate::completion::{test_utils::completion_list, CompletionKind}; | 20 | use crate::completion::{test_utils::completion_list, CompletionKind}; |
21 | 21 | ||
diff --git a/crates/ide/src/completion/complete_pattern.rs b/crates/ide/src/completion/complete_pattern.rs index aceb77cb5..5a13574d4 100644 --- a/crates/ide/src/completion/complete_pattern.rs +++ b/crates/ide/src/completion/complete_pattern.rs | |||
@@ -33,7 +33,7 @@ pub(super) fn complete_pattern(acc: &mut Completions, ctx: &CompletionContext) { | |||
33 | 33 | ||
34 | #[cfg(test)] | 34 | #[cfg(test)] |
35 | mod tests { | 35 | mod tests { |
36 | use expect::{expect, Expect}; | 36 | use expect_test::{expect, Expect}; |
37 | 37 | ||
38 | use crate::completion::{test_utils::completion_list, CompletionKind}; | 38 | use crate::completion::{test_utils::completion_list, CompletionKind}; |
39 | 39 | ||
diff --git a/crates/ide/src/completion/complete_postfix.rs b/crates/ide/src/completion/complete_postfix.rs index d50b13c52..84c4e129d 100644 --- a/crates/ide/src/completion/complete_postfix.rs +++ b/crates/ide/src/completion/complete_postfix.rs | |||
@@ -238,7 +238,7 @@ fn postfix_snippet( | |||
238 | 238 | ||
239 | #[cfg(test)] | 239 | #[cfg(test)] |
240 | mod tests { | 240 | mod tests { |
241 | use expect::{expect, Expect}; | 241 | use expect_test::{expect, Expect}; |
242 | 242 | ||
243 | use crate::completion::{ | 243 | use crate::completion::{ |
244 | test_utils::{check_edit, completion_list}, | 244 | test_utils::{check_edit, completion_list}, |
diff --git a/crates/ide/src/completion/complete_qualified_path.rs b/crates/ide/src/completion/complete_qualified_path.rs index 74794dc88..accb09f7e 100644 --- a/crates/ide/src/completion/complete_qualified_path.rs +++ b/crates/ide/src/completion/complete_qualified_path.rs | |||
@@ -146,7 +146,7 @@ pub(super) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon | |||
146 | 146 | ||
147 | #[cfg(test)] | 147 | #[cfg(test)] |
148 | mod tests { | 148 | mod tests { |
149 | use expect::{expect, Expect}; | 149 | use expect_test::{expect, Expect}; |
150 | use test_utils::mark; | 150 | use test_utils::mark; |
151 | 151 | ||
152 | use crate::completion::{ | 152 | use crate::completion::{ |
diff --git a/crates/ide/src/completion/complete_record.rs b/crates/ide/src/completion/complete_record.rs index 74b94594d..ceb8d16c1 100644 --- a/crates/ide/src/completion/complete_record.rs +++ b/crates/ide/src/completion/complete_record.rs | |||
@@ -18,7 +18,7 @@ pub(super) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) -> | |||
18 | 18 | ||
19 | #[cfg(test)] | 19 | #[cfg(test)] |
20 | mod tests { | 20 | mod tests { |
21 | use expect::{expect, Expect}; | 21 | use expect_test::{expect, Expect}; |
22 | 22 | ||
23 | use crate::completion::{test_utils::completion_list, CompletionKind}; | 23 | use crate::completion::{test_utils::completion_list, CompletionKind}; |
24 | 24 | ||
diff --git a/crates/ide/src/completion/complete_snippet.rs b/crates/ide/src/completion/complete_snippet.rs index 4368e4eec..c3b03b199 100644 --- a/crates/ide/src/completion/complete_snippet.rs +++ b/crates/ide/src/completion/complete_snippet.rs | |||
@@ -70,7 +70,7 @@ fn ${1:feature}() { | |||
70 | 70 | ||
71 | #[cfg(test)] | 71 | #[cfg(test)] |
72 | mod tests { | 72 | mod tests { |
73 | use expect::{expect, Expect}; | 73 | use expect_test::{expect, Expect}; |
74 | 74 | ||
75 | use crate::completion::{test_utils::completion_list, CompletionKind}; | 75 | use crate::completion::{test_utils::completion_list, CompletionKind}; |
76 | 76 | ||
diff --git a/crates/ide/src/completion/complete_trait_impl.rs b/crates/ide/src/completion/complete_trait_impl.rs index d0d3a9f34..1a2b1e8a5 100644 --- a/crates/ide/src/completion/complete_trait_impl.rs +++ b/crates/ide/src/completion/complete_trait_impl.rs | |||
@@ -225,7 +225,7 @@ fn make_const_compl_syntax(const_: &ast::Const) -> String { | |||
225 | 225 | ||
226 | #[cfg(test)] | 226 | #[cfg(test)] |
227 | mod tests { | 227 | mod tests { |
228 | use expect::{expect, Expect}; | 228 | use expect_test::{expect, Expect}; |
229 | 229 | ||
230 | use crate::completion::{ | 230 | use crate::completion::{ |
231 | test_utils::{check_edit, completion_list}, | 231 | test_utils::{check_edit, completion_list}, |
diff --git a/crates/ide/src/completion/complete_unqualified_path.rs b/crates/ide/src/completion/complete_unqualified_path.rs index 824227f31..1f1b682a7 100644 --- a/crates/ide/src/completion/complete_unqualified_path.rs +++ b/crates/ide/src/completion/complete_unqualified_path.rs | |||
@@ -64,7 +64,7 @@ fn complete_enum_variants(acc: &mut Completions, ctx: &CompletionContext, ty: &T | |||
64 | 64 | ||
65 | #[cfg(test)] | 65 | #[cfg(test)] |
66 | mod tests { | 66 | mod tests { |
67 | use expect::{expect, Expect}; | 67 | use expect_test::{expect, Expect}; |
68 | use test_utils::mark; | 68 | use test_utils::mark; |
69 | 69 | ||
70 | use crate::completion::{ | 70 | use crate::completion::{ |
diff --git a/crates/ide/src/completion/completion_context.rs b/crates/ide/src/completion/completion_context.rs index 85456a66f..5adac7ebc 100644 --- a/crates/ide/src/completion/completion_context.rs +++ b/crates/ide/src/completion/completion_context.rs | |||
@@ -457,7 +457,7 @@ impl<'a> CompletionContext<'a> { | |||
457 | if let Some(method_call_expr) = ast::MethodCallExpr::cast(parent) { | 457 | if let Some(method_call_expr) = ast::MethodCallExpr::cast(parent) { |
458 | // As above | 458 | // As above |
459 | self.dot_receiver = method_call_expr | 459 | self.dot_receiver = method_call_expr |
460 | .expr() | 460 | .receiver() |
461 | .map(|e| e.syntax().text_range()) | 461 | .map(|e| e.syntax().text_range()) |
462 | .and_then(|r| find_node_with_range(original_file, r)); | 462 | .and_then(|r| find_node_with_range(original_file, r)); |
463 | self.is_call = true; | 463 | self.is_call = true; |
diff --git a/crates/ide/src/completion/presentation.rs b/crates/ide/src/completion/presentation.rs index a73f8ab0b..3371aed2d 100644 --- a/crates/ide/src/completion/presentation.rs +++ b/crates/ide/src/completion/presentation.rs | |||
@@ -464,7 +464,7 @@ fn guess_macro_braces(macro_name: &str, docs: &str) -> (&'static str, &'static s | |||
464 | mod tests { | 464 | mod tests { |
465 | use std::cmp::Reverse; | 465 | use std::cmp::Reverse; |
466 | 466 | ||
467 | use expect::{expect, Expect}; | 467 | use expect_test::{expect, Expect}; |
468 | use test_utils::mark; | 468 | use test_utils::mark; |
469 | 469 | ||
470 | use crate::{ | 470 | use crate::{ |
diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs index 92b5adaa2..b2b972b02 100644 --- a/crates/ide/src/diagnostics.rs +++ b/crates/ide/src/diagnostics.rs | |||
@@ -214,7 +214,7 @@ fn check_struct_shorthand_initialization( | |||
214 | 214 | ||
215 | #[cfg(test)] | 215 | #[cfg(test)] |
216 | mod tests { | 216 | mod tests { |
217 | use expect::{expect, Expect}; | 217 | use expect_test::{expect, Expect}; |
218 | use stdx::trim_indent; | 218 | use stdx::trim_indent; |
219 | use test_utils::assert_eq_text; | 219 | use test_utils::assert_eq_text; |
220 | 220 | ||
diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs index e77106177..1ee80c2dd 100644 --- a/crates/ide/src/display/navigation_target.rs +++ b/crates/ide/src/display/navigation_target.rs | |||
@@ -421,7 +421,7 @@ pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> | |||
421 | 421 | ||
422 | #[cfg(test)] | 422 | #[cfg(test)] |
423 | mod tests { | 423 | mod tests { |
424 | use expect::expect; | 424 | use expect_test::expect; |
425 | 425 | ||
426 | use crate::{mock_analysis::single_file, Query}; | 426 | use crate::{mock_analysis::single_file, Query}; |
427 | 427 | ||
diff --git a/crates/ide/src/expand_macro.rs b/crates/ide/src/expand_macro.rs index 31455709d..8a285bcf7 100644 --- a/crates/ide/src/expand_macro.rs +++ b/crates/ide/src/expand_macro.rs | |||
@@ -120,7 +120,7 @@ fn insert_whitespaces(syn: SyntaxNode) -> String { | |||
120 | 120 | ||
121 | #[cfg(test)] | 121 | #[cfg(test)] |
122 | mod tests { | 122 | mod tests { |
123 | use expect::{expect, Expect}; | 123 | use expect_test::{expect, Expect}; |
124 | 124 | ||
125 | use crate::mock_analysis::analysis_and_position; | 125 | use crate::mock_analysis::analysis_and_position; |
126 | 126 | ||
diff --git a/crates/ide/src/file_structure.rs b/crates/ide/src/file_structure.rs index c90247ba6..6168fb837 100644 --- a/crates/ide/src/file_structure.rs +++ b/crates/ide/src/file_structure.rs | |||
@@ -164,7 +164,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> { | |||
164 | 164 | ||
165 | #[cfg(test)] | 165 | #[cfg(test)] |
166 | mod tests { | 166 | mod tests { |
167 | use expect::{expect, Expect}; | 167 | use expect_test::{expect, Expect}; |
168 | 168 | ||
169 | use super::*; | 169 | use super::*; |
170 | 170 | ||
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index 300c00edc..c75b2a510 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs | |||
@@ -353,7 +353,7 @@ fn pick_best(tokens: TokenAtOffset<SyntaxToken>) -> Option<SyntaxToken> { | |||
353 | #[cfg(test)] | 353 | #[cfg(test)] |
354 | mod tests { | 354 | mod tests { |
355 | use base_db::FileLoader; | 355 | use base_db::FileLoader; |
356 | use expect::{expect, Expect}; | 356 | use expect_test::{expect, Expect}; |
357 | 357 | ||
358 | use crate::mock_analysis::analysis_and_position; | 358 | use crate::mock_analysis::analysis_and_position; |
359 | 359 | ||
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs index 596bc872d..583f39d85 100644 --- a/crates/ide/src/inlay_hints.rs +++ b/crates/ide/src/inlay_hints.rs | |||
@@ -336,7 +336,7 @@ fn get_callable(sema: &Semantics<RootDatabase>, expr: &ast::Expr) -> Option<Call | |||
336 | 336 | ||
337 | #[cfg(test)] | 337 | #[cfg(test)] |
338 | mod tests { | 338 | mod tests { |
339 | use expect::{expect, Expect}; | 339 | use expect_test::{expect, Expect}; |
340 | use test_utils::extract_annotations; | 340 | use test_utils::extract_annotations; |
341 | 341 | ||
342 | use crate::{inlay_hints::InlayHintsConfig, mock_analysis::single_file}; | 342 | use crate::{inlay_hints::InlayHintsConfig, mock_analysis::single_file}; |
diff --git a/crates/ide/src/references/rename.rs b/crates/ide/src/references/rename.rs index d73dc9cd0..301629763 100644 --- a/crates/ide/src/references/rename.rs +++ b/crates/ide/src/references/rename.rs | |||
@@ -270,7 +270,7 @@ fn rename_reference( | |||
270 | 270 | ||
271 | #[cfg(test)] | 271 | #[cfg(test)] |
272 | mod tests { | 272 | mod tests { |
273 | use expect::{expect, Expect}; | 273 | use expect_test::{expect, Expect}; |
274 | use stdx::trim_indent; | 274 | use stdx::trim_indent; |
275 | use test_utils::{assert_eq_text, mark}; | 275 | use test_utils::{assert_eq_text, mark}; |
276 | use text_edit::TextEdit; | 276 | use text_edit::TextEdit; |
diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs index c3e07c8de..dd59d9e70 100644 --- a/crates/ide/src/runnables.rs +++ b/crates/ide/src/runnables.rs | |||
@@ -160,7 +160,7 @@ fn runnable_fn( | |||
160 | RunnableKind::Test { test_id, attr } | 160 | RunnableKind::Test { test_id, attr } |
161 | } else if fn_def.has_atom_attr("bench") { | 161 | } else if fn_def.has_atom_attr("bench") { |
162 | RunnableKind::Bench { test_id } | 162 | RunnableKind::Bench { test_id } |
163 | } else if has_doc_test(&fn_def) { | 163 | } else if has_runnable_doc_test(&fn_def) { |
164 | RunnableKind::DocTest { test_id } | 164 | RunnableKind::DocTest { test_id } |
165 | } else { | 165 | } else { |
166 | return None; | 166 | return None; |
@@ -211,8 +211,13 @@ fn has_test_related_attribute(fn_def: &ast::Fn) -> bool { | |||
211 | .any(|attribute_text| attribute_text.contains("test")) | 211 | .any(|attribute_text| attribute_text.contains("test")) |
212 | } | 212 | } |
213 | 213 | ||
214 | fn has_doc_test(fn_def: &ast::Fn) -> bool { | 214 | fn has_runnable_doc_test(fn_def: &ast::Fn) -> bool { |
215 | fn_def.doc_comment_text().map_or(false, |comment| comment.contains("```")) | 215 | fn_def.doc_comment_text().map_or(false, |comments_text| { |
216 | comments_text.contains("```") | ||
217 | && !comments_text.contains("```ignore") | ||
218 | && !comments_text.contains("```no_run") | ||
219 | && !comments_text.contains("```compile_fail") | ||
220 | }) | ||
216 | } | 221 | } |
217 | 222 | ||
218 | fn runnable_mod( | 223 | fn runnable_mod( |
@@ -268,7 +273,7 @@ fn has_test_function_or_multiple_test_submodules(module: &ast::Module) -> bool { | |||
268 | 273 | ||
269 | #[cfg(test)] | 274 | #[cfg(test)] |
270 | mod tests { | 275 | mod tests { |
271 | use expect::{expect, Expect}; | 276 | use expect_test::{expect, Expect}; |
272 | 277 | ||
273 | use crate::mock_analysis::analysis_and_position; | 278 | use crate::mock_analysis::analysis_and_position; |
274 | 279 | ||
@@ -417,6 +422,21 @@ fn main() {} | |||
417 | /// let x = 5; | 422 | /// let x = 5; |
418 | /// ``` | 423 | /// ``` |
419 | fn foo() {} | 424 | fn foo() {} |
425 | |||
426 | /// ```no_run | ||
427 | /// let z = 55; | ||
428 | /// ``` | ||
429 | fn should_have_no_runnable() {} | ||
430 | |||
431 | /// ```ignore | ||
432 | /// let z = 55; | ||
433 | /// ``` | ||
434 | fn should_have_no_runnable_2() {} | ||
435 | |||
436 | /// ```compile_fail | ||
437 | /// let z = 55; | ||
438 | /// ``` | ||
439 | fn should_have_no_runnable_3() {} | ||
420 | "#, | 440 | "#, |
421 | &[&BIN, &DOCTEST], | 441 | &[&BIN, &DOCTEST], |
422 | expect![[r#" | 442 | expect![[r#" |
diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs index dd8cfe42d..25d6f7abd 100644 --- a/crates/ide/src/syntax_highlighting.rs +++ b/crates/ide/src/syntax_highlighting.rs | |||
@@ -724,7 +724,8 @@ fn highlight_method_call( | |||
724 | hir::Access::Shared => (), | 724 | hir::Access::Shared => (), |
725 | hir::Access::Exclusive => h |= HighlightModifier::Mutable, | 725 | hir::Access::Exclusive => h |= HighlightModifier::Mutable, |
726 | hir::Access::Owned => { | 726 | hir::Access::Owned => { |
727 | if let Some(receiver_ty) = method_call.expr().and_then(|it| sema.type_of_expr(&it)) | 727 | if let Some(receiver_ty) = |
728 | method_call.receiver().and_then(|it| sema.type_of_expr(&it)) | ||
728 | { | 729 | { |
729 | if !receiver_ty.is_copy(sema.db) { | 730 | if !receiver_ty.is_copy(sema.db) { |
730 | h |= HighlightModifier::Consuming | 731 | h |= HighlightModifier::Consuming |
@@ -747,12 +748,6 @@ fn highlight_def(db: &RootDatabase, def: Definition) -> Highlight { | |||
747 | if func.is_unsafe(db) { | 748 | if func.is_unsafe(db) { |
748 | h |= HighlightModifier::Unsafe; | 749 | h |= HighlightModifier::Unsafe; |
749 | } | 750 | } |
750 | if let Some(self_param) = func.self_param(db) { | ||
751 | match self_param.access(db) { | ||
752 | hir::Access::Exclusive => h |= HighlightModifier::Mutable, | ||
753 | hir::Access::Shared | hir::Access::Owned => (), | ||
754 | } | ||
755 | } | ||
756 | return h; | 751 | return h; |
757 | } | 752 | } |
758 | hir::ModuleDef::Adt(hir::Adt::Struct(_)) => HighlightTag::Struct, | 753 | hir::ModuleDef::Adt(hir::Adt::Struct(_)) => HighlightTag::Struct, |
diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs index ccb76f552..1c3fea058 100644 --- a/crates/ide/src/syntax_highlighting/tests.rs +++ b/crates/ide/src/syntax_highlighting/tests.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use std::fs; | 1 | use std::fs; |
2 | 2 | ||
3 | use expect::{expect_file, ExpectFile}; | 3 | use expect_test::{expect_file, ExpectFile}; |
4 | use test_utils::project_dir; | 4 | use test_utils::project_dir; |
5 | 5 | ||
6 | use crate::{mock_analysis::single_file, FileRange, TextRange}; | 6 | use crate::{mock_analysis::single_file, FileRange, TextRange}; |
diff --git a/crates/ide/test_data/highlighting.html b/crates/ide/test_data/highlighting.html index a6b79589b..d0df2e0ec 100644 --- a/crates/ide/test_data/highlighting.html +++ b/crates/ide/test_data/highlighting.html | |||
@@ -65,7 +65,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
65 | <span class="self_keyword">self</span><span class="punctuation">.</span><span class="field">x</span> | 65 | <span class="self_keyword">self</span><span class="punctuation">.</span><span class="field">x</span> |
66 | <span class="punctuation">}</span> | 66 | <span class="punctuation">}</span> |
67 | 67 | ||
68 | <span class="keyword">fn</span> <span class="function declaration mutable">qux</span><span class="punctuation">(</span><span class="operator">&</span><span class="keyword">mut</span> <span class="self_keyword mutable">self</span><span class="punctuation">)</span> <span class="punctuation">{</span> | 68 | <span class="keyword">fn</span> <span class="function declaration">qux</span><span class="punctuation">(</span><span class="operator">&</span><span class="keyword">mut</span> <span class="self_keyword mutable">self</span><span class="punctuation">)</span> <span class="punctuation">{</span> |
69 | <span class="self_keyword mutable">self</span><span class="punctuation">.</span><span class="field">x</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="punctuation">;</span> | 69 | <span class="self_keyword mutable">self</span><span class="punctuation">.</span><span class="field">x</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="punctuation">;</span> |
70 | <span class="punctuation">}</span> | 70 | <span class="punctuation">}</span> |
71 | 71 | ||
@@ -84,7 +84,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
84 | <span class="self_keyword">self</span><span class="punctuation">.</span><span class="field">x</span> | 84 | <span class="self_keyword">self</span><span class="punctuation">.</span><span class="field">x</span> |
85 | <span class="punctuation">}</span> | 85 | <span class="punctuation">}</span> |
86 | 86 | ||
87 | <span class="keyword">fn</span> <span class="function declaration mutable">qux</span><span class="punctuation">(</span><span class="operator">&</span><span class="keyword">mut</span> <span class="self_keyword mutable">self</span><span class="punctuation">)</span> <span class="punctuation">{</span> | 87 | <span class="keyword">fn</span> <span class="function declaration">qux</span><span class="punctuation">(</span><span class="operator">&</span><span class="keyword">mut</span> <span class="self_keyword mutable">self</span><span class="punctuation">)</span> <span class="punctuation">{</span> |
88 | <span class="self_keyword mutable">self</span><span class="punctuation">.</span><span class="field">x</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="punctuation">;</span> | 88 | <span class="self_keyword mutable">self</span><span class="punctuation">.</span><span class="field">x</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="punctuation">;</span> |
89 | <span class="punctuation">}</span> | 89 | <span class="punctuation">}</span> |
90 | 90 | ||