about summary refs log tree commit diff
path: root/compiler/rustc_hir/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-09-23 04:56:10 +0000
committerbors <bors@rust-lang.org>2024-09-23 04:56:10 +0000
commit702987f75b74f789ba227ee04a3d7bb1680c2309 (patch)
treea7056e093f9d3596604c4bf561fc55475007883a /compiler/rustc_hir/src
parent66b0b29e65c77e5801c308e725a233c0728df300 (diff)
parent693269b2be59f36d1c95a6e57ee44b2002dc65e9 (diff)
downloadrust-702987f75b74f789ba227ee04a3d7bb1680c2309.tar.gz
rust-702987f75b74f789ba227ee04a3d7bb1680c2309.zip
Auto merge of #130732 - matthiaskrgr:rollup-ke1j314, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #129550 (Add str.as_str() for easy Deref to string slices)
 - #130344 (Handle unsized consts with type `str`  in v0 symbol mangling)
 - #130659 (Support `char::encode_utf16` in const scenarios.)
 - #130705 (No longer mark RTN as incomplete)
 - #130712 (Don't call `ty::Const::normalize` in error reporting)
 - #130713 (Mark `u8::make_ascii_uppercase` and `u8::make_ascii_lowercase` as const.)
 - #130714 (Introduce `structurally_normalize_const`, use it in `rustc_hir_typeck`)
 - #130715 (Replace calls to `ty::Const::{try_}eval` in mir build/pattern analysis)
 - #130723 (Add test for `available_parallelism()`)
 - #130726 (tests: Remove spuriously failing vec-tryinto-array codegen test)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_hir/src')
-rw-r--r--compiler/rustc_hir/src/hir.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs
index 17273f1f8fc..71216023ecc 100644
--- a/compiler/rustc_hir/src/hir.rs
+++ b/compiler/rustc_hir/src/hir.rs
@@ -1668,10 +1668,17 @@ pub enum ArrayLen<'hir> {
 }
 
 impl ArrayLen<'_> {
-    pub fn hir_id(&self) -> HirId {
+    pub fn span(self) -> Span {
+        match self {
+            ArrayLen::Infer(arg) => arg.span,
+            ArrayLen::Body(body) => body.span(),
+        }
+    }
+
+    pub fn hir_id(self) -> HirId {
         match self {
-            ArrayLen::Infer(InferArg { hir_id, .. }) | ArrayLen::Body(ConstArg { hir_id, .. }) => {
-                *hir_id
+            ArrayLen::Infer(InferArg { hir_id, .. }) | ArrayLen::Body(&ConstArg { hir_id, .. }) => {
+                hir_id
             }
         }
     }