Skip to content

Diagnostic message for std trait implementation includes unstable std type #108994

Open
@ChrisDenton

Description

@ChrisDenton

Background

Within std I'm attempting to add an unstable type to a trait (see here for the impl). However, after compiling the new std, the unstable type is shown in error messages even without the feature enabled.

Code

struct Biscuits;
fn main() {
    std::fs::metadata(&Biscuits).unwrap();
}

Current Output

error[E0277]: the trait bound `Biscuits: AsRef<Path>` is not satisfied
    --> temp.rs:3:21
     |
3    |     std::fs::metadata(&Biscuits).unwrap();
     |     -----------------  ^^^^^^^^ the trait `AsRef<Path>` is not implemented for `Biscuits`
     |     |
     |     required by a bound introduced by this call
     |
     = help: the trait `AsPath` is implemented for `&NativePath`
     = note: required for `&Biscuits` to implement `AsRef<Path>`
     = note: required for `&Biscuits` to implement `AsPath`
note: required by a bound in `std::fs::metadata`
    --> R:\rust\library\std\src\fs.rs:1848:20
     |
1848 | pub fn metadata<P: AsPath>(path: P) -> io::Result<Metadata> {
     |                    ^^^^^^ required by this bound in `metadata`

Desired Output

Remove the first help: message.

error[E0277]: the trait bound `Biscuits: AsRef<Path>` is not satisfied
    --> temp.rs:3:21
     |
3    |     std::fs::metadata(&Biscuits).unwrap();
     |     -----------------  ^^^^^^^^ the trait `AsRef<Path>` is not implemented for `Biscuits`
     |     |
     |     required by a bound introduced by this call
     |
     = note: required for `&Biscuits` to implement `AsRef<Path>`
     = note: required for `&Biscuits` to implement `AsPath`
note: required by a bound in `std::fs::metadata`
    --> R:\rust\library\std\src\fs.rs:1848:20
     |
1848 | pub fn metadata<P: AsPath>(path: P) -> io::Result<Metadata> {
     |                    ^^^^^^ required by this bound in `metadata`

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions