Skip to content

Default methods and Auto-dereference  #8068

Closed
@bluss

Description

@bluss

Default methods interact surprisingly with Auto-dereference

The first version (method provided by trait impl) auto-dereferences and works.

trait A { fn a(&self); }
impl A for int { fn a(&self) {} };
let s = &1i; s.a()

Moving the method implementation to a default method, does not resolve any more:

trait A { fn a(&self) { } }
impl A for int { } ;
let s = &1i; s.a()
<anon>:22:0: 22:6 error: type `&<VI0>` does not implement any method in scope named `a`

cc @msullivan

Relevant to issue #6246

First discovered this issue with Newtypes. But it also applies to simple &T auto-deref! Edited to simplify the testcase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions