Skip to content

FP single-component-path-imports : self::<import>::... #10549

@matthiaskrgr

Description

@matthiaskrgr

Summary

.

Lint Name

single_component_path_imports

Reproducer

I tried this code:

use std;

fn main() {
    let _ = self::std::io::stdout();
}

I saw this happen:

warning: this import is redundant
 --> src/main.rs:1:1
  |
1 | use std;
  | ^^^^^^^^ help: remove it entirely
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_component_path_imports
  = note: `#[warn(clippy::single_component_path_imports)]` on by default

Applying the suggestion breaks the build:

The following errors were reported:
error[E0433]: failed to resolve: could not find `std` in the crate root
 --> src/main.rs:8:19
  |
8 |     let _ = self::std::io::stdout();
  |                   ^^^ could not find `std` in the crate root

error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
Original diagnostics will follow.

Version

rustc 1.70.0-nightly (8be3c2bda 2023-03-24)
binary: rustc
commit-hash: 8be3c2bda6b683f87b24714ba595e8b04faef54c
commit-date: 2023-03-24
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions