Rollup merge of #102378 - compiler-errors:issue-102289, r=jackh726
Use already resolved `self_ty` in `confirm_fn_pointer_candidate` Fixes #102289
This commit is contained in:
commit
ae2028817a
2 changed files with 56 additions and 1 deletions
|
@ -626,7 +626,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
// the signature, as evidenced by how we treat it during projection.
|
// the signature, as evidenced by how we treat it during projection.
|
||||||
// The safe thing to do here is to liberate it, though, which should
|
// The safe thing to do here is to liberate it, though, which should
|
||||||
// have no worse effect than skipping the binder here.
|
// have no worse effect than skipping the binder here.
|
||||||
let liberated_fn_ty = self.infcx.replace_bound_vars_with_placeholders(obligation.self_ty());
|
let liberated_fn_ty =
|
||||||
|
self.infcx.replace_bound_vars_with_placeholders(obligation.predicate.rebind(self_ty));
|
||||||
let output_ty = self
|
let output_ty = self
|
||||||
.infcx
|
.infcx
|
||||||
.replace_bound_vars_with_placeholders(liberated_fn_ty.fn_sig(self.tcx()).output());
|
.replace_bound_vars_with_placeholders(liberated_fn_ty.fn_sig(self.tcx()).output());
|
||||||
|
|
54
src/test/ui/function-pointer/issue-102289.rs
Normal file
54
src/test/ui/function-pointer/issue-102289.rs
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
// check-pass
|
||||||
|
|
||||||
|
pub(crate) trait Parser: Sized {
|
||||||
|
type Output;
|
||||||
|
fn parse(&mut self, _input: &str) -> Result<(), ()> {
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
|
fn map<F, B>(self, _f: F) -> Map<Self, F>
|
||||||
|
where
|
||||||
|
F: FnMut(Self::Output) -> B,
|
||||||
|
{
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) struct Chainl1<P, Op>(P, Op);
|
||||||
|
impl<P, Op> Parser for Chainl1<P, Op>
|
||||||
|
where
|
||||||
|
P: Parser,
|
||||||
|
Op: Parser,
|
||||||
|
Op::Output: FnOnce(P::Output, P::Output) -> P::Output,
|
||||||
|
{
|
||||||
|
type Output = P::Output;
|
||||||
|
}
|
||||||
|
pub(crate) fn chainl1<P, Op>(_parser: P, _op: Op) -> Chainl1<P, Op>
|
||||||
|
where
|
||||||
|
P: Parser,
|
||||||
|
Op: Parser,
|
||||||
|
Op::Output: FnOnce(P::Output, P::Output) -> P::Output,
|
||||||
|
{
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) struct Map<P, F>(P, F);
|
||||||
|
impl<A, B, P, F> Parser for Map<P, F>
|
||||||
|
where
|
||||||
|
P: Parser<Output = A>,
|
||||||
|
F: FnMut(A) -> B,
|
||||||
|
{
|
||||||
|
type Output = B;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Parser for u32 {
|
||||||
|
type Output = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn chainl1_error_consume() {
|
||||||
|
fn first<T, U>(t: T, _: U) -> T {
|
||||||
|
t
|
||||||
|
}
|
||||||
|
let _ = chainl1(1, 1.map(|_| first)).parse("");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
Loading…
Add table
Add a link
Reference in a new issue