8000 Update traversal impls for Const · rust-lang/rust-analyzer@1e93992 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1e93992

Browse files
committed
Update traversal impls for Const
1 parent 16ba92f commit 1e93992

File tree

1 file changed

+21
-29
lines changed

1 file changed

+21
-29
lines changed

crates/hir-ty/src/next_solver/consts.rs

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -206,20 +206,16 @@ impl<'db> TypeSuperVisitable<DbInterner<'db>> for Const<'db> {
206206
&self,
207207
visitor: &mut V,
208208
) -> V::Result {
209-
match (*self).kind() {
210-
ConstKind::Param(p) => p.visit_with(visitor),
211-
// FIXME(next-solver): need to add this impl upstream
212-
//ConstKind::Infer(i) => i.visit_with(visitor),
213-
ConstKind::Infer(i) => V::Result::output(),
214-
ConstKind::Bound(d, b) => {
215-
try_visit!(d.visit_with(visitor));
216-
b.visit_with(visitor)
217-
}
218-
ConstKind::Placeholder(p) => p.visit_with(visitor),
209+
match self.kind() {
219210
ConstKind::Unevaluated(uv) => uv.visit_with(visitor),
220211
ConstKind::Value(v) => v.visit_with(visitor),
221-
ConstKind::Error(e) => e.visit_with(visitor),
222212
ConstKind::Expr(e) => e.visit_with(visitor),
213+
ConstKind::Error(e) => e.visit_with(visitor),
214+
215+
ConstKind::Param(_)
216+
| ConstKind::Infer(_)
217+
| ConstKind::Bound(..)
218+
| ConstKind::Placeholder(_) => V::Result::output(),
223219
}
224220
}
225221
}
@@ -242,38 +238,34 @@ impl<'db> TypeSuperFoldable<DbInterner<'db>> for Const<'db> {
242238
folder: &mut F,
243239
) -> Result<Self, F::Error> {
244240
let kind = match self.kind() {
245-
ConstKind::Param(p) => ConstKind::Param(p.try_fold_with(folder)?),
246-
// FIXME(next-solver): need to add this impl upstream
247-
//ConstKind::Infer(i) => ConstKind::Infer(i.try_fold_with(folder)?),
248-
ConstKind::Infer(i) => ConstKind::Infer(i),
249-
ConstKind::Bound(d, b) => {
250-
ConstKind::Bound(d.try_fold_with(folder)?, b.try_fold_with(folder)?)
251-
}
252-
ConstKind::Placeholder(p) => ConstKind::Placeholder(p.try_fold_with(folder)?),
253241
ConstKind::Unevaluated(uv) => ConstKind::Unevaluated(uv.try_fold_with(folder)?),
254242
ConstKind::Value(v) => ConstKind::Value(v.try_fold_with(folder)?),
255-
ConstKind::Error(e) => ConstKind::Error(e.try_fold_with(folder)?),
256243
ConstKind::Expr(e) => ConstKind::Expr(e.try_fold_with(folder)?),
244+
245+
ConstKind::Param(_)
246+
| ConstKind::Infer(_)
247+
| ConstKind::Bound(..)
248+
| ConstKind::Placeholder(_)
249+
| ConstKind::Error(_) => return Ok(self),
257250
};
258-
if kind != self.kind() { Ok(Const::new(folder.cx(), kind)) } else { Ok(self) }
251+
if kind != self.kind() { Ok(folder.cx().mk_ct_from_kind(kind)) } else { Ok(self) }
259252
}
260253
fn super_fold_with<F: rustc_type_ir::TypeFolder<DbInterner<'db>>>(
261254
self,
262255
folder: &mut F,
263256
) -> Self {
264257
let kind = match self.kind() {
265-
ConstKind::Param(p) => ConstKind::Param(p.fold_with(folder)),
266-
// FIXME(next-solver): need to add this impl upstream
267-
//ConstKind::Infer(i) => ConstKind::Infer(i.fold_with(folder)),
268-
ConstKind::Infer(i) => ConstKind::Infer(i),
269-
ConstKind::Bound(d, b) => ConstKind::Bound(d.fold_with(folder), b.fold_with(folder)),
270-
ConstKind::Placeholder(p) => ConstKind::Placeholder(p.fold_with(folder)),
271258
ConstKind::Unevaluated(uv) => ConstKind::Unevaluated(uv.fold_with(folder)),
272259
ConstKind::Value(v) => ConstKind::Value(v.fold_with(folder)),
273-
ConstKind::Error(e) => ConstKind::Error(e.fold_with(folder)),
274260
ConstKind::Expr(e) => ConstKind::Expr(e.fold_with(folder)),
261+
262+
ConstKind::Param(_)
263+
| ConstKind::Infer(_)
264+
| ConstKind::Bound(..)
265+
| ConstKind::Placeholder(_)
266+
| ConstKind::Error(_) => return self,
275267
};
276-
if kind != self.kind() { Const::new(folder.cx(), kind) } else { self }
268+
if kind != self.kind() { folder.cx().mk_ct_from_kind(kind) } else { self }
277269
}
278270
}
279271

0 commit comments

Comments
 (0)
0