1
Fork 0

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, def_id: LocalDefId,
) -> Result<(), ErrorGuaranteed> { ) -> Result<(), ErrorGuaranteed> {
let trait_def_id = trait_ref.def_id; 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()) { match traits::orphan_check(tcx, def_id.to_def_id()) {
Ok(()) => {} Ok(()) => {}
@ -48,6 +47,7 @@ fn do_orphan_check_impl<'tcx>(
bug!("{:?} is not an impl: {:?}", def_id, item); bug!("{:?} is not an 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);
emit_orphan_check_error( emit_orphan_check_error(
tcx, tcx,
@ -237,7 +237,10 @@ fn do_orphan_check_impl<'tcx>(
| ty::GeneratorWitnessMIR(..) | ty::GeneratorWitnessMIR(..)
| ty::Bound(..) | ty::Bound(..)
| ty::Placeholder(..) | 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), 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", is one of the trait object's trait bounds",
trait = tcx.def_path_str(trait_def_id), trait = tcx.def_path_str(trait_def_id),
); );
let sp = tcx.def_span(def_id);
let reported = let reported =
struct_span_err!(tcx.sess, sp, E0321, "{}", msg).note(label).emit(); struct_span_err!(tcx.sess, sp, E0321, "{}", msg).note(label).emit();
return Err(reported); return Err(reported);
@ -284,6 +288,7 @@ fn do_orphan_check_impl<'tcx>(
non-struct/enum type", non-struct/enum type",
)), )),
} { } {
let sp = tcx.def_span(def_id);
let reported = let reported =
struct_span_err!(tcx.sess, sp, E0321, "{}", msg).span_label(sp, label).emit(); struct_span_err!(tcx.sess, sp, E0321, "{}", msg).span_label(sp, label).emit();
return Err(reported); return Err(reported);

View file

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