diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-10-01 02:13:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-01 02:13:49 +0200 |
| commit | 85e77edc82f8052b865cf35f9aaade2d668ea4f1 (patch) | |
| tree | 5aee4e376d8877c702d9a32e06a03a89724cfe6e | |
| parent | cc1513b860900f87a1077193f0a1dd4e1beeb577 (diff) | |
| parent | b2ce3e53446173b56607b5a8ad8d9c4b3565d5da (diff) | |
| download | rust-85e77edc82f8052b865cf35f9aaade2d668ea4f1.tar.gz rust-85e77edc82f8052b865cf35f9aaade2d668ea4f1.zip | |
Rollup merge of #77371 - camelid:remove-extra-space-in-diagnostic, r=varkor
Remove trailing space in error message - Add test for error message - Remove trailing space in error message
| -rw-r--r-- | compiler/rustc_middle/src/ty/error.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/slice-to-vec-comparison.rs | 6 | ||||
| -rw-r--r-- | src/test/ui/slice-to-vec-comparison.stderr | 12 |
3 files changed, 19 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/ty/error.rs b/compiler/rustc_middle/src/ty/error.rs index 67c69d69bda..82d698b37ab 100644 --- a/compiler/rustc_middle/src/ty/error.rs +++ b/compiler/rustc_middle/src/ty/error.rs @@ -232,7 +232,7 @@ impl<'tcx> ty::TyS<'tcx> { let n = tcx.lift(&n).unwrap(); match n.try_eval_usize(tcx, ty::ParamEnv::empty()) { _ if t.is_simple_ty() => format!("array `{}`", self).into(), - Some(n) => format!("array of {} element{} ", n, pluralize!(n)).into(), + Some(n) => format!("array of {} element{}", n, pluralize!(n)).into(), None => "array".into(), } } diff --git a/src/test/ui/slice-to-vec-comparison.rs b/src/test/ui/slice-to-vec-comparison.rs new file mode 100644 index 00000000000..7026a49000c --- /dev/null +++ b/src/test/ui/slice-to-vec-comparison.rs @@ -0,0 +1,6 @@ +fn main() { + let a = &[]; + let b: &Vec<u8> = &vec![]; + a > b; + //~^ ERROR mismatched types +} diff --git a/src/test/ui/slice-to-vec-comparison.stderr b/src/test/ui/slice-to-vec-comparison.stderr new file mode 100644 index 00000000000..e3b3b040f66 --- /dev/null +++ b/src/test/ui/slice-to-vec-comparison.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/slice-to-vec-comparison.rs:4:9 + | +LL | a > b; + | ^ expected array of 0 elements, found struct `Vec` + | + = note: expected reference `&[_; 0]` + found reference `&Vec<u8>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. |
