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

Misleading code example for wrong_pub_self_convention lint #6438

Open
ThibsG opened this issue Dec 10, 2020 · 1 comment
Open

Misleading code example for wrong_pub_self_convention lint #6438

ThibsG opened this issue Dec 10, 2020 · 1 comment
Labels
A-documentation Area: Adding or improving documentation A-lint Area: New lints C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages

Comments

@ThibsG
Copy link
Contributor

ThibsG commented Dec 10, 2020

The wrong_pub_self_convention example from documentation is kind of misleading to me.

The example for this lint is:

# struct X;
impl<'a> X {
    pub fn as_str(self) -> &'a str {
        "foo"
    }
}

On playground, it fires wrong_self_convention (instead wrong_pub_self_convention), so the example or the lint needs to be reworked.

The difference with wrong_self_convention example is mainly the pub keyword on the method as_str, but the lint doesn't use the function visibility as condition to choose which lint to fire (in fact it uses the visibility of the impl item).

As proposed in #6316, it would probably make sense to also look into the history of the lints, what were the reasons to split them (if that was the case)?
It seems there are no tests for the pub variant.

@ThibsG
Copy link
Contributor Author

ThibsG commented Dec 10, 2020

@rustbot modify labels: +L-enhancement +L-lint +L-documentation

@rustbot rustbot added A-documentation Area: Adding or improving documentation C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages A-lint Area: New lints labels Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documentation Area: Adding or improving documentation A-lint Area: New lints C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages
Projects
None yet
Development

No branches or pull requests

2 participants