Rollup merge of #108834 - compiler-errors:fn-ptr-fn-obl, r=spastorino
Do not ICE when we have fn pointer `Fn` obligations with bound vars in the self type We never supported solving `for<'a> fn(&'a ()): Fn(&'a ())` -- I tried to add that support in #104929, but iirc `@lcnr` wanted to support this more generally by eagerly instantiating trait predicate binders with placeholders. That never happened due to blockers in the old solver, but we probably shouldn't ICE in any case. On the bright side, this passes on the new solver :^)
This commit is contained in:
commit
bee84733ad
3 changed files with 44 additions and 3 deletions
|
@ -601,10 +601,18 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
debug!(?obligation, "confirm_fn_pointer_candidate");
|
||||
|
||||
let tcx = self.tcx();
|
||||
let self_ty = self
|
||||
|
||||
let Some(self_ty) = self
|
||||
.infcx
|
||||
.shallow_resolve(obligation.self_ty().no_bound_vars())
|
||||
.expect("fn pointer should not capture bound vars from predicate");
|
||||
.shallow_resolve(obligation.self_ty().no_bound_vars()) else
|
||||
{
|
||||
// FIXME: Ideally we'd support `for<'a> fn(&'a ()): Fn(&'a ())`,
|
||||
// but we do not currently. Luckily, such a bound is not
|
||||
// particularly useful, so we don't expect users to write
|
||||
// them often.
|
||||
return Err(SelectionError::Unimplemented);
|
||||
};
|
||||
|
||||
let sig = self_ty.fn_sig(tcx);
|
||||
let trait_ref = closure_trait_ref_and_return_type(
|
||||
tcx,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue