diff options
Diffstat (limited to 'crates/ide/src/completion/complete_keyword.rs')
-rw-r--r-- | crates/ide/src/completion/complete_keyword.rs | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/crates/ide/src/completion/complete_keyword.rs b/crates/ide/src/completion/complete_keyword.rs index 95e4ff1ac..53ba76e0e 100644 --- a/crates/ide/src/completion/complete_keyword.rs +++ b/crates/ide/src/completion/complete_keyword.rs | |||
@@ -129,8 +129,9 @@ pub(super) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte | |||
129 | add_keyword(ctx, acc, "break", "break"); | 129 | add_keyword(ctx, acc, "break", "break"); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | if ctx.has_item_list_or_source_file_parent || ctx.has_impl_parent { | 132 | if ctx.has_item_list_or_source_file_parent || ctx.has_impl_parent | ctx.has_field_list_parent { |
133 | add_keyword(ctx, acc, "pub", "pub ") | 133 | add_keyword(ctx, acc, "pub(crate)", "pub(crate) "); |
134 | add_keyword(ctx, acc, "pub", "pub "); | ||
134 | } | 135 | } |
135 | 136 | ||
136 | if !ctx.is_trivial_path { | 137 | if !ctx.is_trivial_path { |
@@ -227,6 +228,7 @@ mod tests { | |||
227 | kw impl | 228 | kw impl |
228 | kw mod | 229 | kw mod |
229 | kw pub | 230 | kw pub |
231 | kw pub(crate) | ||
230 | kw static | 232 | kw static |
231 | kw struct | 233 | kw struct |
232 | kw trait | 234 | kw trait |
@@ -364,6 +366,7 @@ fn quux() -> i32 { | |||
364 | kw const | 366 | kw const |
365 | kw fn | 367 | kw fn |
366 | kw pub | 368 | kw pub |
369 | kw pub(crate) | ||
367 | kw type | 370 | kw type |
368 | kw unsafe | 371 | kw unsafe |
369 | "#]], | 372 | "#]], |
@@ -524,4 +527,20 @@ pub mod future { | |||
524 | "#]], | 527 | "#]], |
525 | ) | 528 | ) |
526 | } | 529 | } |
530 | |||
531 | #[test] | ||
532 | fn before_field() { | ||
533 | check( | ||
534 | r#" | ||
535 | struct Foo { | ||
536 | <|> | ||
537 | pub f: i32, | ||
538 | } | ||
539 | "#, | ||
540 | expect![[r#" | ||
541 | kw pub | ||
542 | kw pub(crate) | ||
543 | "#]], | ||
544 | ) | ||
545 | } | ||
527 | } | 546 | } |