Even less HIR.

This commit is contained in:
Camille GILLOT
2023-02-12 21:08:14 +00:00
parent 68fb752035
commit 40cb4d1bc7
4 changed files with 28 additions and 33 deletions

View File

@@ -38,26 +38,28 @@ fn do_orphan_check_impl<'tcx>(
def_id: LocalDefId,
) -> Result<(), ErrorGuaranteed> {
let trait_def_id = trait_ref.def_id;
let item = tcx.hir().expect_item(def_id);
let hir::ItemKind::Impl(impl_) = item.kind else {
bug!("{:?} is not an impl: {:?}", def_id, item);
};
let sp = tcx.def_span(def_id);
let tr = impl_.of_trait.as_ref().unwrap();
match traits::orphan_check(tcx, item.owner_id.to_def_id()) {
match traits::orphan_check(tcx, def_id.to_def_id()) {
Ok(()) => {}
Err(err) => emit_orphan_check_error(
tcx,
sp,
item.span,
tr.path.span,
trait_ref,
impl_.self_ty.span,
&impl_.generics,
err,
)?,
Err(err) => {
let item = tcx.hir().expect_item(def_id);
let hir::ItemKind::Impl(impl_) = item.kind else {
bug!("{:?} is not an impl: {:?}", def_id, item);
};
let tr = impl_.of_trait.as_ref().unwrap();
emit_orphan_check_error(
tcx,
sp,
item.span,
tr.path.span,
trait_ref,
impl_.self_ty.span,
&impl_.generics,
err,
)?
}
}
// In addition to the above rules, we restrict impls of auto traits