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:
commit
b053da3a68
2 changed files with 33 additions and 6 deletions
|
@ -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) {
|
fn report_lifetime_number_error(tcx: TyCtxt, span: Span, number: usize, expected: usize) {
|
||||||
span_err!(tcx.sess, span, E0107,
|
let label = if number < expected {
|
||||||
"wrong number of lifetime parameters: expected {}, found {}",
|
if expected == 1 {
|
||||||
expected, number);
|
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
|
// A helper struct for conveniently grouping a set of bounds which we pass to
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
struct Foo<'a>(&'a str);
|
struct Foo<'a>(&'a str);
|
||||||
|
struct Buzz<'a, 'b>(&'a str, &'b str);
|
||||||
|
|
||||||
enum Bar {
|
enum Bar {
|
||||||
A,
|
A,
|
||||||
|
@ -16,9 +17,19 @@ enum Bar {
|
||||||
C,
|
C,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Baz<'a> {
|
struct Baz<'a, 'b, 'c> {
|
||||||
foo: Foo, //~ ERROR E0107
|
foo: Foo,
|
||||||
bar: Bar<'a>, //~ ERROR E0107
|
//~^ 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() {
|
fn main() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue