]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #58075 - asettouf:master, r=varkor
authorMazdak Farrokhzad <twingoow@gmail.com>
Wed, 27 Feb 2019 12:32:16 +0000 (13:32 +0100)
committerGitHub <noreply@github.com>
Wed, 27 Feb 2019 12:32:16 +0000 (13:32 +0100)
Fix for issue  #58050

Hi,

a quick PR to mention in the compiler error message that `?` is a macro operator, as according to issue #58050

It passed `python x.py test src/tools/tidy`  locally, as well as the recommendation to run `/x.py test src/test/ui --stage 1 --bless`.

Let me know if anything else is needed.

1  2 
src/libsyntax/ext/tt/quoted.rs

index 255795f28c7a34d2926326be5804d8fc2a8213b2,43d279980f6ea9eb9666531b32d85c35cefe3a09..b24edb57e527e4b09892ebc62d3a5d889ade6eb1
@@@ -1,14 -1,13 +1,14 @@@
 -use ast::NodeId;
 -use early_buffered_lints::BufferedEarlyLintId;
 -use ext::tt::macro_parser;
 -use feature_gate::Features;
 -use parse::{token, ParseSess};
 -use print::pprust;
 -use symbol::keywords;
 +use crate::ast::NodeId;
 +use crate::early_buffered_lints::BufferedEarlyLintId;
 +use crate::ext::tt::macro_parser;
 +use crate::feature_gate::Features;
 +use crate::parse::{token, ParseSess};
 +use crate::print::pprust;
 +use crate::tokenstream::{self, DelimSpan};
 +use crate::ast;
 +use crate::symbol::keywords;
 +
  use syntax_pos::{edition::Edition, BytePos, Span};
 -use tokenstream::{self, DelimSpan};
 -use ast;
  
  use rustc_data_structures::sync::Lrc;
  use std::iter::Peekable;
@@@ -22,17 -21,17 +22,17 @@@ pub struct Delimited 
  }
  
  impl Delimited {
 -    /// Return the opening delimiter (possibly `NoDelim`).
 +    /// Returns the opening delimiter (possibly `NoDelim`).
      pub fn open_token(&self) -> token::Token {
          token::OpenDelim(self.delim)
      }
  
 -    /// Return the closing delimiter (possibly `NoDelim`).
 +    /// Returns the closing delimiter (possibly `NoDelim`).
      pub fn close_token(&self) -> token::Token {
          token::CloseDelim(self.delim)
      }
  
 -    /// Return a `self::TokenTree` with a `Span` corresponding to the opening delimiter.
 +    /// Returns a `self::TokenTree` with a `Span` corresponding to the opening delimiter.
      pub fn open_tt(&self, span: Span) -> TokenTree {
          let open_span = if span.is_dummy() {
              span
@@@ -42,7 -41,7 +42,7 @@@
          TokenTree::Token(open_span, self.open_token())
      }
  
 -    /// Return a `self::TokenTree` with a `Span` corresponding to the closing delimiter.
 +    /// Returns a `self::TokenTree` with a `Span` corresponding to the closing delimiter.
      pub fn close_tt(&self, span: Span) -> TokenTree {
          let close_span = if span.is_dummy() {
              span
@@@ -107,7 -106,7 +107,7 @@@ impl TokenTree 
          }
      }
  
 -    /// Returns true if the given token tree contains no other tokens. This is vacuously true for
 +    /// Returns `true` if the given token tree contains no other tokens. This is vacuously true for
      /// single tokens or metavar/decls, but may be false for delimited trees or sequences.
      pub fn is_empty(&self) -> bool {
          match *self {
          }
      }
  
 -    /// Get the `index`-th sub-token-tree. This only makes sense for delimited trees and sequences.
 +    /// Gets the `index`-th sub-token-tree. This only makes sense for delimited trees and sequences.
      pub fn get_tt(&self, index: usize) -> TokenTree {
          match (self, index) {
              (&TokenTree::Delimited(_, ref delimed), _) if delimed.delim == token::NoDelim => {
          }
      }
  
 -    /// Retrieve the `TokenTree`'s span.
 +    /// Retrieves the `TokenTree`'s span.
      pub fn span(&self) -> Span {
          match *self {
              TokenTree::Token(sp, _)
@@@ -411,8 -410,8 +411,8 @@@ wher
  /// operator and separator, then a tuple with `(separator, KleeneOp)` is returned. Otherwise, an
  /// error with the appropriate span is emitted to `sess` and a dummy value is returned.
  ///
 -/// NOTE: In 2015 edition, * and + are the only Kleene operators and `?` is a separator. In 2018,
 -/// `?` is a Kleene op and not a separator.
 +/// N.B., in the 2015 edition, `*` and `+` are the only Kleene operators, and `?` is a separator.
 +/// In the 2018 edition however, `?` is a Kleene operator, and not a separator.
  fn parse_sep_and_kleene_op<I>(
      input: &mut Peekable<I>,
      span: Span,
@@@ -475,11 -474,13 +475,13 @@@ wher
                  // #1 is a separator and #2 should be a KleepeOp.
                  // (N.B. We need to advance the input iterator.)
                  match parse_kleene_op(input, span) {
-                     // #2 is `?`, which is not allowed as a Kleene op in 2015 edition.
+                     // #2 is `?`, which is not allowed as a Kleene op in 2015 edition,
+                     // but is allowed in the 2018 edition.
                      Ok(Ok((op, op2_span))) if op == KleeneOp::ZeroOrOne => {
                          sess.span_diagnostic
                              .struct_span_err(op2_span, "expected `*` or `+`")
-                             .note("`?` is not a macro repetition operator")
+                             .note("`?` is not a macro repetition operator in the 2015 edition, \
+                                  but is accepted in the 2018 edition")
                              .emit();
  
                          // Return a dummy
                      Err(_) => op1_span,
                  }
              } else {
-                 // `?` is not allowed as a Kleene op in 2015
+                 // `?` is not allowed as a Kleene op in 2015,
+                 // but is allowed in the 2018 edition
                  sess.span_diagnostic
                      .struct_span_err(op1_span, "expected `*` or `+`")
-                     .note("`?` is not a macro repetition operator")
+                     .note("`?` is not a macro repetition operator in the 2015 edition, \
+                          but is accepted in the 2018 edition")
                      .emit();
  
                  // Return a dummy
  
          // #1 is a separator followed by #2, a KleeneOp
          Ok(Err((tok, span))) => match parse_kleene_op(input, span) {
-             // #2 is a `?`, which is not allowed as a Kleene op in 2015 edition.
+             // #2 is a `?`, which is not allowed as a Kleene op in 2015 edition,
+             // but is allowed in the 2018 edition
              Ok(Ok((op, op2_span))) if op == KleeneOp::ZeroOrOne => {
                  sess.span_diagnostic
                      .struct_span_err(op2_span, "expected `*` or `+`")
-                     .note("`?` is not a macro repetition operator")
+                     .note("`?` is not a macro repetition operator in the 2015 edition, \
+                         but is accepted in the 2018 edition")
                      .emit();
  
                  // Return a dummy