correct erroneous pluralization of '1 type argument' error messages

This is in the matter of #37042.
This commit is contained in:
Zack M. Davis 2016-10-15 11:40:12 -07:00
parent 8e05e7ee3c
commit ac42f3f206
6 changed files with 10 additions and 7 deletions

View file

@ -2218,10 +2218,12 @@ fn check_type_argument_count(tcx: TyCtxt, span: Span, supplied: usize,
} else {
"expected"
};
let arguments_plural = if required == 1 { "" } else { "s" };
struct_span_err!(tcx.sess, span, E0243, "wrong number of type arguments")
.span_label(
span,
&format!("{} {} type arguments, found {}", expected, required, supplied)
&format!("{} {} type argument{}, found {}",
expected, required, arguments_plural, supplied)
)
.emit();
} else if supplied > accepted {
@ -2232,11 +2234,12 @@ fn check_type_argument_count(tcx: TyCtxt, span: Span, supplied: usize,
} else {
format!("expected {}", accepted)
};
let arguments_plural = if accepted == 1 { "" } else { "s" };
struct_span_err!(tcx.sess, span, E0244, "wrong number of type arguments")
.span_label(
span,
&format!("{} type arguments, found {}", expected, supplied)
&format!("{} type argument{}, found {}", expected, arguments_plural, supplied)
)
.emit();
}

View file

@ -11,7 +11,7 @@
struct Foo<T> { x: T }
struct Bar { x: Foo }
//~^ ERROR E0243
//~| NOTE expected 1 type arguments, found 0
//~| NOTE expected 1 type argument, found 0
fn main() {
}

View file

@ -18,5 +18,5 @@ struct Vec<T, A = Heap>(
fn main() {
let _: Vec;
//~^ ERROR E0243
//~| NOTE expected at least 1 type arguments, found 0
//~| NOTE expected at least 1 type argument, found 0
}

View file

@ -10,6 +10,6 @@
fn fn1(0: Box) {}
//~^ ERROR E0243
//~| NOTE expected 1 type arguments, found 0
//~| NOTE expected 1 type argument, found 0
fn main() {}

View file

@ -18,5 +18,5 @@ struct Foo<'a, T:'a> {
pub fn main() {
let c: Foo<_, _> = Foo { r: &5 };
//~^ ERROR E0244
//~| NOTE expected 1 type arguments, found 2
//~| NOTE expected 1 type argument, found 2
}

View file

@ -18,5 +18,5 @@ struct Foo<'a, T:'a> {
pub fn main() {
let c: Foo<_, usize> = Foo { r: &5 };
//~^ ERROR E0244
//~| NOTE expected 1 type arguments, found 2
//~| NOTE expected 1 type argument, found 2
}