rust/src/test/ui/suggest-using-chars.rs
Takayuki Maeda d562f487c9 suggest &str.chars() on attempt to &str.iter()
check if `String` or `&String` or `&str`

Update compiler/rustc_typeck/src/check/method/suggest.rs

Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>

remove some trailing whitespace
2021-11-15 12:37:01 +09:00

8 lines
596 B
Rust

pub fn main() {
let _ = "foo".iter(); //~ ERROR no method named `iter` found for reference `&'static str` in the current scope
let _ = "foo".foo(); //~ ERROR no method named `foo` found for reference `&'static str` in the current scope
let _ = String::from("bar").iter(); //~ ERROR no method named `iter` found for struct `String` in the current scope
let _ = (&String::from("bar")).iter(); //~ ERROR no method named `iter` found for reference `&String` in the current scope
let _ = 0.iter(); //~ ERROR no method named `iter` found for type `{integer}` in the current scope
}