Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update E0088 to new format #36208

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 19 additions & 12 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4324,20 +4324,27 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// Check provided lifetime parameters.
let lifetime_defs = segment.map_or(&[][..], |(_, generics)| &generics.regions);
if lifetimes.len() > lifetime_defs.len() {
let span = lifetimes[lifetime_defs.len()].span;
span_err!(self.tcx.sess, span, E0088,
"too many lifetime parameters provided: \
expected {}, found {}",
count(lifetime_defs.len()),
count(lifetimes.len()));
} else if lifetimes.len() > 0 && lifetimes.len() < lifetime_defs.len() {
span_err!(self.tcx.sess, span, E0090,
"too few lifetime parameters provided: \
expected {}, found {}",
count(lifetime_defs.len()),
count(lifetimes.len()));
let span = lifetimes[..].into_iter().skip(1).map(|lft| lft.span)
.fold(lifetimes[0].span, |acc, n| Span {
expn_id: acc.expn_id,
lo: acc.lo,
hi: n.hi,
});

struct_span_err!(self.tcx.sess, span, E0088,
"too many lifetime parameters provided: \
expected {}, found {}",
count(lifetime_defs.len()),
count(lifetimes.len()))
.span_label(span, &format!("unexpected lifetime parameter{}",
match lifetimes.len() { 1 => "", _ => "s" }))
.emit();
}

// The case where there is not enough lifetime parameters is not checked,
// because this is not possible - a function never takes lifetime parameters.
// See discussion for Pull Request 36208.

// Check provided type parameters.
let type_defs = segment.map_or(&[][..], |(_, generics)| {
if generics.parent.is_none() {
Expand Down
5 changes: 5 additions & 0 deletions src/test/compile-fail/E0088.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
// except according to those terms.

fn f() {}
fn g<'a>() {}

fn main() {
f::<'static>(); //~ ERROR E0088
//~^ unexpected lifetime parameter

g::<'static, 'static>(); //~ ERROR E0088
//~^ unexpected lifetime parameters
}