mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Auto merge of #12360 - Veykril:completion, r=Veykril
fix: Fix completions not working after attributes Closes https://github.com/rust-lang/rust-analyzer/issues/12259
This commit is contained in:
commit
402dba8d04
3 changed files with 11 additions and 11 deletions
|
@ -371,10 +371,7 @@ impl<'a> CompletionContext<'a> {
|
||||||
// FIXME: This shouldn't exist
|
// FIXME: This shouldn't exist
|
||||||
pub(crate) fn is_path_disallowed(&self) -> bool {
|
pub(crate) fn is_path_disallowed(&self) -> bool {
|
||||||
self.previous_token_is(T![unsafe])
|
self.previous_token_is(T![unsafe])
|
||||||
|| matches!(
|
|| matches!(self.prev_sibling, Some(ImmediatePrevSibling::Visibility))
|
||||||
self.prev_sibling,
|
|
||||||
Some(ImmediatePrevSibling::Attribute | ImmediatePrevSibling::Visibility)
|
|
||||||
)
|
|
||||||
|| matches!(
|
|| matches!(
|
||||||
self.completion_location,
|
self.completion_location,
|
||||||
Some(ImmediateLocation::RecordPat(_) | ImmediateLocation::RecordExpr(_))
|
Some(ImmediateLocation::RecordPat(_) | ImmediateLocation::RecordExpr(_))
|
||||||
|
|
|
@ -24,7 +24,6 @@ pub(crate) enum ImmediatePrevSibling {
|
||||||
TraitDefName,
|
TraitDefName,
|
||||||
ImplDefType,
|
ImplDefType,
|
||||||
Visibility,
|
Visibility,
|
||||||
Attribute,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
|
@ -124,7 +123,6 @@ pub(crate) fn determine_prev_sibling(name_like: &ast::NameLike) -> Option<Immedi
|
||||||
} else {
|
} else {
|
||||||
return None
|
return None
|
||||||
},
|
},
|
||||||
ast::Attr(_) => ImmediatePrevSibling::Attribute,
|
|
||||||
_ => return None,
|
_ => return None,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -484,9 +482,4 @@ mod tests {
|
||||||
fn test_vis_prev_sibling() {
|
fn test_vis_prev_sibling() {
|
||||||
check_prev_sibling(r"pub w$0", ImmediatePrevSibling::Visibility);
|
check_prev_sibling(r"pub w$0", ImmediatePrevSibling::Visibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_attr_prev_sibling() {
|
|
||||||
check_prev_sibling(r"#[attr] w$0", ImmediatePrevSibling::Attribute);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,10 @@ fn in_item_list_after_attr() {
|
||||||
check(
|
check(
|
||||||
r#"#[attr] $0"#,
|
r#"#[attr] $0"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
|
ma makro!(…) macro_rules! makro
|
||||||
|
md module
|
||||||
kw const
|
kw const
|
||||||
|
kw crate::
|
||||||
kw enum
|
kw enum
|
||||||
kw extern
|
kw extern
|
||||||
kw fn
|
kw fn
|
||||||
|
@ -87,8 +90,10 @@ fn in_item_list_after_attr() {
|
||||||
kw pub
|
kw pub
|
||||||
kw pub(crate)
|
kw pub(crate)
|
||||||
kw pub(super)
|
kw pub(super)
|
||||||
|
kw self::
|
||||||
kw static
|
kw static
|
||||||
kw struct
|
kw struct
|
||||||
|
kw super::
|
||||||
kw trait
|
kw trait
|
||||||
kw type
|
kw type
|
||||||
kw union
|
kw union
|
||||||
|
@ -184,11 +189,16 @@ fn in_impl_assoc_item_list_after_attr() {
|
||||||
check(
|
check(
|
||||||
r#"impl Struct { #[attr] $0 }"#,
|
r#"impl Struct { #[attr] $0 }"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
|
ma makro!(…) macro_rules! makro
|
||||||
|
md module
|
||||||
kw const
|
kw const
|
||||||
|
kw crate::
|
||||||
kw fn
|
kw fn
|
||||||
kw pub
|
kw pub
|
||||||
kw pub(crate)
|
kw pub(crate)
|
||||||
kw pub(super)
|
kw pub(super)
|
||||||
|
kw self::
|
||||||
|
kw super::
|
||||||
kw type
|
kw type
|
||||||
kw unsafe
|
kw unsafe
|
||||||
"#]],
|
"#]],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue