From cde0023b5b71eb4ceafef31dd9036a268ba3b08d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 25 Nov 2017 06:19:39 -0800 Subject: [PATCH] Add `compile-fail` style comments to tests --- src/test/ui/suggestions/str-array-assignment.rs | 17 ++++++++++++++++- .../ui/suggestions/str-array-assignment.stderr | 14 +++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/test/ui/suggestions/str-array-assignment.rs b/src/test/ui/suggestions/str-array-assignment.rs index 523e7bea6224b..52b39d390d62b 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 225dfbd98fddf..55006b2760cca 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`