about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-12-08 09:18:34 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2019-12-21 19:20:41 +0100
commitb484faefab8bfd27d7ccf28aa5597e85591d2a90 (patch)
treeec33f47566f5adeb27f85e2799f54ee839eceb2e /src
parent3f499a97e43b9f1cd23233de542419921ea4b6d0 (diff)
downloadrust-b484faefab8bfd27d7ccf28aa5597e85591d2a90.tar.gz
rust-b484faefab8bfd27d7ccf28aa5597e85591d2a90.zip
extract error_opt_out_lifetime
Diffstat (limited to 'src')
-rw-r--r--src/librustc_parse/parser/ty.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/librustc_parse/parser/ty.rs b/src/librustc_parse/parser/ty.rs
index a4c1f530ef8..b9537100ce1 100644
--- a/src/librustc_parse/parser/ty.rs
+++ b/src/librustc_parse/parser/ty.rs
@@ -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()?;