mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
extract error_opt_out_lifetime
This commit is contained in:
parent
3f499a97e4
commit
b484faefab
@ -383,10 +383,7 @@ impl<'a> Parser<'a> {
|
||||
let is_negative = self.eat(&token::Not);
|
||||
let question = if self.eat(&token::Question) { Some(self.prev_span) } else { None };
|
||||
if self.token.is_lifetime() {
|
||||
if let Some(question_span) = question {
|
||||
self.span_err(question_span,
|
||||
"`?` may only modify trait bounds, not lifetime bounds");
|
||||
}
|
||||
self.error_opt_out_lifetime(question);
|
||||
bounds.push(GenericBound::Outlives(self.expect_lifetime()));
|
||||
if has_parens {
|
||||
let inner_span = inner_lo.to(self.prev_span);
|
||||
@ -473,6 +470,13 @@ impl<'a> Parser<'a> {
|
||||
return Ok(bounds);
|
||||
}
|
||||
|
||||
fn error_opt_out_lifetime(&self, question: Option<Span>) {
|
||||
if let Some(span) = question {
|
||||
self.struct_span_err(span, "`?` may only modify trait bounds, not lifetime bounds")
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn parse_late_bound_lifetime_defs(&mut self) -> PResult<'a, Vec<GenericParam>> {
|
||||
if self.eat_keyword(kw::For) {
|
||||
self.expect_lt()?;
|
||||
|
Loading…
Reference in New Issue
Block a user