Skip to content
Draft
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: 11 additions & 5 deletions compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1177,13 +1177,19 @@ where
if ecx.shallow_resolve(self_ty).is_ty_var() {
// We force the certainty of impl candidates to be `Maybe`.
let certainty = certainty.and(Certainty::AMBIGUOUS);
ecx.evaluate_added_goals_and_make_canonical_response(certainty)
let response =
ecx.evaluate_added_goals_and_make_canonical_response(certainty)?;

let Certainty::Maybe(maybe) = response.value.certainty else {
unreachable!();
};

// Blanket impls here only guide inference while the opaque hidden type
// is unknown. Do not let constraints from matching the impl itself
// constrain other inference variables.
Ok(ecx.make_ambiguous_response_no_constraints(maybe))
} else {
// We don't want to use impls if they constrain the opaque.
//
// FIXME(trait-system-refactor-initiative#229): This isn't
// perfect yet as it still allows us to incorrectly constrain
// other inference variables.
Err(NoSolution.into())
}
})
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
//@ revisions: current next
//@[next] compile-flags: -Znext-solver
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[current] check-pass
//@ check-pass

// Regression test for trait-system-refactor-initiative#205. Avoid
// Regression test for trait-system-refactor-initiative#205 and #229. Avoid
// constraining other impl arguments when applying blanket impls.

// FIXME(-Znext-solver): This currently incompletely constrains the
// argument of `opaque: Trait<?x>` using the blanket impl of trait.
// Ideally we don't do that.

trait Trait<T> {}

impl<T> Trait<u64> for T {}
Expand All @@ -25,7 +21,6 @@ fn foo() -> impl Sized {
return impls_trait::<_, _>(x);
}
let _: u32 = x;
//[next]~^ ERROR mismatched types
1u64
}
fn main() {}
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
//@ compile-flags: -Znext-solver
//@ ignore-compare-mode-next-solver (explicit revisions)
//@ check-pass
#![allow(unconditional_recursion)]

// Regression test for trait-system-refactor-initiative#205. Avoid
// Regression test for trait-system-refactor-initiative#205 and #229. Avoid
// constraining other impl arguments when applying blanket impls,
// especially if the nested where-bounds of the blanket impl don't
// actually apply for the opaque.

// FIXME(-Znext-solver): This currently incompletely constrains the
// argument of `opaque: Trait<?x>` using the blanket impl of trait.
// Ideally we don't do that.

trait Trait<T> {}

impl<T: Copy> Trait<u32> for T {}
Expand All @@ -19,7 +16,7 @@ fn impls_trait<T: Trait<U>, U>(_: T) {}

fn test() -> impl Sized {
let x = test();
impls_trait(x); //~ ERROR the trait bound `String: Trait<u32>` is not satisfied
impls_trait(x);
String::new()
}
fn main() {}

This file was deleted.

Loading