Skip to content

Commit 8e8ac02

Browse files
committed
extract error_opt_out_lifetime
1 parent 3b63465 commit 8e8ac02

File tree

1 file changed

+8
-4
lines changed
  • src/librustc_parse/parser

1 file changed

+8
-4
lines changed

src/librustc_parse/parser/ty.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,7 @@ impl<'a> Parser<'a> {
383383
let is_negative = self.eat(&token::Not);
384384
let question = if self.eat(&token::Question) { Some(self.prev_span) } else { None };
385385
if self.token.is_lifetime() {
386-
if let Some(question_span) = question {
387-
self.span_err(question_span,
388-
"`?` may only modify trait bounds, not lifetime bounds");
389-
}
386+
self.error_opt_out_lifetime(question);
390387
bounds.push(GenericBound::Outlives(self.expect_lifetime()));
391388
if has_parens {
392389
let inner_span = inner_lo.to(self.prev_span);
@@ -473,6 +470,13 @@ impl<'a> Parser<'a> {
473470
return Ok(bounds);
474471
}
475472

473+
fn error_opt_out_lifetime(&self, question: Option<Span>) {
474+
if let Some(span) = question {
475+
self.struct_span_err(span, "`?` may only modify trait bounds, not lifetime bounds")
476+
.emit();
477+
}
478+
}
479+
476480
pub(super) fn parse_late_bound_lifetime_defs(&mut self) -> PResult<'a, Vec<GenericParam>> {
477481
if self.eat_keyword(kw::For) {
478482
self.expect_lt()?;

0 commit comments

Comments
 (0)