Skip to content

Commit a720b77

Browse files
authored
Rollup merge of rust-lang#118736 - aliemjay:revert-ice-on-ambig, r=compiler-errors
temporarily revert "ice on ambguity in mir typeck" Reverts rust-lang#116530 as a temporary measure to fix rust-lang#117577. That issue should be ultimately fixed by checking WF of type annotations prior to normalization, which is implemented in rust-lang#104098 but this PR is intended to be backported to beta. r? `@compiler-errors` (the reviewer of the reverted PR)
2 parents 68c5438 + 5fdb648 commit a720b77

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,10 @@ where
157157
}
158158

159159
let mut region_constraints = QueryRegionConstraints::default();
160-
let (output, error_info, mut obligations) =
161-
Q::fully_perform_into(self, infcx, &mut region_constraints)
162-
.map_err(|_| {
163-
infcx.tcx.sess.span_delayed_bug(span, format!("error performing {self:?}"))
164-
})
165-
.and_then(|(output, error_info, obligations, certainty)| match certainty {
166-
Certainty::Proven => Ok((output, error_info, obligations)),
167-
Certainty::Ambiguous => Err(infcx
168-
.tcx
169-
.sess
170-
.span_delayed_bug(span, format!("ambiguity performing {self:?}"))),
171-
})?;
160+
let (output, error_info, mut obligations, _) =
161+
Q::fully_perform_into(self, infcx, &mut region_constraints).map_err(|_| {
162+
infcx.tcx.sess.span_delayed_bug(span, format!("error performing {self:?}"))
163+
})?;
172164

173165
// Typically, instantiating NLL query results does not
174166
// create obligations. However, in some cases there
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// The WF requirements of the *unnormalized* form of type annotations
2+
// can guide inference.
3+
// check-pass
4+
5+
pub trait EqualTo {
6+
type Ty;
7+
}
8+
impl<X> EqualTo for X {
9+
type Ty = X;
10+
}
11+
12+
trait MyTrait<U: EqualTo<Ty = Self>> {
13+
type Out;
14+
}
15+
impl<T, U: EqualTo<Ty = T>> MyTrait<U> for T {
16+
type Out = ();
17+
}
18+
19+
fn main() {
20+
let _: <_ as MyTrait<u8>>::Out;
21+
// We shoud be able to infer a value for the inference variable above.
22+
// The WF of the unnormalized projection requires `u8: EqualTo<Ty = _>`,
23+
// which is sufficient to guide inference.
24+
}

0 commit comments

Comments
 (0)