Skip to content

Commit 3da6836

Browse files
committed
Auto merge of #65099 - pnkfelix:issue-63154-needed-more-normalize, r=nagisa
MIR typeck needed more normalize Add some missing normalization calls (@nagisa [was right](#63154 (comment))). Fix #63154
2 parents 80b861b + 00bf29b commit 3da6836

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/librustc_mir/borrow_check/nll/type_check/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1396,7 +1396,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
13961396
};
13971397

13981398
let place_ty = place.ty(body, tcx).ty;
1399+
let place_ty = self.normalize(place_ty, location);
13991400
let rv_ty = rv.ty(body, tcx);
1401+
let rv_ty = self.normalize(rv_ty, location);
14001402
if let Err(terr) =
14011403
self.sub_types_or_anon(rv_ty, place_ty, location.to_locations(), category)
14021404
{
@@ -1672,6 +1674,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
16721674
match *destination {
16731675
Some((ref dest, _target_block)) => {
16741676
let dest_ty = dest.ty(body, tcx).ty;
1677+
let dest_ty = self.normalize(dest_ty, term_location);
16751678
let category = match *dest {
16761679
Place {
16771680
base: PlaceBase::Local(RETURN_PLACE),
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Regression test for rust-lang/rust#63154
2+
//
3+
// Before, we would ICE after failing to normalize the destination type
4+
// when checking call destinations and also when checking MIR
5+
// assignment statements.
6+
7+
// check-pass
8+
9+
trait HasAssocType {
10+
type Inner;
11+
}
12+
13+
impl HasAssocType for () {
14+
type Inner = ();
15+
}
16+
17+
trait Tr<I, T>: Fn(I) -> Option<T> {}
18+
impl<I, T, Q: Fn(I) -> Option<T>> Tr<I, T> for Q {}
19+
20+
fn f<T: HasAssocType>() -> impl Tr<T, T::Inner> {
21+
|_| None
22+
}
23+
24+
fn g<T, Y>(f: impl Tr<T, Y>) -> impl Tr<T, Y> {
25+
f
26+
}
27+
28+
fn h() {
29+
g(f())(());
30+
}
31+
32+
fn main() {
33+
h();
34+
}

0 commit comments

Comments
 (0)