diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2017-12-13 17:34:47 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2018-06-29 10:36:32 -0700 |
| commit | 2636b314ec5771498f26847f1204d1d4f8b280dd (patch) | |
| tree | 94e01450a7ea83d179862e0d2adc12a634ee5ce7 /src/test/ui/suggestions | |
| parent | 5fdcd3aa389aa92879f576c55e429015667143c3 (diff) | |
| download | rust-2636b314ec5771498f26847f1204d1d4f8b280dd.tar.gz rust-2636b314ec5771498f26847f1204d1d4f8b280dd.zip | |
Fix incorrect type mismatch label pointing at return type
Diffstat (limited to 'src/test/ui/suggestions')
| -rw-r--r-- | src/test/ui/suggestions/issue-46302.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/suggestions/issue-46302.stderr | 15 | ||||
| -rw-r--r-- | src/test/ui/suggestions/str-array-assignment.stderr | 3 |
3 files changed, 34 insertions, 3 deletions
diff --git a/src/test/ui/suggestions/issue-46302.rs b/src/test/ui/suggestions/issue-46302.rs new file mode 100644 index 00000000000..6ae6b549b07 --- /dev/null +++ b/src/test/ui/suggestions/issue-46302.rs @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo() { + let s = "abc"; + let u: &str = if true { s[..2] } else { s }; + //~^ ERROR mismatched types +} + +fn main() { + foo(); +} diff --git a/src/test/ui/suggestions/issue-46302.stderr b/src/test/ui/suggestions/issue-46302.stderr new file mode 100644 index 00000000000..8e399136fad --- /dev/null +++ b/src/test/ui/suggestions/issue-46302.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/issue-46302.rs:13:27 + | +LL | let u: &str = if true { s[..2] } else { s }; + | ^^^^^^ + | | + | expected &str, found str + | help: consider borrowing here: `&s[..2]` + | + = note: expected type `&str` + found type `str` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/suggestions/str-array-assignment.stderr b/src/test/ui/suggestions/str-array-assignment.stderr index 041bae4a421..5af936eec5b 100644 --- a/src/test/ui/suggestions/str-array-assignment.stderr +++ b/src/test/ui/suggestions/str-array-assignment.stderr @@ -10,9 +10,6 @@ LL | let t = if true { s[..2] } else { s }; error[E0308]: mismatched types --> $DIR/str-array-assignment.rs:15:27 | -LL | fn main() { - | - expected `()` because of default return type -... LL | let u: &str = if true { s[..2] } else { s }; | ^^^^^^ | | |
