Skip to content

Self should be consistently usable within method bodies #24389

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
Diggsey opened this issue Apr 13, 2015 · 0 comments
Closed

Self should be consistently usable within method bodies #24389

Diggsey opened this issue Apr 13, 2015 · 0 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@Diggsey
Copy link
Contributor

Diggsey commented Apr 13, 2015

The following code will fail to compile at "Self::new()" with the message, "error: failed to resolve. Use of undeclared type or module Self"

struct Foo;

impl Foo {
    fn new() -> Self { Foo }
    fn bar() { Self::new(); }
}

While either of the following will work:

    fn bar() { <Self>::new(); }
    fn bar() { let x: Self = Foo::new(); }

The first example should compile as-is.

@steveklabnik steveklabnik added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Apr 13, 2015
bors pushed a commit that referenced this issue Sep 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

2 participants