diff options
| author | Ali MJ Al-Nasrawy <alimjalnasrawy@gmail.com> | 2023-12-08 07:27:47 +0000 |
|---|---|---|
| committer | Ali MJ Al-Nasrawy <alimjalnasrawy@gmail.com> | 2023-12-08 07:49:06 +0000 |
| commit | 5fdb648fc3a672140f3fc8f98ee3268ed3fe5389 (patch) | |
| tree | eee74a75291b153ffdf3025691d9539979179e4a | |
| parent | 6c470a557ab97ee9e73ff5ab3d0872fbccad6645 (diff) | |
| download | rust-5fdb648fc3a672140f3fc8f98ee3268ed3fe5389.tar.gz rust-5fdb648fc3a672140f3fc8f98ee3268ed3fe5389.zip | |
temporarily revert "ice on ambguity in mir typeck"
Reverts #116530
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs | 16 | ||||
| -rw-r--r-- | tests/ui/wf/unnormalized-projection-guides-inference.rs | 24 |
2 files changed, 28 insertions, 12 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs index e87e585ef0b..cd09aaff2d9 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs @@ -157,18 +157,10 @@ where } let mut region_constraints = QueryRegionConstraints::default(); - let (output, error_info, mut obligations) = - Q::fully_perform_into(self, infcx, &mut region_constraints) - .map_err(|_| { - infcx.tcx.sess.span_delayed_bug(span, format!("error performing {self:?}")) - }) - .and_then(|(output, error_info, obligations, certainty)| match certainty { - Certainty::Proven => Ok((output, error_info, obligations)), - Certainty::Ambiguous => Err(infcx - .tcx - .sess - .span_delayed_bug(span, format!("ambiguity performing {self:?}"))), - })?; + let (output, error_info, mut obligations, _) = + Q::fully_perform_into(self, infcx, &mut region_constraints).map_err(|_| { + infcx.tcx.sess.span_delayed_bug(span, format!("error performing {self:?}")) + })?; // Typically, instantiating NLL query results does not // create obligations. However, in some cases there diff --git a/tests/ui/wf/unnormalized-projection-guides-inference.rs b/tests/ui/wf/unnormalized-projection-guides-inference.rs new file mode 100644 index 00000000000..ca2d6c2e882 --- /dev/null +++ b/tests/ui/wf/unnormalized-projection-guides-inference.rs @@ -0,0 +1,24 @@ +// The WF requirements of the *unnormalized* form of type annotations +// can guide inference. +// check-pass + +pub trait EqualTo { + type Ty; +} +impl<X> EqualTo for X { + type Ty = X; +} + +trait MyTrait<U: EqualTo<Ty = Self>> { + type Out; +} +impl<T, U: EqualTo<Ty = T>> MyTrait<U> for T { + type Out = (); +} + +fn main() { + let _: <_ as MyTrait<u8>>::Out; + // We shoud be able to infer a value for the inference variable above. + // The WF of the unnormalized projection requires `u8: EqualTo<Ty = _>`, + // which is sufficient to guide inference. +} |
