error[E0308]: mismatched types --> $DIR/coerce-suggestions.rs:17:20 | LL | let x: usize = String::new(); | ^^^^^^^^^^^^^ expected usize, found struct `std::string::String` | = note: expected type `usize` found type `std::string::String` error[E0308]: mismatched types --> $DIR/coerce-suggestions.rs:19:19 | LL | let x: &str = String::new(); | ^^^^^^^^^^^^^ | | | expected &str, found struct `std::string::String` | help: consider borrowing here: `&String::new()` | = note: expected type `&str` found type `std::string::String` error[E0308]: mismatched types --> $DIR/coerce-suggestions.rs:22:10 | LL | test(&y); | ^^ types differ in mutability | = note: expected type `&mut std::string::String` found type `&std::string::String` error[E0308]: mismatched types --> $DIR/coerce-suggestions.rs:24:11 | LL | test2(&y); | ^^ types differ in mutability | = note: expected type `&mut i32` found type `&std::string::String` error[E0308]: mismatched types --> $DIR/coerce-suggestions.rs:27:9 | LL | f = box f; | ^^^^^ | | | cyclic type of infinite size | help: try using a conversion method: `box f.to_string()` error[E0308]: mismatched types --> $DIR/coerce-suggestions.rs:31:9 | LL | s = format!("foo"); | ^^^^^^^^^^^^^^ | | | expected mutable reference, found struct `std::string::String` | help: consider mutably borrowing here: `&mut format!("foo")` | = note: expected type `&mut std::string::String` found type `std::string::String` = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: aborting due to 6 previous errors If you want more information on this error, try using "rustc --explain E0308"