Skip to content

Error message about importing traits should use a working code #31864

Closed
@julienw

Description

@julienw

Current error when using io::stdout().flush() without importing std::io::Write looks like this:

src/main.rs:95:22: 95:27 error: no method named `flush` found for type `std::io::stdio::Stdout` in the current scope
src/main.rs:95         io::stdout().flush(); // https://github.com/rust-lang/rust/issues/23818
                                    ^~~~~
src/main.rs:95:22: 95:27 help: items from traits can only be used if the trait is in scope; the following trait is implemented but not in scope, perhaps add a `use` for it:
src/main.rs:95:22: 95:27 help: candidate #1: use `std::io::Write`

I think the last line should not have the backticks so that we could use the command directly in code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions