Don't show incorrect completions after unsafe or visiblity node

This commit is contained in:
Lukas Wirth 2021-06-16 17:56:04 +02:00
parent 1a8f76a224
commit 9ea6ee6b27
4 changed files with 38 additions and 42 deletions

View file

@ -311,13 +311,16 @@ impl<'a> CompletionContext<'a> {
}
pub(crate) fn is_path_disallowed(&self) -> bool {
matches!(
self.completion_location,
Some(ImmediateLocation::Attribute(_))
| Some(ImmediateLocation::ModDeclaration(_))
| Some(ImmediateLocation::RecordPat(_))
| Some(ImmediateLocation::RecordExpr(_))
) || self.attribute_under_caret.is_some()
self.attribute_under_caret.is_some()
|| self.previous_token_is(T![unsafe])
|| self.has_visibility_prev_sibling()
|| matches!(
self.completion_location,
Some(ImmediateLocation::Attribute(_))
| Some(ImmediateLocation::ModDeclaration(_))
| Some(ImmediateLocation::RecordPat(_))
| Some(ImmediateLocation::RecordExpr(_))
)
}
pub(crate) fn expects_expression(&self) -> bool {