Skip to content

Method resolution fails to find inherent method on custom Deref type #53843

Closed
@withoutboats

Description

@withoutboats

This cannot find the poll method on Pin:

use std::ops::Deref;

pub struct Pin<P>(P);

impl<P, T> Deref for Pin<P> where
    P: Deref<Target = T>,
{
    type Target = T;
    fn deref(&self) -> &T {
        &*self.0
    }
}

impl<'a, F> Pin<&'a mut F> {
    fn poll(self) {}
}

fn test(pin: Pin<&mut ()>) {
    pin.poll()
}

https://play.rust-lang.org/?gist=6e3b3f6f3aa4e8a49cb45480f4dd7e7a&version=stable&mode=debug&edition=2015

This clearly should compile.

This bug may be a blocker on changing the Pin API to a composeable form.

cc @nikomatsakis @eddyb @arielb1 @cramertj

Metadata

Metadata

Labels

C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions