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

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

Merged
merged 1 commit into from
Nov 22, 2024
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
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() {}
Loading