Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2f5294e
Fixes #35304
mikhail-m1 Aug 5, 2016
e7e5cfe
Merge branch 'master' of https://github.com/rust-lang/rust
mikhail-m1 Aug 5, 2016
424e772
Add error code check in librustc_const_eval/diagnostics.rs
GuillaumeGomez Aug 5, 2016
5bab0e6
Update E0206 message to new format
KiChjang Aug 5, 2016
065c685
Update E0223 to the new format
KiChjang Aug 6, 2016
c9e9d42
Update compiler error 0027 to use new error format.
silenuss Aug 6, 2016
1d25e2e
Update compiler error 0029 to use new error format.
silenuss Aug 6, 2016
f4dd1f9
Updated error message E0252
Aug 5, 2016
eb469d6
Updated E0225 to new format.
razielgn Aug 6, 2016
4e2dd8d
Add new error code tests
GuillaumeGomez Aug 5, 2016
24ddca0
Update error message for E0243 and E0244
Aug 6, 2016
fbd7c55
Rollup merge of #35362 - medzin:E0252, r=GuillaumeGomez
Aug 6, 2016
edd8e04
Rollup merge of #35393 - GuillaumeGomez:err_codes2, r=jonathandturner
Aug 6, 2016
5e84fc4
Rollup merge of #35394 - mikhail-m1:master, r=jonathandturner
Aug 6, 2016
ae59b96
Rollup merge of #35402 - KiChjang:e0206-new-msg, r=GuillaumeGomez
Aug 6, 2016
2fd369f
Rollup merge of #35410 - silenuss:e0027-formatting, r=jonathandturner
Aug 6, 2016
388e7d6
Rollup merge of #35411 - KiChjang:e0223-new-format, r=jonathandturner
Aug 6, 2016
32de7ca
Rollup merge of #35413 - silenuss:e0029-formatting, r=jonathandturner
Aug 6, 2016
14163fa
Rollup merge of #35419 - Keats:err-243, r=jonathandturner
Aug 6, 2016
11022b4
Rollup merge of #35421 - razielgn:updated-e0225-to-new-format, r=jona…
Aug 6, 2016
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
Prev Previous commit
Next Next commit
Update error message for E0243 and E0244
  • Loading branch information
Vincent Prouillet committed Aug 6, 2016
commit 24ddca05e75ab16fec6bbe009eabc3420eb68e78
29 changes: 18 additions & 11 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2248,20 +2248,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();
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0243.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
// except according to those terms.

struct Foo<T> { x: T }
struct Bar { x: Foo } //~ ERROR E0243
struct Bar { x: Foo }
//~^ ERROR E0243
//~| NOTE expected 1 type arguments, found 0

fn main() {
}
5 changes: 4 additions & 1 deletion src/test/compile-fail/E0244.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
// except according to those terms.

struct Foo { x: bool }
struct Bar<S, T> { x: Foo<S, T> } //~ ERROR E0244
struct Bar<S, T> { x: Foo<S, T> }
//~^ ERROR E0244
//~| NOTE expected no type arguments, found 2


fn main() {
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ struct Vec<T, A = Heap>(
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
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ struct Vec<T, A = Heap>(

fn main() {
let _: Vec<isize, Heap, bool>;
//~^ ERROR wrong number of type arguments: expected at most 2, found 3
//~^ ERROR E0244
//~| NOTE expected at most 2 type arguments, found 3
}
4 changes: 3 additions & 1 deletion src/test/compile-fail/issue-14092.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
7 changes: 6 additions & 1 deletion src/test/compile-fail/issue-23024.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!
}
15 changes: 10 additions & 5 deletions src/test/compile-fail/typeck-builtin-bound-type-parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,25 @@
// except according to those terms.

fn foo1<T:Copy<U>, 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<Send> {}
//~^ ERROR: wrong number of type arguments: expected 0, found 1
//~^ ERROR E0244
//~| NOTE expected no type arguments, found 1

struct MyStruct1<T: Copy<T>>;
//~^ 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


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

fn main() {
}
3 changes: 2 additions & 1 deletion src/test/compile-fail/typeck_type_placeholder_lifetime_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 2 additions & 1 deletion src/test/compile-fail/typeck_type_placeholder_lifetime_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 2 additions & 1 deletion src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
trait Trait {}

fn f<F:Trait(isize) -> 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() {}