Skip to content

Reimplement Self in impls in the compiler #23909

New issue

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

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

Already on GitHub? # to your account

Closed
nrc opened this issue Mar 31, 2015 · 0 comments · Fixed by #23998
Closed

Reimplement Self in impls in the compiler #23909

nrc opened this issue Mar 31, 2015 · 0 comments · Fixed by #23998
Assignees
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically

Comments

@nrc
Copy link
Member

nrc commented Mar 31, 2015

Currently the Self:: shorthand in the body of an impl is implemented by syntactic expansion in libsyntax. That leads to a bug if another item shadows the concrete type. E.g.,

struct Foo;

impl Foo {
    fn foo() {}
    fn bar() {
        let Foo = ...;
        Self::foo(); // Whoops!
    }
}

The Self on the commented line will cause an error in name resolution, since Self ends up referring to the local variable Foo, not the self type.

@nrc nrc added the A-resolve Area: Name/path resolution done by `rustc_resolve` specifically label Mar 31, 2015
@nrc nrc self-assigned this Mar 31, 2015
nrc added a commit to nrc/rust that referenced this issue Apr 3, 2015
nrc added a commit to nrc/rust that referenced this issue Apr 7, 2015
bors added a commit that referenced this issue Apr 8, 2015
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant