提交 1a819a22 编写于 作者: S sinkuu

Make E0243/0244 message consistent with E0107

上级 3fc8304f
......@@ -2245,27 +2245,32 @@ fn check_type_argument_count(tcx: TyCtxt, span: Span, supplied: usize,
"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 argument{}, found {}",
expected, required, arguments_plural, supplied)
)
struct_span_err!(tcx.sess, span, E0243,
"wrong number of type arguments: {} {}, found {}",
expected, required, supplied)
.span_label(span,
&format!("{} {} type argument{}",
expected,
required,
arguments_plural))
.emit();
} else if supplied > accepted {
let expected = if required == 0 {
"expected no".to_string()
} else if required < accepted {
let expected = if required < accepted {
format!("expected at most {}", accepted)
} else {
format!("expected {}", accepted)
};
let arguments_plural = if accepted == 1 { "" } else { "s" };
struct_span_err!(tcx.sess, span, E0244, "wrong number of type arguments")
struct_span_err!(tcx.sess, span, E0244,
"wrong number of type arguments: {}, found {}",
expected, supplied)
.span_label(
span,
&format!("{} type argument{}, found {}", expected, arguments_plural, supplied)
&format!("{} type argument{}",
if accepted == 0 { "expected no" } else { &expected },
arguments_plural)
)
.emit();
}
......
......@@ -10,8 +10,8 @@
struct Foo<T> { x: T }
struct Bar { x: Foo }
//~^ ERROR E0243
//~| NOTE expected 1 type argument, found 0
//~^ ERROR wrong number of type arguments: expected 1, found 0 [E0243]
//~| NOTE expected 1 type argument
fn main() {
}
......@@ -10,8 +10,8 @@
struct Foo { x: bool }
struct Bar<S, T> { x: Foo<S, T> }
//~^ ERROR E0244
//~| NOTE expected no type arguments, found 2
//~^ ERROR wrong number of type arguments: expected 0, found 2 [E0244]
//~| NOTE expected no type arguments
fn main() {
......
......@@ -17,6 +17,6 @@ struct Vec<T, A = Heap>(
fn main() {
let _: Vec;
//~^ ERROR E0243
//~| NOTE expected at least 1 type argument, found 0
//~^ ERROR wrong number of type arguments: expected at least 1, found 0 [E0243]
//~| NOTE expected at least 1 type argument
}
......@@ -17,6 +17,6 @@ struct Vec<T, A = Heap>(
fn main() {
let _: Vec<isize, Heap, bool>;
//~^ ERROR E0244
//~| NOTE expected at most 2 type arguments, found 3
//~^ ERROR wrong number of type arguments: expected at most 2, found 3 [E0244]
//~| NOTE expected at most 2 type arguments
}
......@@ -9,7 +9,7 @@
// except according to those terms.
fn fn1(0: Box) {}
//~^ ERROR E0243
//~| NOTE expected 1 type argument, found 0
//~^ ERROR wrong number of type arguments: expected 1, found 0 [E0243]
//~| NOTE expected 1 type argument
fn main() {}
......@@ -18,6 +18,6 @@ fn h(x:i32) -> i32 {3*x}
vfnfer.push(box h);
println!("{:?}",(vfnfer[0] as Fn)(3));
//~^ ERROR the precise format of `Fn`-family traits'
//~| ERROR E0243
//~| ERROR wrong number of type arguments: expected 1, found 0 [E0243]
//~| ERROR the value of the associated type `Output` (from the trait `std::ops::FnOnce`)
}
......@@ -9,16 +9,16 @@
// except according to those terms.
fn foo1<T:Copy<U>, U>(x: T) {}
//~^ ERROR E0244
//~| NOTE expected no type arguments, found 1
//~^ ERROR wrong number of type arguments: expected 0, found 1 [E0244]
//~| NOTE expected no type arguments
trait Trait: Copy<Send> {}
//~^ ERROR E0244
//~| NOTE expected no type arguments, found 1
//~^ ERROR wrong number of type arguments: expected 0, found 1 [E0244]
//~| NOTE expected no type arguments
struct MyStruct1<T: Copy<T>>;
//~^ ERROR E0244
//~| NOTE expected no type arguments, found 1
//~^ ERROR wrong number of type arguments: expected 0, found 1 [E0244]
//~| NOTE expected no type arguments
struct MyStruct2<'a, T: Copy<'a>>;
//~^ ERROR: wrong number of lifetime parameters: expected 0, found 1
......@@ -26,8 +26,8 @@ trait Trait: Copy<Send> {}
fn foo2<'a, T:Copy<'a, U>, U>(x: T) {}
//~^ ERROR E0244
//~| NOTE expected no type arguments, found 1
//~^ ERROR wrong number of type arguments: expected 0, found 1 [E0244]
//~| NOTE expected no type arguments
//~| ERROR: wrong number of lifetime parameters: expected 0, found 1
//~| NOTE unexpected lifetime parameter
......
......@@ -17,6 +17,6 @@ struct Foo<'a, T:'a> {
pub fn main() {
let c: Foo<_, _> = Foo { r: &5 };
//~^ ERROR E0244
//~| NOTE expected 1 type argument, found 2
//~^ ERROR wrong number of type arguments: expected 1, found 2 [E0244]
//~| NOTE expected 1 type argument
}
......@@ -17,6 +17,6 @@ struct Foo<'a, T:'a> {
pub fn main() {
let c: Foo<_, usize> = Foo { r: &5 };
//~^ ERROR E0244
//~| NOTE expected 1 type argument, found 2
//~^ ERROR wrong number of type arguments: expected 1, found 2 [E0244]
//~| NOTE expected 1 type argument
}
......@@ -13,8 +13,8 @@
trait Trait {}
fn f<F:Trait(isize) -> isize>(x: F) {}
//~^ ERROR E0244
//~| NOTE expected no type arguments, found 1
//~^ ERROR wrong number of type arguments: expected 0, found 1 [E0244]
//~| NOTE expected no type arguments
//~| ERROR E0220
//~| NOTE associated type `Output` not found
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册