Move query out of path.

This commit is contained in:
Camille GILLOT 2023-02-14 18:12:49 +00:00
parent 40cb4d1bc7
commit 065f0b222d
2 changed files with 9 additions and 4 deletions

View File

@ -38,7 +38,6 @@ fn do_orphan_check_impl<'tcx>(
def_id: LocalDefId,
) -> Result<(), ErrorGuaranteed> {
let trait_def_id = trait_ref.def_id;
let sp = tcx.def_span(def_id);
match traits::orphan_check(tcx, def_id.to_def_id()) {
Ok(()) => {}
@ -48,6 +47,7 @@ fn do_orphan_check_impl<'tcx>(
bug!("{:?} is not an impl: {:?}", def_id, item);
};
let tr = impl_.of_trait.as_ref().unwrap();
let sp = tcx.def_span(def_id);
emit_orphan_check_error(
tcx,
@ -237,7 +237,10 @@ fn do_orphan_check_impl<'tcx>(
| ty::GeneratorWitnessMIR(..)
| ty::Bound(..)
| ty::Placeholder(..)
| ty::Infer(..) => span_bug!(sp, "weird self type for autotrait impl"),
| ty::Infer(..) => {
let sp = tcx.def_span(def_id);
span_bug!(sp, "weird self type for autotrait impl")
}
ty::Error(..) => (LocalImpl::Allow, NonlocalImpl::Allow),
};
@ -256,6 +259,7 @@ fn do_orphan_check_impl<'tcx>(
is one of the trait object's trait bounds",
trait = tcx.def_path_str(trait_def_id),
);
let sp = tcx.def_span(def_id);
let reported =
struct_span_err!(tcx.sess, sp, E0321, "{}", msg).note(label).emit();
return Err(reported);
@ -284,6 +288,7 @@ fn do_orphan_check_impl<'tcx>(
non-struct/enum type",
)),
} {
let sp = tcx.def_span(def_id);
let reported =
struct_span_err!(tcx.sess, sp, E0321, "{}", msg).span_label(sp, label).emit();
return Err(reported);

View File

@ -1191,8 +1191,8 @@ impl<'v> RootCollector<'_, 'v> {
fn process_item(&mut self, id: hir::ItemId) {
match self.tcx.def_kind(id.owner_id) {
DefKind::Enum | DefKind::Struct | DefKind::Union => {
if self.tcx.generics_of(id.owner_id).count() == 0
&& self.mode == MonoItemCollectionMode::Eager
if self.mode == MonoItemCollectionMode::Eager
&& self.tcx.generics_of(id.owner_id).count() == 0
{
debug!("RootCollector: ADT drop-glue for `{id:?}`",);