aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/context.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-06-17 17:22:32 +0100
committerGitHub <[email protected]>2021-06-17 17:22:32 +0100
commitce926aebc4461e38535047958c0b6f72b7a0c0ea (patch)
tree4b844e0681b459836bac22c34bee43e4dfa3dc5f /crates/ide_completion/src/context.rs
parent3ae0c5911ab50ee209179ee4329b0551abe6fc48 (diff)
parent02d25ab60d2701ce71fe2dfaca36627ad902e229 (diff)
Merge #9315
9315: Nest all the or-patterns! r=Veykril a=Veykril `cargo +nightly clippy --fix -Z unstable-options --allow-dirty -- -A clippy::all -D clippy::unnested_or_patterns` Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/ide_completion/src/context.rs')
-rw-r--r--crates/ide_completion/src/context.rs31
1 files changed, 16 insertions, 15 deletions
diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs
index d7a7e9cca..98fb36042 100644
--- a/crates/ide_completion/src/context.rs
+++ b/crates/ide_completion/src/context.rs
@@ -242,24 +242,23 @@ impl<'a> CompletionContext<'a> {
242 } 242 }
243 243
244 pub(crate) fn expects_assoc_item(&self) -> bool { 244 pub(crate) fn expects_assoc_item(&self) -> bool {
245 matches!( 245 matches!(self.completion_location, Some(ImmediateLocation::Trait | ImmediateLocation::Impl))
246 self.completion_location,
247 Some(ImmediateLocation::Trait) | Some(ImmediateLocation::Impl)
248 )
249 } 246 }
250 247
251 pub(crate) fn has_dot_receiver(&self) -> bool { 248 pub(crate) fn has_dot_receiver(&self) -> bool {
252 matches!( 249 matches!(
253 &self.completion_location, 250 &self.completion_location,
254 Some(ImmediateLocation::FieldAccess { receiver, .. }) | Some(ImmediateLocation::MethodCall { receiver,.. }) 251 Some(ImmediateLocation::FieldAccess { receiver, .. } | ImmediateLocation::MethodCall { receiver,.. })
255 if receiver.is_some() 252 if receiver.is_some()
256 ) 253 )
257 } 254 }
258 255
259 pub(crate) fn dot_receiver(&self) -> Option<&ast::Expr> { 256 pub(crate) fn dot_receiver(&self) -> Option<&ast::Expr> {
260 match &self.completion_location { 257 match &self.completion_location {
261 Some(ImmediateLocation::MethodCall { receiver, .. }) 258 Some(
262 | Some(ImmediateLocation::FieldAccess { receiver, .. }) => receiver.as_ref(), 259 ImmediateLocation::MethodCall { receiver, .. }
260 | ImmediateLocation::FieldAccess { receiver, .. },
261 ) => receiver.as_ref(),
263 _ => None, 262 _ => None,
264 } 263 }
265 } 264 }
@@ -283,7 +282,7 @@ impl<'a> CompletionContext<'a> {
283 pub(crate) fn expects_ident_pat_or_ref_expr(&self) -> bool { 282 pub(crate) fn expects_ident_pat_or_ref_expr(&self) -> bool {
284 matches!( 283 matches!(
285 self.completion_location, 284 self.completion_location,
286 Some(ImmediateLocation::IdentPat) | Some(ImmediateLocation::RefExpr) 285 Some(ImmediateLocation::IdentPat | ImmediateLocation::RefExpr)
287 ) 286 )
288 } 287 }
289 288
@@ -294,14 +293,14 @@ impl<'a> CompletionContext<'a> {
294 pub(crate) fn in_use_tree(&self) -> bool { 293 pub(crate) fn in_use_tree(&self) -> bool {
295 matches!( 294 matches!(
296 self.completion_location, 295 self.completion_location,
297 Some(ImmediateLocation::Use) | Some(ImmediateLocation::UseTree) 296 Some(ImmediateLocation::Use | ImmediateLocation::UseTree)
298 ) 297 )
299 } 298 }
300 299
301 pub(crate) fn has_impl_or_trait_prev_sibling(&self) -> bool { 300 pub(crate) fn has_impl_or_trait_prev_sibling(&self) -> bool {
302 matches!( 301 matches!(
303 self.prev_sibling, 302 self.prev_sibling,
304 Some(ImmediatePrevSibling::ImplDefType) | Some(ImmediatePrevSibling::TraitDefName) 303 Some(ImmediatePrevSibling::ImplDefType | ImmediatePrevSibling::TraitDefName)
305 ) 304 )
306 } 305 }
307 306
@@ -322,14 +321,16 @@ impl<'a> CompletionContext<'a> {
322 || self.previous_token_is(T![unsafe]) 321 || self.previous_token_is(T![unsafe])
323 || matches!( 322 || matches!(
324 self.prev_sibling, 323 self.prev_sibling,
325 Some(ImmediatePrevSibling::Attribute) | Some(ImmediatePrevSibling::Visibility) 324 Some(ImmediatePrevSibling::Attribute | ImmediatePrevSibling::Visibility)
326 ) 325 )
327 || matches!( 326 || matches!(
328 self.completion_location, 327 self.completion_location,
329 Some(ImmediateLocation::Attribute(_)) 328 Some(
330 | Some(ImmediateLocation::ModDeclaration(_)) 329 ImmediateLocation::Attribute(_)
331 | Some(ImmediateLocation::RecordPat(_)) 330 | ImmediateLocation::ModDeclaration(_)
332 | Some(ImmediateLocation::RecordExpr(_)) 331 | ImmediateLocation::RecordPat(_)
332 | ImmediateLocation::RecordExpr(_)
333 )
333 ) 334 )
334 } 335 }
335 336