Skip to content

Add compiler hint for stdin().get_line() -> stdin().read_line() #131091

Closed
JakenHerman/rust
#1
@myclevorname

Description

@myclevorname

Code

I am learning Rust, and I keep typing std::io::stdin().get_line() instead of std::io::stdin().read_line() and the compiler doesn't give any useful hints.

Current output

   Compiling playground v0.0.1 (/playground)
error[E0599]: no method named `get_line` found for struct `Stdin` in the current scope
 --> src/main.rs:5:13
  |
5 |     stdin().get_line(&mut string);
  |             ^^^^^^^^ method not found in `Stdin`

Desired output

   Compiling playground v0.0.1 (/playground)
error[E0599]: no method named `get_line` found for struct `Stdin` in the current scope
 --> src/main.rs:5:13
  |
5 |     stdin().get_line(&mut string);
  |             ^^^^^^^^
  |
help: there is a method `read_line` with a similar name
  |
5 |     stdin().read_line(&mut string);
  |             ~~~~~~~~~

Rationale and extra context

I keep accidentally making this mistake because I am a beginner.

Other cases

No response

Rust Version

rustc version 1.81.0 via https://play.rust-lang.org/?version=stable&mode=debug&edition=2021
I am not able to access my laptop right now, and it uses 1.80.1 anyway.

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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions