Skip to content

Commit

Permalink
correct erroneous pluralization of '1 type argument' error messages
Browse files Browse the repository at this point in the history
This is in the matter of rust-lang#37042.
  • Loading branch information
zackmdavis committed Oct 15, 2016
1 parent 8e05e7e commit ac42f3f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/E0243.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-14092.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit ac42f3f

Please sign in to comment.