Skip to content

Commit

Permalink
Unrolled build for rust-lang#133323
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#133323 - compiler-errors:bail-if-self-var, r=lcnr

Bail in effects in old solver if self ty is ty var

Otherwise when we try to check something like `?t: ~const Trait` we'll immediately stick it to the first param-env candidate, lol.

r? lcnr
  • Loading branch information
rust-timer authored Nov 22, 2024
2 parents a7d9ebd + 8dfed4e commit 5696804
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions compiler/rustc_trait_selection/src/traits/effects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ pub fn evaluate_host_effect_obligation<'tcx>(
);
}

// Force ambiguity for infer self ty.
if obligation.predicate.self_ty().is_ty_var() {
return Err(EvaluationFailure::Ambiguous);
}

match evaluate_host_effect_from_bounds(selcx, obligation) {
Ok(result) => return Ok(result),
Err(EvaluationFailure::Ambiguous) => return Err(EvaluationFailure::Ambiguous),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//@ check-pass

#![feature(const_trait_impl)]

#[const_trait]
trait Foo {}

impl<T> const Foo for (T,) where T: ~const Foo {}

const fn needs_const_foo(_: impl ~const Foo + Copy) {}

const fn test<T: ~const Foo + Copy>(t: T) {
needs_const_foo((t,));
}

fn main() {}

0 comments on commit 5696804

Please sign in to comment.