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

Non-sense help when type parameter from outer function is used #51303

Closed
nagisa opened this issue Jun 2, 2018 · 0 comments
Closed

Non-sense help when type parameter from outer function is used #51303

nagisa opened this issue Jun 2, 2018 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@nagisa
Copy link
Member

nagisa commented Jun 2, 2018

Code

struct A;

impl A {
    fn banana(&mut self) {
        fn peach(this: &Self) {
            
        }
    }
}

Error

error[E0401]: can't use type parameters from outer function
 --> src/main.rs:9:25
  |
7 | impl A {
  | ---- `Self` type implicitely declared here, on the `impl`
8 |     fn banana(&mut self) {
9 |         fn peach(this: &Self) {
  |            -----        ^^^^ use of type variable from outer function
  |            |
  |            help: try using a local type parameter instead: `peach<Self>`

It seems that the help message is trying to suggest to introduce a local type parameter, but is worded rather poorly, as if suggesting to use a peach<Self> (e.g. this: &peach<Self>?).

Perhaps rewording the help message to explicitly say "introduce" rather than "use" would be better, but even then Self is a keyword, and cannot be introduced as a local generic parameter anyway.

@nagisa nagisa added the A-diagnostics Area: Messages for errors, warnings, and lints label Jun 2, 2018
kennytm added a commit to kennytm/rust that referenced this issue Sep 7, 2018
Fix incorrect outer function type parameter message

Fix rust-lang#51303.
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Sep 8, 2018
Fix incorrect outer function type parameter message

Fix rust-lang#51303.
bors added a commit that referenced this issue Sep 9, 2018
Fix incorrect outer function type parameter message

Fix #51303.
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
Projects
None yet
Development

No branches or pull requests

1 participant