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
This commit is contained in:
Dylan DPC 2020-10-01 02:13:49 +02:00 committed by GitHub
commit 85e77edc82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 1 deletions

View File

@ -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(),
}
}

View File

@ -0,0 +1,6 @@
fn main() {
let a = &[];
let b: &Vec<u8> = &vec![];
a > b;
//~^ ERROR mismatched types
}

View File

@ -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`.