Skip to content

Using Self when initializing a tuple struct #47085

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
U007D opened this issue Dec 31, 2017 · 0 comments · Fixed by #47116
Closed

Using Self when initializing a tuple struct #47085

U007D opened this issue Dec 31, 2017 · 0 comments · Fixed by #47116
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name/path resolution done by `rustc_resolve` specifically C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@U007D
Copy link

U007D commented Dec 31, 2017

https://internals.rust-lang.org/t/initialization-syntax-for-self-tuple-structs/5389/5 talks about this problem. But the solution (using the typename, rather than Self) isn't discussed anywhere (that I could find).

Could a helpful compiler message be added (until the problem is fixed)? Something to the effect of
"Use of Self when initializing a tuple struct is not currently supported. Please try <typename>(...) instead." (where code following 'Please try' is the user's code with Self replaced with the struct's typename).

@kennytm kennytm added A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The lexing & parsing of Rust source code to an AST C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Dec 31, 2017
@petrochenkov petrochenkov added A-resolve Area: Name/path resolution done by `rustc_resolve` specifically and removed A-parser Area: The lexing & parsing of Rust source code to an AST labels Dec 31, 2017
bors added a commit that referenced this issue Jan 21, 2018
Tweaks to invalid ctor messages

 - Do not suggest using a constructor that isn't accessible
 - Suggest the appropriate syntax (`()`/`{}` as appropriate)
 - Add note when trying to use `Self` as a ctor

CC #22488, fix #47085.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name/path resolution done by `rustc_resolve` specifically C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants