Skip to content

Commit 402dba8

Browse files
committedMay 23, 2022
Auto merge of rust-lang#12360 - Veykril:completion, r=Veykril
fix: Fix completions not working after attributes Closes rust-lang/rust-analyzer#12259
2 parents 8e8aa7b + 2aa2273 commit 402dba8

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed
 

‎crates/ide-completion/src/context.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,7 @@ impl<'a> CompletionContext<'a> {
371371
// FIXME: This shouldn't exist
372372
pub(crate) fn is_path_disallowed(&self) -> bool {
373373
self.previous_token_is(T![unsafe])
374-
|| matches!(
375-
self.prev_sibling,
376-
Some(ImmediatePrevSibling::Attribute | ImmediatePrevSibling::Visibility)
377-
)
374+
|| matches!(self.prev_sibling, Some(ImmediatePrevSibling::Visibility))
378375
|| matches!(
379376
self.completion_location,
380377
Some(ImmediateLocation::RecordPat(_) | ImmediateLocation::RecordExpr(_))

‎crates/ide-completion/src/patterns.rs

-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ pub(crate) enum ImmediatePrevSibling {
2424
TraitDefName,
2525
ImplDefType,
2626
Visibility,
27-
Attribute,
2827
}
2928

3029
#[derive(Clone, Debug, PartialEq, Eq)]
@@ -124,7 +123,6 @@ pub(crate) fn determine_prev_sibling(name_like: &ast::NameLike) -> Option<Immedi
124123
} else {
125124
return None
126125
},
127-
ast::Attr(_) => ImmediatePrevSibling::Attribute,
128126
_ => return None,
129127
}
130128
};
@@ -484,9 +482,4 @@ mod tests {
484482
fn test_vis_prev_sibling() {
485483
check_prev_sibling(r"pub w$0", ImmediatePrevSibling::Visibility);
486484
}
487-
488-
#[test]
489-
fn test_attr_prev_sibling() {
490-
check_prev_sibling(r"#[attr] w$0", ImmediatePrevSibling::Attribute);
491-
}
492485
}

‎crates/ide-completion/src/tests/item_list.rs

+10
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ fn in_item_list_after_attr() {
7878
check(
7979
r#"#[attr] $0"#,
8080
expect![[r#"
81+
ma makro!(…) macro_rules! makro
82+
md module
8183
kw const
84+
kw crate::
8285
kw enum
8386
kw extern
8487
kw fn
@@ -87,8 +90,10 @@ fn in_item_list_after_attr() {
8790
kw pub
8891
kw pub(crate)
8992
kw pub(super)
93+
kw self::
9094
kw static
9195
kw struct
96+
kw super::
9297
kw trait
9398
kw type
9499
kw union
@@ -184,11 +189,16 @@ fn in_impl_assoc_item_list_after_attr() {
184189
check(
185190
r#"impl Struct { #[attr] $0 }"#,
186191
expect![[r#"
192+
ma makro!(…) macro_rules! makro
193+
md module
187194
kw const
195+
kw crate::
188196
kw fn
189197
kw pub
190198
kw pub(crate)
191199
kw pub(super)
200+
kw self::
201+
kw super::
192202
kw type
193203
kw unsafe
194204
"#]],

0 commit comments

Comments
 (0)
Please sign in to comment.