Skip to content
Open
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
11 changes: 11 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,17 @@ where
then(ecx)
}

fn probe_and_consider_object_bound_candidate(
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,37 @@
//@ 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.

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