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

No location reported for module_name_repetitions #3892

Closed
simon-bourne opened this issue Mar 18, 2019 · 1 comment · Fixed by #4006
Closed

No location reported for module_name_repetitions #3892

simon-bourne opened this issue Mar 18, 2019 · 1 comment · Fixed by #4006
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy

Comments

@simon-bourne
Copy link

Hi,

Clippy fails to give a location for module_name_repetitions in some cases. It looks like it's when an attribute matches the module name. Here's the steps to reproduce:

cargo new --lib clippy-test
cd clippy-test

Change the module inside src/lib.rs from tests to test:

#[cfg(test)]
mod test {
    #[test]
    fn it_works() {
        assert_eq!(2 + 2, 4);
    }
}

Then run cargo clippy --tests -- -D clippy::pedantic, which outputs:

    Checking clippy-test v0.1.0 (/some_path/clippy-test)
error: item name starts with its containing module's name
  |
  = note: `-D clippy::module-name-repetitions` implied by `-D clippy::pedantic`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#module_name_repetitions

error: aborting due to previous error

error: Could not compile `clippy-test`.

To learn more, run the command again with --verbose.

Regards,

Simon

Versions:

clippy 0.0.212 (1b89724 2019-01-15)
cargo 1.33.0 (f099fe94b 2019-02-12)

@flip1995 flip1995 added C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy labels Mar 18, 2019
@flip1995
Copy link
Member

I don't think we should apply this lint to attributes at all.

@phansch phansch self-assigned this Apr 19, 2019
bors added a commit that referenced this issue Apr 20, 2019
Fix false positive in module_name_repetitions lint

This lint was triggering on modules inside expanded attrs, like
for example `#[cfg(test)]` and possibly more.

It was not reporting a location in #3892 because `span.lo()` and `span.hi()` both were 0.

Fixes #3892

changelog: Fix false positive in `module_name_repetitions` lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants