Inline do_orphan_check_impl
This commit is contained in:
parent
086463b227
commit
4803f173be
@ -18,25 +18,17 @@ pub(crate) fn orphan_check_impl(
|
|||||||
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap().instantiate_identity();
|
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap().instantiate_identity();
|
||||||
trait_ref.error_reported()?;
|
trait_ref.error_reported()?;
|
||||||
|
|
||||||
do_orphan_check_impl(tcx, trait_ref, impl_def_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn do_orphan_check_impl<'tcx>(
|
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
trait_ref: ty::TraitRef<'tcx>,
|
|
||||||
def_id: LocalDefId,
|
|
||||||
) -> Result<(), ErrorGuaranteed> {
|
|
||||||
let trait_def_id = trait_ref.def_id;
|
let trait_def_id = trait_ref.def_id;
|
||||||
|
|
||||||
match traits::orphan_check(tcx, def_id.to_def_id()) {
|
match traits::orphan_check(tcx, impl_def_id.to_def_id()) {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
let item = tcx.hir().expect_item(def_id);
|
let item = tcx.hir().expect_item(impl_def_id);
|
||||||
let hir::ItemKind::Impl(impl_) = item.kind else {
|
let hir::ItemKind::Impl(impl_) = item.kind else {
|
||||||
bug!("{:?} is not an impl: {:?}", def_id, item);
|
bug!("{:?} is not an impl: {:?}", impl_def_id, item);
|
||||||
};
|
};
|
||||||
let tr = impl_.of_trait.as_ref().unwrap();
|
let tr = impl_.of_trait.as_ref().unwrap();
|
||||||
let sp = tcx.def_span(def_id);
|
let sp = tcx.def_span(impl_def_id);
|
||||||
|
|
||||||
emit_orphan_check_error(
|
emit_orphan_check_error(
|
||||||
tcx,
|
tcx,
|
||||||
@ -180,7 +172,7 @@ enum NonlocalImpl {
|
|||||||
// impl<T> AutoTrait for T {}
|
// impl<T> AutoTrait for T {}
|
||||||
// impl<T: ?Sized> AutoTrait for T {}
|
// impl<T: ?Sized> AutoTrait for T {}
|
||||||
ty::Param(..) => (
|
ty::Param(..) => (
|
||||||
if self_ty.is_sized(tcx, tcx.param_env(def_id)) {
|
if self_ty.is_sized(tcx, tcx.param_env(impl_def_id)) {
|
||||||
LocalImpl::Allow
|
LocalImpl::Allow
|
||||||
} else {
|
} else {
|
||||||
LocalImpl::Disallow { problematic_kind: "generic type" }
|
LocalImpl::Disallow { problematic_kind: "generic type" }
|
||||||
@ -237,7 +229,7 @@ enum NonlocalImpl {
|
|||||||
| ty::Bound(..)
|
| ty::Bound(..)
|
||||||
| ty::Placeholder(..)
|
| ty::Placeholder(..)
|
||||||
| ty::Infer(..) => {
|
| ty::Infer(..) => {
|
||||||
let sp = tcx.def_span(def_id);
|
let sp = tcx.def_span(impl_def_id);
|
||||||
span_bug!(sp, "weird self type for autotrait impl")
|
span_bug!(sp, "weird self type for autotrait impl")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +241,7 @@ enum NonlocalImpl {
|
|||||||
LocalImpl::Allow => {}
|
LocalImpl::Allow => {}
|
||||||
LocalImpl::Disallow { problematic_kind } => {
|
LocalImpl::Disallow { problematic_kind } => {
|
||||||
return Err(tcx.dcx().emit_err(errors::TraitsWithDefaultImpl {
|
return Err(tcx.dcx().emit_err(errors::TraitsWithDefaultImpl {
|
||||||
span: tcx.def_span(def_id),
|
span: tcx.def_span(impl_def_id),
|
||||||
traits: tcx.def_path_str(trait_def_id),
|
traits: tcx.def_path_str(trait_def_id),
|
||||||
problematic_kind,
|
problematic_kind,
|
||||||
self_ty,
|
self_ty,
|
||||||
@ -261,13 +253,13 @@ enum NonlocalImpl {
|
|||||||
NonlocalImpl::Allow => {}
|
NonlocalImpl::Allow => {}
|
||||||
NonlocalImpl::DisallowBecauseNonlocal => {
|
NonlocalImpl::DisallowBecauseNonlocal => {
|
||||||
return Err(tcx.dcx().emit_err(errors::CrossCrateTraitsDefined {
|
return Err(tcx.dcx().emit_err(errors::CrossCrateTraitsDefined {
|
||||||
span: tcx.def_span(def_id),
|
span: tcx.def_span(impl_def_id),
|
||||||
traits: tcx.def_path_str(trait_def_id),
|
traits: tcx.def_path_str(trait_def_id),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
NonlocalImpl::DisallowOther => {
|
NonlocalImpl::DisallowOther => {
|
||||||
return Err(tcx.dcx().emit_err(errors::CrossCrateTraits {
|
return Err(tcx.dcx().emit_err(errors::CrossCrateTraits {
|
||||||
span: tcx.def_span(def_id),
|
span: tcx.def_span(impl_def_id),
|
||||||
traits: tcx.def_path_str(trait_def_id),
|
traits: tcx.def_path_str(trait_def_id),
|
||||||
self_ty,
|
self_ty,
|
||||||
}));
|
}));
|
||||||
|
Loading…
Reference in New Issue
Block a user