Skip to content

Commit 9b4055b

Browse files
author
Angelos Oikonomopoulos
committed
Normalize the type Self resolves to in an impl
This is required at the very least in order to evaluate associated constants for arrays (see #58212).
1 parent ea43c3c commit 9b4055b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/librustc_typeck/astconv.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1700,7 +1700,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
17001700
// `Self` in impl (we know the concrete type).
17011701
assert_eq!(opt_self_ty, None);
17021702
self.prohibit_generics(&path.segments);
1703-
tcx.at(span).type_of(def_id)
1703+
// Try to evaluate any array length constants
1704+
self.normalize_ty(span, tcx.at(span).type_of(def_id))
17041705
}
17051706
Def::SelfTy(Some(_), None) => {
17061707
// `Self` in trait.
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
trait FromUnchecked {
2+
unsafe fn from_unchecked();
3+
}
4+
5+
impl FromUnchecked for [u8; 1] {
6+
unsafe fn from_unchecked() {
7+
let mut array: Self = std::mem::uninitialized();
8+
let _ptr = &mut array as *mut [u8] as *mut u8;
9+
}
10+
}
11+
12+
fn main() {
13+
}

0 commit comments

Comments
 (0)