diff --git a/src/test/ui/suggestions/str-array-assignment.rs b/src/test/ui/suggestions/str-array-assignment.rs index 523e7bea622..52b39d390d6 100644 --- a/src/test/ui/suggestions/str-array-assignment.rs +++ b/src/test/ui/suggestions/str-array-assignment.rs @@ -8,10 +8,25 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +fn main() { //~ NOTE expected `()` because of default return type let s = "abc"; let t = if true { s[..2] } else { s }; + //~^ ERROR if and else have incompatible types + //~| NOTE expected str, found &str + //~| NOTE expected type let u: &str = if true { s[..2] } else { s }; + //~^ ERROR mismatched types + //~| NOTE expected &str, found str + //~| NOTE expected type let v = s[..2]; + //~^ ERROR the trait bound `str: std::marker::Sized` is not satisfied + //~| NOTE consider a slice instead + //~| NOTE `str` does not have a constant size known at compile-time + //~| HELP the trait `std::marker::Sized` is not implemented for `str` + //~| NOTE all local variables must have a statically known size let w: &str = s[..2]; + //~^ ERROR mismatched types + //~| NOTE expected &str, found str + //~| NOTE expected type + //~| HELP try with `&s[..2]` } diff --git a/src/test/ui/suggestions/str-array-assignment.stderr b/src/test/ui/suggestions/str-array-assignment.stderr index 225dfbd98fd..55006b2760c 100644 --- a/src/test/ui/suggestions/str-array-assignment.stderr +++ b/src/test/ui/suggestions/str-array-assignment.stderr @@ -8,21 +8,21 @@ error[E0308]: if and else have incompatible types found type `&str` error[E0308]: mismatched types - --> $DIR/str-array-assignment.rs:14:27 + --> $DIR/str-array-assignment.rs:17:27 | -11 | fn main() { +11 | fn main() { //~ NOTE expected `()` because of default return type | - expected `()` because of default return type ... -14 | let u: &str = if true { s[..2] } else { s }; +17 | let u: &str = if true { s[..2] } else { s }; | ^^^^^^ expected &str, found str | = note: expected type `&str` found type `str` error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied - --> $DIR/str-array-assignment.rs:15:7 + --> $DIR/str-array-assignment.rs:21:7 | -15 | let v = s[..2]; +21 | let v = s[..2]; | ^ ------ help: consider a slice instead: `&s[..2]` | | | `str` does not have a constant size known at compile-time @@ -31,9 +31,9 @@ error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied = note: all local variables must have a statically known size error[E0308]: mismatched types - --> $DIR/str-array-assignment.rs:16:17 + --> $DIR/str-array-assignment.rs:27:17 | -16 | let w: &str = s[..2]; +27 | let w: &str = s[..2]; | ^^^^^^ expected &str, found str | = note: expected type `&str`