Skip to content
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
2 changes: 2 additions & 0 deletions compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ where
/// Consider a clause specifically for a `dyn Trait` self type. This requires
/// additionally checking all of the supertraits and object bounds to hold,
/// since they're not implied by the well-formedness of the object type.
/// `NormalizesTo` overrides this to not check the supertraits for backwards
/// compatibility with the old solver. cc trait-system-refactor-initiative#245.
fn probe_and_consider_object_bound_candidate(
ecx: &mut EvalCtxt<'_, D>,
source: CandidateSource<I>,
Expand Down
14 changes: 14 additions & 0 deletions compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,20 @@ where
then(ecx)
}

// Hack for trait-system-refactor-initiative#245.
// FIXME(-Zhigher-ranked-assumptions): this impl differs from trait goals and we should unify
// them again once we properly support binders.
fn probe_and_consider_object_bound_candidate(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a comment here as well that this differs from trait goals with a FIXME(-Zhigher-ranked-assumptions) that we should try to unify these again once we properly support binders, linking to the issue fixed by this change

ecx: &mut EvalCtxt<'_, D>,
source: CandidateSource<I>,
goal: Goal<I, Self>,
assumption: I::Clause,
) -> Result<Candidate<I>, NoSolution> {
Self::probe_and_match_goal_against_assumption(ecx, source, goal, assumption, |ecx| {
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
})
}

fn consider_additional_alias_assumptions(
_ecx: &mut EvalCtxt<'_, D>,
_goal: Goal<I, Self>,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//@ check-pass
//@ compile-flags: -Znext-solver
//@ edition: 2024

// A regression test for trait-system-refactor-initiative#245.
// The old solver doesn't check the supertraits of the principal trait
// when considering object candidate for normalization.
Comment on lines +6 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and the new solver previously did, resulting in a placeholder error while normalizing inside of a generator witness

// And the new solver previously did, resulting in a placeholder error
// while normalizing inside of a generator witness.

trait AsyncFn: Send + 'static {
type Fut: Future<Output = ()> + Send;

fn call(&self) -> Self::Fut;
}

type BoxFuture<'a, T> = std::pin::Pin<Box<dyn Future<Output = T> + Send + 'a>>;
type DynAsyncFnBoxed = dyn AsyncFn<Fut = BoxFuture<'static, ()>>;

fn wrap_call<P: AsyncFn + ?Sized>(func: Box<P>) -> impl Future<Output = ()> {
func.call()
}

fn get_boxed_fn() -> Box<DynAsyncFnBoxed> {
todo!()
}

async fn cursed_fut() {
wrap_call(get_boxed_fn()).await;
}

fn observe_fut_not_send() {
fn assert_send<T: Send>(t: T) -> T {
t
}
assert_send(cursed_fut());
}

fn main() {}
Loading