about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/check_consts
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-01-09 17:43:02 +0000
committerMichael Goulet <michael@errs.io>2025-01-13 02:20:08 +0000
commit9bf9f5db9b07cf0fa74bc5f2340ef13b6c22a96a (patch)
tree94a6863f6529f9eaed217469ccdb0da11947d7e9 /compiler/rustc_const_eval/src/check_consts
parente7ad3ae331bf2716389c10e01612e201a7f98c8d (diff)
downloadrust-9bf9f5db9b07cf0fa74bc5f2340ef13b6c22a96a.tar.gz
rust-9bf9f5db9b07cf0fa74bc5f2340ef13b6c22a96a.zip
Assert that Instance::try_resolve is only used on body-like things
Diffstat (limited to 'compiler/rustc_const_eval/src/check_consts')
-rw-r--r--compiler/rustc_const_eval/src/check_consts/ops.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/rustc_const_eval/src/check_consts/ops.rs b/compiler/rustc_const_eval/src/check_consts/ops.rs
index 6707ebe7d1c..7d103055a7c 100644
--- a/compiler/rustc_const_eval/src/check_consts/ops.rs
+++ b/compiler/rustc_const_eval/src/check_consts/ops.rs
@@ -14,9 +14,11 @@ use rustc_middle::ty::{
     self, Closure, FnDef, FnPtr, GenericArgKind, GenericArgsRef, Param, TraitRef, Ty,
     suggest_constraining_type_param,
 };
-use rustc_middle::util::{CallDesugaringKind, CallKind, call_kind};
 use rustc_session::parse::add_feature_diagnostics;
 use rustc_span::{BytePos, Pos, Span, Symbol, sym};
+use rustc_trait_selection::error_reporting::traits::call_kind::{
+    CallDesugaringKind, CallKind, call_kind,
+};
 use rustc_trait_selection::traits::SelectionContext;
 use tracing::debug;
 
@@ -324,10 +326,12 @@ fn build_error_for_const_call<'tcx>(
             note_trait_if_possible(&mut err, self_ty, trait_id);
             err
         }
-        CallKind::DerefCoercion { deref_target, deref_target_ty, self_ty } => {
+        CallKind::DerefCoercion { deref_target_span, deref_target_ty, self_ty } => {
             // Check first whether the source is accessible (issue #87060)
-            let target = if tcx.sess.source_map().is_span_accessible(deref_target) {
-                Some(deref_target)
+            let target = if let Some(deref_target_span) = deref_target_span
+                && tcx.sess.source_map().is_span_accessible(deref_target_span)
+            {
+                Some(deref_target_span)
             } else {
                 None
             };