Skip to content

E0603 "import directly" suggestion doesn't consider a matching prefix with brace syntax #155348

@424ever

Description

@424ever

Code

use std::{fs::Path};

fn main() {}

Current output

error[E0603]: struct `Path` is private
 --> main.rs:1:15
  |
1 | use std::{fs::Path};
  |               ^^^^ private struct
  |
note: the struct `Path` is defined here
 --> /rustc/a5c825cd824ee0ef9463021078a2f464b4cc1a0d/library/std/src/fs.rs:46:18
help: import `Path` directly
  |
1 - use std::{fs::Path};
1 + use std::{std::path::Path};
  |

Desired output

error[E0603]: struct `Path` is private
 --> main.rs:1:15
  |
1 | use std::{fs::Path};
  |               ^^^^ private struct
  |
note: the struct `Path` is defined here
 --> /rustc/a5c825cd824ee0ef9463021078a2f464b4cc1a0d/library/std/src/fs.rs:46:18
help: import `Path` directly
  |
1 - use std::{fs::Path};
1 + use std::{path::Path};
  |

Rationale and extra context

No response

Other cases

Rust Version

$ rustc --version --verbose
rustc 1.97.0-nightly (a5c825cd8 2026-04-14)
binary: rustc
commit-hash: a5c825cd824ee0ef9463021078a2f464b4cc1a0d
commit-date: 2026-04-14
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.2

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions