Skip to content

Commit 1a819a2

Browse files
committed
Make E0243/0244 message consistent with E0107
1 parent 3fc8304 commit 1a819a2

11 files changed

+41
-36
lines changed

src/librustc_typeck/astconv.rs

+16-11
Original file line numberDiff line numberDiff line change
@@ -2245,27 +2245,32 @@ fn check_type_argument_count(tcx: TyCtxt, span: Span, supplied: usize,
22452245
"expected"
22462246
};
22472247
let arguments_plural = if required == 1 { "" } else { "s" };
2248-
struct_span_err!(tcx.sess, span, E0243, "wrong number of type arguments")
2249-
.span_label(
2250-
span,
2251-
&format!("{} {} type argument{}, found {}",
2252-
expected, required, arguments_plural, supplied)
2253-
)
2248+
2249+
struct_span_err!(tcx.sess, span, E0243,
2250+
"wrong number of type arguments: {} {}, found {}",
2251+
expected, required, supplied)
2252+
.span_label(span,
2253+
&format!("{} {} type argument{}",
2254+
expected,
2255+
required,
2256+
arguments_plural))
22542257
.emit();
22552258
} else if supplied > accepted {
2256-
let expected = if required == 0 {
2257-
"expected no".to_string()
2258-
} else if required < accepted {
2259+
let expected = if required < accepted {
22592260
format!("expected at most {}", accepted)
22602261
} else {
22612262
format!("expected {}", accepted)
22622263
};
22632264
let arguments_plural = if accepted == 1 { "" } else { "s" };
22642265

2265-
struct_span_err!(tcx.sess, span, E0244, "wrong number of type arguments")
2266+
struct_span_err!(tcx.sess, span, E0244,
2267+
"wrong number of type arguments: {}, found {}",
2268+
expected, supplied)
22662269
.span_label(
22672270
span,
2268-
&format!("{} type argument{}, found {}", expected, arguments_plural, supplied)
2271+
&format!("{} type argument{}",
2272+
if accepted == 0 { "expected no" } else { &expected },
2273+
arguments_plural)
22692274
)
22702275
.emit();
22712276
}

src/test/compile-fail/E0243.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
struct Foo<T> { x: T }
1212
struct Bar { x: Foo }
13-
//~^ ERROR E0243
14-
//~| NOTE expected 1 type argument, found 0
13+
//~^ ERROR wrong number of type arguments: expected 1, found 0 [E0243]
14+
//~| NOTE expected 1 type argument
1515

1616
fn main() {
1717
}

src/test/compile-fail/E0244.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
struct Foo { x: bool }
1212
struct Bar<S, T> { x: Foo<S, T> }
13-
//~^ ERROR E0244
14-
//~| NOTE expected no type arguments, found 2
13+
//~^ ERROR wrong number of type arguments: expected 0, found 2 [E0244]
14+
//~| NOTE expected no type arguments
1515

1616

1717
fn main() {

src/test/compile-fail/generic-type-less-params-with-defaults.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ struct Vec<T, A = Heap>(
1717

1818
fn main() {
1919
let _: Vec;
20-
//~^ ERROR E0243
21-
//~| NOTE expected at least 1 type argument, found 0
20+
//~^ ERROR wrong number of type arguments: expected at least 1, found 0 [E0243]
21+
//~| NOTE expected at least 1 type argument
2222
}

src/test/compile-fail/generic-type-more-params-with-defaults.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ struct Vec<T, A = Heap>(
1717

1818
fn main() {
1919
let _: Vec<isize, Heap, bool>;
20-
//~^ ERROR E0244
21-
//~| NOTE expected at most 2 type arguments, found 3
20+
//~^ ERROR wrong number of type arguments: expected at most 2, found 3 [E0244]
21+
//~| NOTE expected at most 2 type arguments
2222
}

src/test/compile-fail/issue-14092.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
fn fn1(0: Box) {}
12-
//~^ ERROR E0243
13-
//~| NOTE expected 1 type argument, found 0
12+
//~^ ERROR wrong number of type arguments: expected 1, found 0 [E0243]
13+
//~| NOTE expected 1 type argument
1414

1515
fn main() {}

src/test/compile-fail/issue-23024.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ fn main()
1818
vfnfer.push(box h);
1919
println!("{:?}",(vfnfer[0] as Fn)(3));
2020
//~^ ERROR the precise format of `Fn`-family traits'
21-
//~| ERROR E0243
21+
//~| ERROR wrong number of type arguments: expected 1, found 0 [E0243]
2222
//~| ERROR the value of the associated type `Output` (from the trait `std::ops::FnOnce`)
2323
}

src/test/compile-fail/typeck-builtin-bound-type-parameters.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@
99
// except according to those terms.
1010

1111
fn foo1<T:Copy<U>, U>(x: T) {}
12-
//~^ ERROR E0244
13-
//~| NOTE expected no type arguments, found 1
12+
//~^ ERROR wrong number of type arguments: expected 0, found 1 [E0244]
13+
//~| NOTE expected no type arguments
1414

1515
trait Trait: Copy<Send> {}
16-
//~^ ERROR E0244
17-
//~| NOTE expected no type arguments, found 1
16+
//~^ ERROR wrong number of type arguments: expected 0, found 1 [E0244]
17+
//~| NOTE expected no type arguments
1818

1919
struct MyStruct1<T: Copy<T>>;
20-
//~^ ERROR E0244
21-
//~| NOTE expected no type arguments, found 1
20+
//~^ ERROR wrong number of type arguments: expected 0, found 1 [E0244]
21+
//~| NOTE expected no type arguments
2222

2323
struct MyStruct2<'a, T: Copy<'a>>;
2424
//~^ ERROR: wrong number of lifetime parameters: expected 0, found 1
2525
//~| NOTE unexpected lifetime parameter
2626

2727

2828
fn foo2<'a, T:Copy<'a, U>, U>(x: T) {}
29-
//~^ ERROR E0244
30-
//~| NOTE expected no type arguments, found 1
29+
//~^ ERROR wrong number of type arguments: expected 0, found 1 [E0244]
30+
//~| NOTE expected no type arguments
3131
//~| ERROR: wrong number of lifetime parameters: expected 0, found 1
3232
//~| NOTE unexpected lifetime parameter
3333

src/test/compile-fail/typeck_type_placeholder_lifetime_1.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ struct Foo<'a, T:'a> {
1717

1818
pub fn main() {
1919
let c: Foo<_, _> = Foo { r: &5 };
20-
//~^ ERROR E0244
21-
//~| NOTE expected 1 type argument, found 2
20+
//~^ ERROR wrong number of type arguments: expected 1, found 2 [E0244]
21+
//~| NOTE expected 1 type argument
2222
}

src/test/compile-fail/typeck_type_placeholder_lifetime_2.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ struct Foo<'a, T:'a> {
1717

1818
pub fn main() {
1919
let c: Foo<_, usize> = Foo { r: &5 };
20-
//~^ ERROR E0244
21-
//~| NOTE expected 1 type argument, found 2
20+
//~^ ERROR wrong number of type arguments: expected 1, found 2 [E0244]
21+
//~| NOTE expected 1 type argument
2222
}

src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
trait Trait {}
1414

1515
fn f<F:Trait(isize) -> isize>(x: F) {}
16-
//~^ ERROR E0244
17-
//~| NOTE expected no type arguments, found 1
16+
//~^ ERROR wrong number of type arguments: expected 0, found 1 [E0244]
17+
//~| NOTE expected no type arguments
1818
//~| ERROR E0220
1919
//~| NOTE associated type `Output` not found
2020

0 commit comments

Comments
 (0)