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

On places that pub would be "reasonable" but incorrect, provide better errors #56473

Closed
estebank opened this issue Dec 3, 2018 · 0 comments
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@estebank
Copy link
Contributor

estebank commented Dec 3, 2018

When trying to incorrectly specify a pub fn in a trait, the error message just complains about the incorrect token:

trait T {
    pub fn foo(&self);
}

Ideally the compiler would explain that individual trait methods' visibility can't be modified, only the trait itself, and continue parsing the AST as if it were correct, possibly suggesting the following, if appropriate:

pub trait T {
    fn foo(&self);
}
@estebank estebank added the A-diagnostics Area: Messages for errors, warnings, and lints label Dec 3, 2018
bors added a commit that referenced this issue Mar 22, 2019
Recover from missing comma between enum variants and from bad `pub` kw

Fix #56579. Fix #56473.
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