1
Fork 0

Use Item::expect_* and ImplItem::expect_* more

This commit is contained in:
Maybe Waffle 2023-04-17 17:16:49 +00:00
parent e49122fb1c
commit 9534541dd4
5 changed files with 11 additions and 22 deletions

View file

@ -462,10 +462,7 @@ fn foo(&self) -> Self::T { String::new() }
if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = *proj_ty.self_ty().kind() {
let opaque_local_def_id = def_id.as_local();
let opaque_hir_ty = if let Some(opaque_local_def_id) = opaque_local_def_id {
match &tcx.hir().expect_item(opaque_local_def_id).kind {
hir::ItemKind::OpaqueTy(opaque_hir_ty) => opaque_hir_ty,
_ => bug!("The HirId comes from a `ty::Opaque`"),
}
tcx.hir().expect_item(opaque_local_def_id).expect_opaque_ty()
} else {
return false;
};

View file

@ -392,12 +392,7 @@ impl<'tcx> InferCtxt<'tcx> {
/// defining scope.
#[instrument(skip(self), level = "trace", ret)]
fn opaque_type_origin_unchecked(&self, def_id: LocalDefId) -> OpaqueTyOrigin {
match self.tcx.hir().expect_item(def_id).kind {
hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) => origin,
ref itemkind => {
bug!("weird opaque type: {:?}, {:#?}", def_id, itemkind)
}
}
self.tcx.hir().expect_item(def_id).expect_opaque_ty().origin
}
}