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
24 changes: 23 additions & 1 deletion compiler/rustc_next_trait_solver/src/placeholder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ where
IndexMap<ty::PlaceholderType<I>, ty::BoundTy<I>>,
IndexMap<ty::PlaceholderConst<I>, ty::BoundConst<I>>,
) {
let old_universes = universe_indices.clone();
let mut replacer = BoundVarReplacer {
infcx,
mapped_regions: Default::default(),
Expand All @@ -57,8 +58,29 @@ where
};

let value = value.fold_with(&mut replacer);
let BoundVarReplacer {
mapped_regions,
mapped_types,
mapped_consts,
universe_indices,
infcx: _,
current_index: _,
} = replacer;

if infcx.cx().assumptions_on_binders() {
for (old, new) in old_universes.into_iter().zip(universe_indices.iter()) {
if let (None, Some(new)) = (old, new) {
// FIXME(-Zassumptions-on-binders): `replace_bound_vars` does not have enough
// context to compute placeholder assumptions for the binders it enters.
infcx.insert_placeholder_assumptions(
*new,
Some(rustc_type_ir::region_constraint::Assumptions::empty()),
);
}
}
}

(value, replacer.mapped_regions, replacer.mapped_types, replacer.mapped_consts)
(value, mapped_regions, mapped_types, mapped_consts)
}

fn universe_for(&mut self, debruijn: ty::DebruijnIndex) -> ty::UniverseIndex {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//@ compile-flags: -Znext-solver=globally -Zassumptions-on-binders

trait Trait<T> {}

trait Proj<'a> {
type Assoc;
}

fn foo<'a, T>()
where
T: Proj<'a, Assoc = fn(<T as Proj>::Assoc)>,
(): Trait<<T as Proj<'a>>::Assoc>,
//~^ ERROR the trait bound `(): Trait<fn(for<'a> fn(<T as Proj<'a>>::Assoc))>` is not satisfied
{
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error[E0277]: the trait bound `(): Trait<fn(for<'a> fn(<T as Proj<'a>>::Assoc))>` is not satisfied
--> $DIR/placeholder-assumptions-issue-157840.rs:12:9
|
LL | (): Trait<<T as Proj<'a>>::Assoc>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<fn(for<'a> fn(<T as Proj<'a>>::Assoc))>` is not implemented for `()`
|
help: consider extending the `where` clause, but there might be an alternative better way to express this requirement
|
LL | (): Trait<<T as Proj<'a>>::Assoc>, (): Trait<fn(for<'a> fn(<T as Proj<'a>>::Assoc))>
| +++++++++++++++++++++++++++++++++++++++++++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
Loading