diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-10 16:43:14 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-10 16:43:14 +0100 |
commit | 4ff47096f4a4676be1f4991138865a0154fb4731 (patch) | |
tree | b5a4bb6045818abfe224829c115c769c4a68f950 /crates/ra_ide/src/completion/completion_context.rs | |
parent | 5a195001d79995a6336988e18a2b78052917a02e (diff) | |
parent | 2d20c8f218710b7d98611cf501783a591b7dc0bb (diff) |
Merge #5296
5296: Don't add braces after struct r=matklad a=matklad
Unit structs are a thing
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide/src/completion/completion_context.rs')
-rw-r--r-- | crates/ra_ide/src/completion/completion_context.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index 7688a1483..8e1f6dd98 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs | |||
@@ -53,6 +53,8 @@ pub(crate) struct CompletionContext<'a> { | |||
53 | pub(super) after_if: bool, | 53 | pub(super) after_if: bool, |
54 | /// `true` if we are a statement or a last expr in the block. | 54 | /// `true` if we are a statement or a last expr in the block. |
55 | pub(super) can_be_stmt: bool, | 55 | pub(super) can_be_stmt: bool, |
56 | /// `true` if we expect an expression at the cursor position. | ||
57 | pub(super) can_be_expr: bool, | ||
56 | /// Something is typed at the "top" level, in module or impl/trait. | 58 | /// Something is typed at the "top" level, in module or impl/trait. |
57 | pub(super) is_new_item: bool, | 59 | pub(super) is_new_item: bool, |
58 | /// The receiver if this is a field or method access, i.e. writing something.<|> | 60 | /// The receiver if this is a field or method access, i.e. writing something.<|> |
@@ -127,6 +129,7 @@ impl<'a> CompletionContext<'a> { | |||
127 | path_prefix: None, | 129 | path_prefix: None, |
128 | after_if: false, | 130 | after_if: false, |
129 | can_be_stmt: false, | 131 | can_be_stmt: false, |
132 | can_be_expr: false, | ||
130 | is_new_item: false, | 133 | is_new_item: false, |
131 | dot_receiver: None, | 134 | dot_receiver: None, |
132 | is_call: false, | 135 | is_call: false, |
@@ -403,6 +406,7 @@ impl<'a> CompletionContext<'a> { | |||
403 | None | 406 | None |
404 | }) | 407 | }) |
405 | .unwrap_or(false); | 408 | .unwrap_or(false); |
409 | self.can_be_expr = path.syntax().parent().and_then(ast::PathExpr::cast).is_some(); | ||
406 | 410 | ||
407 | if let Some(off) = name_ref.syntax().text_range().start().checked_sub(2.into()) { | 411 | if let Some(off) = name_ref.syntax().text_range().start().checked_sub(2.into()) { |
408 | if let Some(if_expr) = | 412 | if let Some(if_expr) = |