Skip to content

Commit 71bb655

Browse files
committed
Update to latest rustc_pattern_analysis
1 parent c06ca6c commit 71bb655

File tree

4 files changed

+25
-29
lines changed

4 files changed

+25
-29
lines changed

Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ ra-ap-rustc_lexer = { version = "0.35.0", default-features = false }
8484
ra-ap-rustc_parse_format = { version = "0.35.0", default-features = false }
8585
ra-ap-rustc_index = { version = "0.35.0", default-features = false }
8686
ra-ap-rustc_abi = { version = "0.35.0", default-features = false }
87-
ra-ap-rustc_pattern_analysis = { version = "0.36.0", default-features = false }
87+
ra-ap-rustc_pattern_analysis = { version = "0.37.0", default-features = false }
8888

8989
# local crates that aren't published to crates.io. These should not have versions.
9090
sourcegen = { path = "./crates/sourcegen" }

crates/hir-ty/src/diagnostics/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl ExprValidator {
223223
ValidityConstraint::ValidOnly,
224224
) {
225225
Ok(report) => report,
226-
Err(void) => match void {},
226+
Err(()) => return,
227227
};
228228

229229
// FIXME Report unreachable arms

crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use Constructor::*;
2626

2727
// Re-export r-a-specific versions of all these types.
2828
pub(crate) type DeconstructedPat<'p> =
29-
rustc_pattern_analysis::pat::DeconstructedPat<'p, MatchCheckCtx<'p>>;
29+
rustc_pattern_analysis::pat::DeconstructedPat<MatchCheckCtx<'p>>;
3030
pub(crate) type MatchArm<'p> = rustc_pattern_analysis::MatchArm<'p, MatchCheckCtx<'p>>;
3131
pub(crate) type WitnessPat<'p> = rustc_pattern_analysis::pat::WitnessPat<MatchCheckCtx<'p>>;
3232

@@ -131,15 +131,15 @@ impl<'p> MatchCheckCtx<'p> {
131131
}
132132

133133
pub(crate) fn lower_pat(&self, pat: &Pat) -> DeconstructedPat<'p> {
134-
let singleton = |pat| std::slice::from_ref(self.pattern_arena.alloc(pat));
134+
let singleton = |pat| vec![pat];
135135
let ctor;
136-
let fields: &[_];
136+
let fields: Vec<_>;
137137

138138
match pat.kind.as_ref() {
139139
PatKind::Binding { subpattern: Some(subpat), .. } => return self.lower_pat(subpat),
140140
PatKind::Binding { subpattern: None, .. } | PatKind::Wild => {
141141
ctor = Wildcard;
142-
fields = &[];
142+
fields = Vec::new();
143143
}
144144
PatKind::Deref { subpattern } => {
145145
ctor = match pat.ty.kind(Interner) {
@@ -157,7 +157,7 @@ impl<'p> MatchCheckCtx<'p> {
157157
match pat.ty.kind(Interner) {
158158
TyKind::Tuple(_, substs) => {
159159
ctor = Struct;
160-
let mut wilds: SmallVec<[_; 2]> = substs
160+
let mut wilds: Vec<_> = substs
161161
.iter(Interner)
162162
.map(|arg| arg.assert_ty_ref(Interner).clone())
163163
.map(DeconstructedPat::wildcard)
@@ -166,7 +166,7 @@ impl<'p> MatchCheckCtx<'p> {
166166
let idx: u32 = pat.field.into_raw().into();
167167
wilds[idx as usize] = self.lower_pat(&pat.pattern);
168168
}
169-
fields = self.pattern_arena.alloc_extend(wilds)
169+
fields = wilds
170170
}
171171
TyKind::Adt(adt, substs) if is_box(self.db, adt.0) => {
172172
// The only legal patterns of type `Box` (outside `std`) are `_` and box
@@ -216,33 +216,29 @@ impl<'p> MatchCheckCtx<'p> {
216216
field_id_to_id[field_idx as usize] = Some(i);
217217
ty
218218
});
219-
let mut wilds: SmallVec<[_; 2]> =
220-
tys.map(DeconstructedPat::wildcard).collect();
219+
let mut wilds: Vec<_> = tys.map(DeconstructedPat::wildcard).collect();
221220
for pat in subpatterns {
222221
let field_idx: u32 = pat.field.into_raw().into();
223222
if let Some(i) = field_id_to_id[field_idx as usize] {
224223
wilds[i] = self.lower_pat(&pat.pattern);
225224
}
226225
}
227-
fields = self.pattern_arena.alloc_extend(wilds);
226+
fields = wilds;
228227
}
229228
_ => {
230229
never!("pattern has unexpected type: pat: {:?}, ty: {:?}", pat, &pat.ty);
231230
ctor = Wildcard;
232-
fields = &[];
231+
fields = Vec::new();
233232
}
234233
}
235234
}
236235
&PatKind::LiteralBool { value } => {
237236
ctor = Bool(value);
238-
fields = &[];
237+
fields = Vec::new();
239238
}
240239
PatKind::Or { pats } => {
241240
ctor = Or;
242-
// Collect here because `Arena::alloc_extend` panics on reentrancy.
243-
let subpats: SmallVec<[_; 2]> =
244-
pats.iter().map(|pat| self.lower_pat(pat)).collect();
245-
fields = self.pattern_arena.alloc_extend(subpats);
241+
fields = pats.iter().map(|pat| self.lower_pat(pat)).collect();
246242
}
247243
}
248244
let data = PatData { db: self.db };
@@ -307,7 +303,7 @@ impl<'p> MatchCheckCtx<'p> {
307303
}
308304

309305
impl<'p> TypeCx for MatchCheckCtx<'p> {
310-
type Error = Void;
306+
type Error = ();
311307
type Ty = Ty;
312308
type VariantIdx = EnumVariantId;
313309
type StrLit = Void;
@@ -463,7 +459,7 @@ impl<'p> TypeCx for MatchCheckCtx<'p> {
463459

464460
fn write_variant_name(
465461
f: &mut fmt::Formatter<'_>,
466-
pat: &rustc_pattern_analysis::pat::DeconstructedPat<'_, Self>,
462+
pat: &rustc_pattern_analysis::pat::DeconstructedPat<Self>,
467463
) -> fmt::Result {
468464
let variant =
469465
pat.ty().as_adt().and_then(|(adt, _)| Self::variant_id_for_adt(pat.ctor(), adt));
@@ -485,8 +481,8 @@ impl<'p> TypeCx for MatchCheckCtx<'p> {
485481
Ok(())
486482
}
487483

488-
fn bug(&self, fmt: fmt::Arguments<'_>) -> ! {
489-
panic!("{}", fmt)
484+
fn bug(&self, fmt: fmt::Arguments<'_>) -> () {
485+
never!("{}", fmt)
490486
}
491487
}
492488

0 commit comments

Comments
 (0)