Skip to content

Commit 8dfed4e

Browse files
Bail in effects in old solver if self ty is ty var
1 parent 5d3c6ee commit 8dfed4e

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

compiler/rustc_trait_selection/src/traits/effects.rs

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ pub fn evaluate_host_effect_obligation<'tcx>(
2727
);
2828
}
2929

30+
// Force ambiguity for infer self ty.
31+
if obligation.predicate.self_ty().is_ty_var() {
32+
return Err(EvaluationFailure::Ambiguous);
33+
}
34+
3035
match evaluate_host_effect_from_bounds(selcx, obligation) {
3136
Ok(result) => return Ok(result),
3237
Err(EvaluationFailure::Ambiguous) => return Err(EvaluationFailure::Ambiguous),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@ check-pass
2+
3+
#![feature(const_trait_impl)]
4+
5+
#[const_trait]
6+
trait Foo {}
7+
8+
impl<T> const Foo for (T,) where T: ~const Foo {}
9+
10+
const fn needs_const_foo(_: impl ~const Foo + Copy) {}
11+
12+
const fn test<T: ~const Foo + Copy>(t: T) {
13+
needs_const_foo((t,));
14+
}
15+
16+
fn main() {}

0 commit comments

Comments
 (0)