1
Fork 0

Rollup merge of #110461 - WaffleLapkin:expect_, r=Nilstrieb

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

r? ``@Nilstrieb``
This commit is contained in:
Matthias Krüger 2023-04-18 06:44:47 +02:00 committed by GitHub
commit d97b39d3a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 24 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
}
}