about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2023-02-14 18:12:49 +0000
committerCamille GILLOT <gillot.camille@gmail.com>2023-02-14 20:27:38 +0000
commit065f0b222d4e23ae3d4215061c5df7d248855717 (patch)
tree47f3874cdafbd730228cda0c2d82b3944344b77e
parent40cb4d1bc78f9479b6c29ade5d2ecf89dc4eba35 (diff)
downloadrust-065f0b222d4e23ae3d4215061c5df7d248855717.tar.gz
rust-065f0b222d4e23ae3d4215061c5df7d248855717.zip
Move query out of path.
-rw-r--r--compiler/rustc_hir_analysis/src/coherence/orphan.rs9
-rw-r--r--compiler/rustc_monomorphize/src/collector.rs4
2 files changed, 9 insertions, 4 deletions
diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs
index 49a9a2ea293..f0a0e7e3e92 100644
--- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs
+++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs
@@ -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);
diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs
index dd7ee220d73..bbe4e67977c 100644
--- a/compiler/rustc_monomorphize/src/collector.rs
+++ b/compiler/rustc_monomorphize/src/collector.rs
@@ -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:?}`",);