Skip to content

Commit e8673ff

Browse files
Rollup merge of rust-lang#37835 - ojsheikh:E0088, r=jonathandturner
Update E0088 to new error format Fixes rust-lang#35226 which is part of rust-lang#35233. Is based on rust-lang#36208 from @yossi-k. r? @jonathandturner
2 parents 224f2ce + 92abce2 commit e8673ff

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/librustc_typeck/check/mod.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -4436,19 +4436,20 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
44364436
let lifetime_defs = segment.map_or(&[][..], |(_, generics)| &generics.regions);
44374437
if lifetimes.len() > lifetime_defs.len() {
44384438
let span = lifetimes[lifetime_defs.len()].span;
4439-
span_err!(self.tcx.sess, span, E0088,
4440-
"too many lifetime parameters provided: \
4441-
expected {}, found {}",
4442-
count(lifetime_defs.len()),
4443-
count(lifetimes.len()));
4444-
} else if lifetimes.len() > 0 && lifetimes.len() < lifetime_defs.len() {
4445-
span_err!(self.tcx.sess, span, E0090,
4446-
"too few lifetime parameters provided: \
4447-
expected {}, found {}",
4448-
count(lifetime_defs.len()),
4449-
count(lifetimes.len()));
4439+
struct_span_err!(self.tcx.sess, span, E0088,
4440+
"too many lifetime parameters provided: \
4441+
expected {}, found {}",
4442+
count(lifetime_defs.len()),
4443+
count(lifetimes.len()))
4444+
.span_label(span, &format!("unexpected lifetime parameter{}",
4445+
match lifetimes.len() { 1 => "", _ => "s" }))
4446+
.emit();
44504447
}
44514448

4449+
// The case where there is not enough lifetime parameters is not checked,
4450+
// because this is not possible - a function never takes lifetime parameters.
4451+
// See discussion for Pull Request 36208.
4452+
44524453
// Check provided type parameters.
44534454
let type_defs = segment.map_or(&[][..], |(_, generics)| {
44544455
if generics.parent.is_none() {

src/test/compile-fail/E0088.rs

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

1111
fn f() {}
12+
fn g<'a>() {}
1213

1314
fn main() {
1415
f::<'static>(); //~ ERROR E0088
16+
//~^ unexpected lifetime parameter
17+
18+
g::<'static, 'static>(); //~ ERROR E0088
19+
//~^ unexpected lifetime parameters
1520
}

0 commit comments

Comments
 (0)