Rollup merge of #35373 - oijazsh:E0107, r=jonathandturner

Update E0107 message to new format

Fixes #35246 as part of #35233.

r? @jonathandturner
This commit is contained in:
Eduard-Mihai Burtescu 2016-08-06 15:01:22 +03:00 committed by GitHub
commit b053da3a68
2 changed files with 33 additions and 6 deletions

View File

@ -2273,9 +2273,25 @@ fn check_type_argument_count(tcx: TyCtxt, span: Span, supplied: usize,
}
fn report_lifetime_number_error(tcx: TyCtxt, span: Span, number: usize, expected: usize) {
span_err!(tcx.sess, span, E0107,
"wrong number of lifetime parameters: expected {}, found {}",
expected, number);
let label = if number < expected {
if expected == 1 {
format!("expected {} lifetime parameter", expected)
} else {
format!("expected {} lifetime parameters", expected)
}
} else {
let additional = number - expected;
if additional == 1 {
"unexpected lifetime parameter".to_string()
} else {
format!("{} unexpected lifetime parameters", additional)
}
};
struct_span_err!(tcx.sess, span, E0107,
"wrong number of lifetime parameters: expected {}, found {}",
expected, number)
.span_label(span, &label)
.emit();
}
// A helper struct for conveniently grouping a set of bounds which we pass to

View File

@ -9,6 +9,7 @@
// except according to those terms.
struct Foo<'a>(&'a str);
struct Buzz<'a, 'b>(&'a str, &'b str);
enum Bar {
A,
@ -16,9 +17,19 @@ enum Bar {
C,
}
struct Baz<'a> {
foo: Foo, //~ ERROR E0107
bar: Bar<'a>, //~ ERROR E0107
struct Baz<'a, 'b, 'c> {
foo: Foo,
//~^ ERROR E0107
//~| expected 1 lifetime parameter
buzz: Buzz<'a>,
//~^ ERROR E0107
//~| expected 2 lifetime parameters
bar: Bar<'a>,
//~^ ERROR E0107
//~| unexpected lifetime parameter
foo2: Foo<'a, 'b, 'c>,
//~^ ERROR E0107
//~| 2 unexpected lifetime parameters
}
fn main() {