Skip to content

Default methods and Auto-dereference #8068

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bluss opened this issue Jul 27, 2013 · 3 comments
Closed

Default methods and Auto-dereference #8068

bluss opened this issue Jul 27, 2013 · 3 comments

Comments

@bluss
Copy link
Member

bluss commented Jul 27, 2013

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.

@bluss
Copy link
Member Author

bluss commented Jul 27, 2013

This should be a valid refactorization if default methods and newtypes exist in Rust together like this. (concerns more than newtypes)

@msullivan
Copy link
Contributor

Um, this seems to work perfectly well to me.

@bluss
Copy link
Member Author

bluss commented Jul 27, 2013

it does indeed work. I'm hitting some kind of autoderef issue, but this is not it.

@bluss bluss closed this as completed Jul 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants