Skip to content

Conversation

lengyijun
Copy link
Contributor

@lengyijun lengyijun commented Nov 7, 2024

changelog: [use_crate_prefix_for_self_imports]: new lint

fix #13645

Only check main.rs and lib.rs

Known problem

  • Duplicate warning

TODO

  • rm tests/ui/use_crate_prefix_for_self_imports.rs
  • squash commits

Question

Although pass all tests, but if copy lintcheck to /tmp, clippy will report two warnings (expected)

warning: this import is not clear
  --> src/main.rs:42:5
   |
42 | use input::read_crates;
   |     ^^^^^ help: prefix with `crate::`: `crate::input`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_crate_prefix_for_self_imports
   = note: `#[warn(clippy::use_crate_prefix_for_self_imports)]` on by default

warning: this import is not clear
  --> src/main.rs:43:5
   |
43 | use output::{ClippyCheckOutput, ClippyWarning, RustcIce};
   |     ^^^^^^ help: prefix with `crate::`: `crate::output`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_crate_prefix_for_self_imports

@rustbot
Copy link
Collaborator

rustbot commented Nov 7, 2024

r? @llogiq

rustbot has assigned @llogiq.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Nov 7, 2024
@lengyijun lengyijun force-pushed the last_use_crate_prefix_for_self_imports branch from 2a70749 to bfc0849 Compare November 7, 2024 11:40
@lengyijun lengyijun changed the title use crate prefix for self imports new lint use_crate_prefix_for_self_imports Nov 7, 2024
@lengyijun lengyijun changed the title new lint use_crate_prefix_for_self_imports new lint: use_crate_prefix_for_self_imports Nov 7, 2024
@lengyijun lengyijun force-pushed the last_use_crate_prefix_for_self_imports branch 5 times, most recently from f74a6bc to 6a0c669 Compare November 8, 2024 04:46
@lengyijun lengyijun force-pushed the last_use_crate_prefix_for_self_imports branch from 6a0c669 to 7633f16 Compare November 13, 2024 03:26
@llogiq
Copy link
Contributor

llogiq commented Jan 10, 2025

So, as you know we discussed this on zulip a while ago. The upshot is that we have two acceptable options:

  • Put the lint in the nursery group and improve it until we deem it ready for style
  • Add more checks to the lint to reduce the number of warnings that aren't too helpful. For example, if we have the respective mod near the use (where near could be measured in line number differences or in no other items but mods and uses in between), we could avoid linting, as the reader of the code will know that the item comes from the mod specified nearby (this could be done by walking the sibling items until a non-mod-or-use item is found).

Do you intend to continue working on this?

@llogiq
Copy link
Contributor

llogiq commented Jan 25, 2025

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Jan 25, 2025
@lengyijun lengyijun force-pushed the last_use_crate_prefix_for_self_imports branch from 7633f16 to 5817b6f Compare January 27, 2025 10:20
@lengyijun lengyijun force-pushed the last_use_crate_prefix_for_self_imports branch 5 times, most recently from 840f04d to 9e1dbdc Compare January 30, 2025 04:22
@lengyijun
Copy link
Contributor Author

Don't lint if mod and use in the same block

@lengyijun lengyijun force-pushed the last_use_crate_prefix_for_self_imports branch from a500545 to a3f5529 Compare January 31, 2025 01:01
@lengyijun
Copy link
Contributor Author

The problem of lintcheck still exists

@llogiq
Copy link
Contributor

llogiq commented Feb 2, 2025

What does that mean?

@lengyijun
Copy link
Contributor Author

Although pass all tests, but if copy lintcheck to /tmp, clippy will report two warnings (expected)

warning: this import is not clear
  --> src/main.rs:42:5
   |
42 | use input::read_crates;
   |     ^^^^^ help: prefix with `crate::`: `crate::input`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_crate_prefix_for_self_imports
   = note: `#[warn(clippy::use_crate_prefix_for_self_imports)]` on by default

warning: this import is not clear
  --> src/main.rs:43:5
   |
43 | use output::{ClippyCheckOutput, ClippyWarning, RustcIce};
   |     ^^^^^^ help: prefix with `crate::`: `crate::output`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_crate_prefix_for_self_imports

@lengyijun lengyijun force-pushed the last_use_crate_prefix_for_self_imports branch from a8b6306 to 4cfbe4d Compare October 12, 2025 02:33
@rustbot
Copy link
Collaborator

rustbot commented Oct 12, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@lengyijun lengyijun force-pushed the last_use_crate_prefix_for_self_imports branch 3 times, most recently from 10b927e to c4aa68c Compare October 12, 2025 03:03
@lengyijun
Copy link
Contributor Author

lengyijun commented Oct 12, 2025

@samueltardieu @llogiq Hi, ready for another review
I'll rebase before merge

@lengyijun lengyijun force-pushed the last_use_crate_prefix_for_self_imports branch from c4aa68c to fcf45ca Compare October 12, 2025 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-fcp S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

use_crate_prefix_for_self_imports

5 participants