Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}