diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-10-03 13:47:59 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-03 13:47:59 +0200 |
| commit | aedf14bb0c5bac2a75099dff13caec5247cbdc2d (patch) | |
| tree | bf153ae8f4b58e9bb6d35eda4e46c15696f0f640 | |
| parent | c9b907a567d6c7e276910f77a86aa134d19da4ba (diff) | |
| parent | 4b48d72eaa7f4d934f56bcf2b6d0348954977823 (diff) | |
| download | rust-aedf14bb0c5bac2a75099dff13caec5247cbdc2d.tar.gz rust-aedf14bb0c5bac2a75099dff13caec5247cbdc2d.zip | |
Rollup merge of #131163 - JakenHerman:master, r=Nadrieril
Add `get_line` confusable to `Stdin::read_line()` This pull request resolves https://github.com/rust-lang/rust/issues/131091 --- I've updated tests for `tests/ui/attributes/rustc_confusables_std_cases` in order to verify this change is working as intended. Before I submitted this pull request, I had a pull request to my local fork. If you're interested in seeing the conversation on that PR, go to https://github.com/JakenHerman/rust/pull/1. --- **Testing**: Run `./x.py test tests/ui/attributes/rustc_confusables_std_cases.rs`
| -rw-r--r-- | library/std/src/io/stdio.rs | 1 | ||||
| -rw-r--r-- | tests/ui/attributes/rustc_confusables_std_cases.rs | 4 | ||||
| -rw-r--r-- | tests/ui/attributes/rustc_confusables_std_cases.stderr | 13 |
3 files changed, 17 insertions, 1 deletions
diff --git a/library/std/src/io/stdio.rs b/library/std/src/io/stdio.rs index 6de069a518e..bf242e715bd 100644 --- a/library/std/src/io/stdio.rs +++ b/library/std/src/io/stdio.rs @@ -394,6 +394,7 @@ impl Stdin { /// in which case it will wait for the Enter key to be pressed before /// continuing #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_confusables("get_line")] pub fn read_line(&self, buf: &mut String) -> io::Result<usize> { self.lock().read_line(buf) } diff --git a/tests/ui/attributes/rustc_confusables_std_cases.rs b/tests/ui/attributes/rustc_confusables_std_cases.rs index d9121695950..4f6baea26df 100644 --- a/tests/ui/attributes/rustc_confusables_std_cases.rs +++ b/tests/ui/attributes/rustc_confusables_std_cases.rs @@ -23,4 +23,8 @@ fn main() { //~^ HELP you might have meant to use `push_str` String::new().append(""); //~ ERROR E0599 //~^ HELP you might have meant to use `push_str` + let mut buffer = String::new(); + let stdin = std::io::stdin(); + stdin.get_line(&mut buffer).unwrap(); //~ ERROR E0599 + //~^ HELP you might have meant to use `read_line` } diff --git a/tests/ui/attributes/rustc_confusables_std_cases.stderr b/tests/ui/attributes/rustc_confusables_std_cases.stderr index f4b6947ccd9..7bf96241ca7 100644 --- a/tests/ui/attributes/rustc_confusables_std_cases.stderr +++ b/tests/ui/attributes/rustc_confusables_std_cases.stderr @@ -106,7 +106,18 @@ help: you might have meant to use `push_str` LL | String::new().push_str(""); | ~~~~~~~~ -error: aborting due to 8 previous errors +error[E0599]: no method named `get_line` found for struct `Stdin` in the current scope + --> $DIR/rustc_confusables_std_cases.rs:28:11 + | +LL | stdin.get_line(&mut buffer).unwrap(); + | ^^^^^^^^ method not found in `Stdin` + | +help: you might have meant to use `read_line` + | +LL | stdin.read_line(&mut buffer).unwrap(); + | ~~~~~~~~~ + +error: aborting due to 9 previous errors Some errors have detailed explanations: E0308, E0599. For more information about an error, try `rustc --explain E0308`. |
