diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 2444259d406..081efdfd2fd 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -2257,20 +2257,27 @@ fn check_type_argument_count(tcx: TyCtxt, span: Span, supplied: usize, } else { "expected" }; - span_err!(tcx.sess, span, E0243, - "wrong number of type arguments: {} {}, found {}", - expected, required, supplied); + struct_span_err!(tcx.sess, span, E0243, "wrong number of type arguments") + .span_label( + span, + &format!("{} {} type arguments, found {}", expected, required, supplied) + ) + .emit(); } else if supplied > accepted { - let expected = if required < accepted { - "expected at most" + let expected = if required == 0 { + "expected no".to_string() + } else if required < accepted { + format!("expected at most {}", accepted) } else { - "expected" + format!("expected {}", accepted) }; - span_err!(tcx.sess, span, E0244, - "wrong number of type arguments: {} {}, found {}", - expected, - accepted, - supplied); + + struct_span_err!(tcx.sess, span, E0244, "wrong number of type arguments") + .span_label( + span, + &format!("{} type arguments, found {}", expected, supplied) + ) + .emit(); } } diff --git a/src/test/compile-fail/E0243.rs b/src/test/compile-fail/E0243.rs index 8cc245c10cb..77c9856c261 100644 --- a/src/test/compile-fail/E0243.rs +++ b/src/test/compile-fail/E0243.rs @@ -9,7 +9,9 @@ // except according to those terms. struct Foo { x: T } -struct Bar { x: Foo } //~ ERROR E0243 +struct Bar { x: Foo } + //~^ ERROR E0243 + //~| NOTE expected 1 type arguments, found 0 fn main() { } diff --git a/src/test/compile-fail/E0244.rs b/src/test/compile-fail/E0244.rs index 4c574471092..5678a7fd450 100644 --- a/src/test/compile-fail/E0244.rs +++ b/src/test/compile-fail/E0244.rs @@ -9,7 +9,10 @@ // except according to those terms. struct Foo { x: bool } -struct Bar { x: Foo } //~ ERROR E0244 +struct Bar { x: Foo } + //~^ ERROR E0244 + //~| NOTE expected no type arguments, found 2 + fn main() { } diff --git a/src/test/compile-fail/generic-type-less-params-with-defaults.rs b/src/test/compile-fail/generic-type-less-params-with-defaults.rs index 37737fda474..d9ac715fa95 100644 --- a/src/test/compile-fail/generic-type-less-params-with-defaults.rs +++ b/src/test/compile-fail/generic-type-less-params-with-defaults.rs @@ -16,5 +16,7 @@ struct Vec( marker::PhantomData<(T,A)>); fn main() { - let _: Vec; //~ ERROR wrong number of type arguments: expected at least 1, found 0 + let _: Vec; + //~^ ERROR E0243 + //~| NOTE expected at least 1 type arguments, found 0 } diff --git a/src/test/compile-fail/generic-type-more-params-with-defaults.rs b/src/test/compile-fail/generic-type-more-params-with-defaults.rs index ad7e4f190c5..8f733ddfce1 100644 --- a/src/test/compile-fail/generic-type-more-params-with-defaults.rs +++ b/src/test/compile-fail/generic-type-more-params-with-defaults.rs @@ -17,5 +17,6 @@ struct Vec( fn main() { let _: Vec; - //~^ ERROR wrong number of type arguments: expected at most 2, found 3 + //~^ ERROR E0244 + //~| NOTE expected at most 2 type arguments, found 3 } diff --git a/src/test/compile-fail/issue-14092.rs b/src/test/compile-fail/issue-14092.rs index c87dcb8ae79..dd02fa7ac15 100644 --- a/src/test/compile-fail/issue-14092.rs +++ b/src/test/compile-fail/issue-14092.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn fn1(0: Box) {} //~ ERROR: wrong number of type arguments: expected 1, found 0 +fn fn1(0: Box) {} + //~^ ERROR E0243 + //~| NOTE expected 1 type arguments, found 0 fn main() {} diff --git a/src/test/compile-fail/issue-23024.rs b/src/test/compile-fail/issue-23024.rs index df2a70160f8..50f1323d39c 100644 --- a/src/test/compile-fail/issue-23024.rs +++ b/src/test/compile-fail/issue-23024.rs @@ -18,6 +18,11 @@ fn main() vfnfer.push(box h); println!("{:?}",(vfnfer[0] as Fn)(3)); //~^ ERROR the precise format of `Fn`-family traits' - //~| ERROR wrong number of type arguments: expected 1, found 0 + //~| ERROR E0243 + //~| NOTE expected 1 type arguments, found 0 //~| ERROR the value of the associated type `Output` (from the trait `std::ops::FnOnce`) + //~| NOTE in this expansion of println! + //~| NOTE in this expansion of println! + //~| NOTE in this expansion of println! + //~| NOTE in this expansion of println! } diff --git a/src/test/compile-fail/typeck-builtin-bound-type-parameters.rs b/src/test/compile-fail/typeck-builtin-bound-type-parameters.rs index fb6c43a1905..41242a44f58 100644 --- a/src/test/compile-fail/typeck-builtin-bound-type-parameters.rs +++ b/src/test/compile-fail/typeck-builtin-bound-type-parameters.rs @@ -9,20 +9,27 @@ // except according to those terms. fn foo1, U>(x: T) {} -//~^ ERROR: wrong number of type arguments: expected 0, found 1 +//~^ ERROR E0244 +//~| NOTE expected no type arguments, found 1 trait Trait: Copy {} -//~^ ERROR: wrong number of type arguments: expected 0, found 1 +//~^ ERROR E0244 +//~| NOTE expected no type arguments, found 1 struct MyStruct1>; -//~^ ERROR wrong number of type arguments: expected 0, found 1 +//~^ ERROR E0244 +//~| NOTE expected no type arguments, found 1 struct MyStruct2<'a, T: Copy<'a>>; //~^ ERROR: wrong number of lifetime parameters: expected 0, found 1 +//~| NOTE unexpected lifetime parameter + fn foo2<'a, T:Copy<'a, U>, U>(x: T) {} -//~^ ERROR: wrong number of type arguments: expected 0, found 1 -//~^^ ERROR: wrong number of lifetime parameters: expected 0, found 1 +//~^ ERROR E0244 +//~| NOTE expected no type arguments, found 1 +//~| ERROR: wrong number of lifetime parameters: expected 0, found 1 +//~| NOTE unexpected lifetime parameter fn main() { } diff --git a/src/test/compile-fail/typeck_type_placeholder_lifetime_1.rs b/src/test/compile-fail/typeck_type_placeholder_lifetime_1.rs index 2cb46cc352b..f60d925a748 100644 --- a/src/test/compile-fail/typeck_type_placeholder_lifetime_1.rs +++ b/src/test/compile-fail/typeck_type_placeholder_lifetime_1.rs @@ -17,5 +17,6 @@ struct Foo<'a, T:'a> { pub fn main() { let c: Foo<_, _> = Foo { r: &5 }; - //~^ ERROR wrong number of type arguments: expected 1, found 2 + //~^ ERROR E0244 + //~| NOTE expected 1 type arguments, found 2 } diff --git a/src/test/compile-fail/typeck_type_placeholder_lifetime_2.rs b/src/test/compile-fail/typeck_type_placeholder_lifetime_2.rs index 8178335de59..ec2675ece74 100644 --- a/src/test/compile-fail/typeck_type_placeholder_lifetime_2.rs +++ b/src/test/compile-fail/typeck_type_placeholder_lifetime_2.rs @@ -17,5 +17,6 @@ struct Foo<'a, T:'a> { pub fn main() { let c: Foo<_, usize> = Foo { r: &5 }; - //~^ ERROR wrong number of type arguments: expected 1, found 2 + //~^ ERROR E0244 + //~| NOTE expected 1 type arguments, found 2 } diff --git a/src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs b/src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs index 04bbfc445ed..12097576102 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs @@ -13,7 +13,8 @@ trait Trait {} fn f isize>(x: F) {} -//~^ ERROR wrong number of type arguments: expected 0, found 1 +//~^ ERROR E0244 +//~| NOTE expected no type arguments, found 1 //~| ERROR associated type `Output` not found fn main() {}