Skip to content

Commit 2da9967

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#35419 - Keats:err-243, r=jonathandturner
Update error message for E0243 and E0244 Fixes rust-lang#35389 and rust-lang#35390 as part of rust-lang#35233. r? @jonathandturner
2 parents 350125b + 02f3609 commit 2da9967

11 files changed

+57
-25
lines changed

src/librustc_typeck/astconv.rs

+18-11
Original file line numberDiff line numberDiff line change
@@ -2261,20 +2261,27 @@ fn check_type_argument_count(tcx: TyCtxt, span: Span, supplied: usize,
22612261
} else {
22622262
"expected"
22632263
};
2264-
span_err!(tcx.sess, span, E0243,
2265-
"wrong number of type arguments: {} {}, found {}",
2266-
expected, required, supplied);
2264+
struct_span_err!(tcx.sess, span, E0243, "wrong number of type arguments")
2265+
.span_label(
2266+
span,
2267+
&format!("{} {} type arguments, found {}", expected, required, supplied)
2268+
)
2269+
.emit();
22672270
} else if supplied > accepted {
2268-
let expected = if required < accepted {
2269-
"expected at most"
2271+
let expected = if required == 0 {
2272+
"expected no".to_string()
2273+
} else if required < accepted {
2274+
format!("expected at most {}", accepted)
22702275
} else {
2271-
"expected"
2276+
format!("expected {}", accepted)
22722277
};
2273-
span_err!(tcx.sess, span, E0244,
2274-
"wrong number of type arguments: {} {}, found {}",
2275-
expected,
2276-
accepted,
2277-
supplied);
2278+
2279+
struct_span_err!(tcx.sess, span, E0244, "wrong number of type arguments")
2280+
.span_label(
2281+
span,
2282+
&format!("{} type arguments, found {}", expected, supplied)
2283+
)
2284+
.emit();
22782285
}
22792286
}
22802287

src/test/compile-fail/E0243.rs

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

1111
struct Foo<T> { x: T }
12-
struct Bar { x: Foo } //~ ERROR E0243
12+
struct Bar { x: Foo }
13+
//~^ ERROR E0243
14+
//~| NOTE expected 1 type arguments, found 0
1315

1416
fn main() {
1517
}

src/test/compile-fail/E0244.rs

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

1111
struct Foo { x: bool }
12-
struct Bar<S, T> { x: Foo<S, T> } //~ ERROR E0244
12+
struct Bar<S, T> { x: Foo<S, T> }
13+
//~^ ERROR E0244
14+
//~| NOTE expected no type arguments, found 2
15+
1316

1417
fn main() {
1518
}

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ struct Vec<T, A = Heap>(
1616
marker::PhantomData<(T,A)>);
1717

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

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

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

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

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

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

1315
fn main() {}

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ 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 wrong number of type arguments: expected 1, found 0
21+
//~| ERROR E0243
22+
//~| NOTE expected 1 type arguments, found 0
2223
//~| ERROR the value of the associated type `Output` (from the trait `std::ops::FnOnce`)
24+
//~| NOTE in this expansion of println!
25+
//~| NOTE in this expansion of println!
26+
//~| NOTE in this expansion of println!
27+
//~| NOTE in this expansion of println!
2328
}

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

+12-5
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,27 @@
99
// except according to those terms.
1010

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

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

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

2023
struct MyStruct2<'a, T: Copy<'a>>;
2124
//~^ ERROR: wrong number of lifetime parameters: expected 0, found 1
25+
//~| NOTE unexpected lifetime parameter
26+
2227

2328
fn foo2<'a, T:Copy<'a, U>, U>(x: T) {}
24-
//~^ ERROR: wrong number of type arguments: expected 0, found 1
25-
//~^^ ERROR: wrong number of lifetime parameters: expected 0, found 1
29+
//~^ ERROR E0244
30+
//~| NOTE expected no type arguments, found 1
31+
//~| ERROR: wrong number of lifetime parameters: expected 0, found 1
32+
//~| NOTE unexpected lifetime parameter
2633

2734
fn main() {
2835
}

src/test/compile-fail/typeck_type_placeholder_lifetime_1.rs

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

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

src/test/compile-fail/typeck_type_placeholder_lifetime_2.rs

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

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

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

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

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

1920
fn main() {}

0 commit comments

Comments
 (0)