Skip to content
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

Un-xfail test of error message for "missing 'self'" #2356

Closed
catamorphism opened this issue May 4, 2012 · 9 comments · Fixed by #14086
Closed

Un-xfail test of error message for "missing 'self'" #2356

catamorphism opened this issue May 4, 2012 · 9 comments · Fixed by #14086
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-traits Area: Trait system A-typesystem Area: The type system

Comments

@catamorphism
Copy link
Contributor

(Original title: More helpful error message for "missing 'self'")

The test for the improved error message was xfailed in SHA: 93d3b8a ; we want to un-xfail it.

Original bug report follows


Currently, if I write x inside a class that has field x, and x isn't in the outer scope, the error I get is "unresolved name". I could see that being confusing. Ideally the typechecker would suggest "did you mean self.x?" if self has a field named x.

@ghost ghost assigned catamorphism May 4, 2012
@Vincent-Belliard
Copy link
Contributor

I made a pull request (#3252) which implements this feature.

Vincent-Belliard added a commit to Vincent-Belliard/rust that referenced this issue Aug 25, 2012
catamorphism added a commit that referenced this issue Aug 25, 2012
@catamorphism
Copy link
Contributor Author

Fixed in 390a31a

catamorphism added a commit that referenced this issue Aug 25, 2012
@catamorphism catamorphism reopened this Nov 16, 2012
@catamorphism
Copy link
Contributor Author

This doesn't work anymore, since the code that handled this for old-style classes doesn't work with impls. The test is currently xfailed.

@catamorphism
Copy link
Contributor Author

Bumping to 0.7

@catamorphism
Copy link
Contributor Author

Not critical for 0.7. Nominating for milestone 5, production-ready.

@graydon
Copy link
Contributor

graydon commented Jun 6, 2013

just a bug, removing milestone/nomination.

@huonw
Copy link
Member

huonw commented Jul 23, 2013

Visiting for triage, still an issue.

@pnkfelix
Copy link
Member

visiting for triage, email from 2013 sep 23.

@flaper87
Copy link
Contributor

This can probably be fixed as part of #2392 or v.v.

bors added a commit that referenced this issue May 14, 2014
…ichton

Provides better help for the resolve failures inside an `impl` if the name matches:
- a field on the self type
- a method on the self type
- a method on the current trait ref (in a trait impl)

Not handling trait method suggestions if in a regular `impl` (as you can see on line 69 of the test), I believe it is possible though.

Also, provides a better message when `self` fails to resolve due to being a static method.

It's using some unsafe pointers to skip copying the larger structures (which are only used in error conditions); it's likely possible to get it working with lifetimes (all the useful refs should outlive the visitor calls) but I haven't really figured that out for this case. (can switch to copying code if wanted)

Closes #2356.
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 22, 2022
require level and colon in `//~` style comments

implements rust-lang/miri#2348 (comment)
celinval added a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
The toolchain upgrade job is currently running every 4h, and it is generating a lot of unnecessary notifications when the job is broken.

The nightly toolchain is updated once a day, so there's no point in running an update that often.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-traits Area: Trait system A-typesystem Area: The type system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants