Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

temporarily revert "ice on ambguity in mir typeck" #118736

Merged
merged 1 commit into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions tests/ui/wf/unnormalized-projection-guides-inference.rs
Original file line number Diff line number Diff line change
@@ -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.
}
Loading