Skip to content

Commit 008e239

Browse files
committed
Auto merge of #38859 - jonathandturner:E0088_fix, r=eddyb
E0088/E0090 fix This fixes an issue reported by @eddyb (#36208 (comment)) where the check for "too few lifetime parameters" was removed in one of the error message PRs. I also removed the span shrinking from E0088, as early bound lifetimes give you a confusing underline in some cases. r=eddyb
2 parents b6c97c3 + 33bb471 commit 008e239

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/librustc_typeck/check/mod.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -4565,7 +4565,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
45654565
// Check provided lifetime parameters.
45664566
let lifetime_defs = segment.map_or(&[][..], |(_, generics)| &generics.regions);
45674567
if lifetimes.len() > lifetime_defs.len() {
4568-
let span = lifetimes[lifetime_defs.len()].span;
45694568
struct_span_err!(self.tcx.sess, span, E0088,
45704569
"too many lifetime parameters provided: \
45714570
expected {}, found {}",
@@ -4574,6 +4573,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
45744573
.span_label(span, &format!("unexpected lifetime parameter{}",
45754574
match lifetimes.len() { 1 => "", _ => "s" }))
45764575
.emit();
4576+
} else if lifetimes.len() > 0 && lifetimes.len() < lifetime_defs.len() {
4577+
struct_span_err!(self.tcx.sess, span, E0090,
4578+
"too few lifetime parameters provided: \
4579+
expected {}, found {}",
4580+
count(lifetime_defs.len()),
4581+
count(lifetimes.len()))
4582+
.span_label(span, &format!("too few lifetime parameters"))
4583+
.emit();
45774584
}
45784585

45794586
// The case where there is not enough lifetime parameters is not checked,

src/test/compile-fail/E0090.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn foo<'a: 'b, 'b: 'a>() {}
12+
fn main() {
13+
foo::<'static>();//~ ERROR E0090
14+
//~^ too few lifetime parameters
15+
}

0 commit comments

Comments
 (0)