From 95c8c65139c10e4de44367fead8dff88511e6d46 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 17 Jun 2021 17:37:14 +0200 Subject: Nest all the or-patterns! --- crates/hir_def/src/item_tree/pretty.rs | 4 ++-- crates/hir_def/src/nameres/collector.rs | 2 +- crates/hir_def/src/resolver.rs | 3 +-- crates/hir_def/src/visibility.rs | 5 ++--- 4 files changed, 6 insertions(+), 8 deletions(-) (limited to 'crates/hir_def/src') diff --git a/crates/hir_def/src/item_tree/pretty.rs b/crates/hir_def/src/item_tree/pretty.rs index b1e1b70d0..e63bc8232 100644 --- a/crates/hir_def/src/item_tree/pretty.rs +++ b/crates/hir_def/src/item_tree/pretty.rs @@ -63,7 +63,7 @@ impl<'a> Printer<'a> { fn blank(&mut self) { let mut iter = self.buf.chars().rev().fuse(); match (iter.next(), iter.next()) { - (Some('\n'), Some('\n')) | (Some('\n'), None) | (None, None) => {} + (Some('\n'), Some('\n') | None) | (None, None) => {} (Some('\n'), Some(_)) => { self.buf.push('\n'); } @@ -77,7 +77,7 @@ impl<'a> Printer<'a> { fn whitespace(&mut self) { match self.buf.chars().next_back() { - None | Some('\n') | Some(' ') => {} + None | Some('\n' | ' ') => {} _ => self.buf.push(' '), } } diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index fc2c50fb8..927a7b6e8 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs @@ -1260,7 +1260,7 @@ impl DefCollector<'_> { for directive in &self.unresolved_imports { if let ImportSource::Import { id: import, use_tree } = &directive.import.source { match (directive.import.path.segments().first(), &directive.import.path.kind) { - (Some(krate), PathKind::Plain) | (Some(krate), PathKind::Abs) => { + (Some(krate), PathKind::Plain | PathKind::Abs) => { if diagnosed_extern_crates.contains(krate) { continue; } diff --git a/crates/hir_def/src/resolver.rs b/crates/hir_def/src/resolver.rs index d4681fa3e..47e56259f 100644 --- a/crates/hir_def/src/resolver.rs +++ b/crates/hir_def/src/resolver.rs @@ -605,8 +605,7 @@ fn to_value_ns(per_ns: PerNs) -> Option { ModuleDefId::ConstId(it) => ValueNs::ConstId(it), ModuleDefId::StaticId(it) => ValueNs::StaticId(it), - ModuleDefId::AdtId(AdtId::EnumId(_)) - | ModuleDefId::AdtId(AdtId::UnionId(_)) + ModuleDefId::AdtId(AdtId::EnumId(_) | AdtId::UnionId(_)) | ModuleDefId::TraitId(_) | ModuleDefId::TypeAliasId(_) | ModuleDefId::BuiltinType(_) diff --git a/crates/hir_def/src/visibility.rs b/crates/hir_def/src/visibility.rs index 83500f54e..aeb1e7726 100644 --- a/crates/hir_def/src/visibility.rs +++ b/crates/hir_def/src/visibility.rs @@ -172,9 +172,8 @@ impl Visibility { /// visible in unrelated modules). pub(crate) fn max(self, other: Visibility, def_map: &DefMap) -> Option { match (self, other) { - (Visibility::Module(_), Visibility::Public) - | (Visibility::Public, Visibility::Module(_)) - | (Visibility::Public, Visibility::Public) => Some(Visibility::Public), + (Visibility::Module(_) | Visibility::Public, Visibility::Public) + | (Visibility::Public, Visibility::Module(_)) => Some(Visibility::Public), (Visibility::Module(mod_a), Visibility::Module(mod_b)) => { if mod_a.krate != mod_b.krate { return None; -- cgit v1.2.3