about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
diff options
context:
space:
mode:
authorLukas Markeffsky <@>2025-01-27 11:16:19 +0000
committerLukas Markeffsky <@>2025-01-30 18:13:16 +0100
commit0055fb92db2fcfb8c74d1bf9063f14f65d5dcce0 (patch)
treeef85e6eb90f4d25876ca6d5a64ea027f3a86dccc /compiler/rustc_trait_selection
parent10fc0b159ee6e5281bf38f65680082961dd7bec3 (diff)
downloadrust-0055fb92db2fcfb8c74d1bf9063f14f65d5dcce0.tar.gz
rust-0055fb92db2fcfb8c74d1bf9063f14f65d5dcce0.zip
check the types in `ty::Value` to value conversion
and remove `ty::Const::try_to_scalar` because it becomes redundant
Diffstat (limited to 'compiler/rustc_trait_selection')
-rw-r--r--compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs
index 9eacd377361..117b6a76425 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs
@@ -2023,14 +2023,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
             _ => None,
         };
         if let Some(tykind) = tykind
-            && let hir::TyKind::Array(_, length) = tykind
-            && let Some((scalar, ty)) = sz.found.try_to_scalar()
-            && ty == self.tcx.types.usize
+            && let hir::TyKind::Array(_, length_arg) = tykind
+            && let Some(length_val) = sz.found.try_to_target_usize(self.tcx)
         {
-            let span = length.span();
             Some(TypeErrorAdditionalDiags::ConsiderSpecifyingLength {
-                span,
-                length: scalar.to_target_usize(&self.tcx).unwrap(),
+                span: length_arg.span(),
+                length: length_val,
             })
         } else {
             None