Skip to content

Commit 5c65e9f

Browse files
committed
Avoid PatOrWild glob import
1 parent 1a3edc1 commit 5c65e9f

File tree

1 file changed

+18
-18
lines changed
  • compiler/rustc_pattern_analysis/src

1 file changed

+18
-18
lines changed

compiler/rustc_pattern_analysis/src/pat.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use crate::usefulness::PlaceCtxt;
1010
use crate::{Captures, TypeCx};
1111

1212
use self::Constructor::*;
13-
use self::PatOrWild::*;
1413

1514
/// Values and patterns can be represented as a constructor applied to some fields. This represents
1615
/// a pattern in this form.
@@ -75,7 +74,7 @@ impl<'p, Cx: TypeCx> DeconstructedPat<'p, Cx> {
7574
other_ctor: &Constructor<Cx>,
7675
ctor_arity: usize,
7776
) -> SmallVec<[PatOrWild<'p, Cx>; 2]> {
78-
let wildcard_sub_tys = || (0..ctor_arity).map(|_| Wild).collect();
77+
let wildcard_sub_tys = || (0..ctor_arity).map(|_| PatOrWild::Wild).collect();
7978
match (&self.ctor, other_ctor) {
8079
// Return a wildcard for each field of `other_ctor`.
8180
(Wildcard, _) => wildcard_sub_tys(),
@@ -91,14 +90,15 @@ impl<'p, Cx: TypeCx> DeconstructedPat<'p, Cx> {
9190
// Fill in the fields from both ends.
9291
let new_arity = fields.len();
9392
for i in 0..prefix {
94-
fields[i] = Pat(&self.fields[i]);
93+
fields[i] = PatOrWild::Pat(&self.fields[i]);
9594
}
9695
for i in 0..suffix {
97-
fields[new_arity - 1 - i] = Pat(&self.fields[self.fields.len() - 1 - i]);
96+
fields[new_arity - 1 - i] =
97+
PatOrWild::Pat(&self.fields[self.fields.len() - 1 - i]);
9898
}
9999
fields
100100
}
101-
_ => self.fields.iter().map(Pat).collect(),
101+
_ => self.fields.iter().map(PatOrWild::Pat).collect(),
102102
}
103103
}
104104

@@ -162,29 +162,29 @@ pub(crate) enum PatOrWild<'p, Cx: TypeCx> {
162162
impl<'p, Cx: TypeCx> PatOrWild<'p, Cx> {
163163
pub(crate) fn as_pat(&self) -> Option<&'p DeconstructedPat<'p, Cx>> {
164164
match self {
165-
Wild => None,
166-
Pat(pat) => Some(pat),
165+
PatOrWild::Wild => None,
166+
PatOrWild::Pat(pat) => Some(pat),
167167
}
168168
}
169169
pub(crate) fn ctor(self) -> &'p Constructor<Cx> {
170170
match self {
171-
Wild => &Wildcard,
172-
Pat(pat) => pat.ctor(),
171+
PatOrWild::Wild => &Wildcard,
172+
PatOrWild::Pat(pat) => pat.ctor(),
173173
}
174174
}
175175

176176
pub(crate) fn is_or_pat(&self) -> bool {
177177
match self {
178-
Wild => false,
179-
Pat(pat) => pat.is_or_pat(),
178+
PatOrWild::Wild => false,
179+
PatOrWild::Pat(pat) => pat.is_or_pat(),
180180
}
181181
}
182182

183183
/// Expand this (possibly-nested) or-pattern into its alternatives.
184184
pub(crate) fn flatten_or_pat(self) -> SmallVec<[Self; 1]> {
185185
match self {
186-
Pat(pat) if pat.is_or_pat() => {
187-
pat.iter_fields().flat_map(|p| Pat(p).flatten_or_pat()).collect()
186+
PatOrWild::Pat(pat) if pat.is_or_pat() => {
187+
pat.iter_fields().flat_map(|p| PatOrWild::Pat(p).flatten_or_pat()).collect()
188188
}
189189
_ => smallvec![self],
190190
}
@@ -198,13 +198,13 @@ impl<'p, Cx: TypeCx> PatOrWild<'p, Cx> {
198198
ctor_arity: usize,
199199
) -> SmallVec<[PatOrWild<'p, Cx>; 2]> {
200200
match self {
201-
Wild => (0..ctor_arity).map(|_| Wild).collect(),
202-
Pat(pat) => pat.specialize(other_ctor, ctor_arity),
201+
PatOrWild::Wild => (0..ctor_arity).map(|_| PatOrWild::Wild).collect(),
202+
PatOrWild::Pat(pat) => pat.specialize(other_ctor, ctor_arity),
203203
}
204204
}
205205

206206
pub(crate) fn set_useful(&self) {
207-
if let Pat(pat) = self {
207+
if let PatOrWild::Pat(pat) = self {
208208
pat.set_useful()
209209
}
210210
}
@@ -213,8 +213,8 @@ impl<'p, Cx: TypeCx> PatOrWild<'p, Cx> {
213213
impl<'p, Cx: TypeCx> fmt::Debug for PatOrWild<'p, Cx> {
214214
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
215215
match self {
216-
Wild => write!(f, "_"),
217-
Pat(pat) => pat.fmt(f),
216+
PatOrWild::Wild => write!(f, "_"),
217+
PatOrWild::Pat(pat) => pat.fmt(f),
218218
}
219219
}
220220
}

0 commit comments

Comments
 (0)