about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-09-25 14:27:08 +0000
committerbors <bors@rust-lang.org>2019-09-25 14:27:08 +0000
commit6c2c29c43206d6e2f1091fa278d2792ea10e3659 (patch)
tree8cfaca24961df42b0c4f69dd214d1b9e552ce7d4 /src/libsyntax
parentacf7b50c737cfb8f4003477559305bedf3c316fe (diff)
parent1e8dd3756171a8a01f3951d61ff6ba8d1ef5bd7d (diff)
downloadrust-6c2c29c43206d6e2f1091fa278d2792ea10e3659.tar.gz
rust-6c2c29c43206d6e2f1091fa278d2792ea10e3659.zip
Auto merge of #64766 - Centril:rollup-gdy5jr6, r=Centril
Rollup of 6 pull requests

Successful merges:

 - #62975 (Almost fully deprecate hir::map::Map.hir_to_node_id)
 - #64386 (use `sign` variable in abs and wrapping_abs methods)
 - #64508 (or-patterns: Push `PatKind/PatternKind::Or` at top level to HIR & HAIR)
 - #64738 (Add const-eval support for SIMD types, insert, and extract)
 - #64759 (Refactor mbe a tiny bit)
 - #64764 (Master is now 1.40 )

Failed merges:

r? @ghost
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ext/mbe/macro_parser.rs12
-rw-r--r--src/libsyntax/ext/mbe/macro_rules.rs23
-rw-r--r--src/libsyntax/ext/mbe/quoted.rs31
-rw-r--r--src/libsyntax/lib.rs1
-rw-r--r--src/libsyntax/visit.rs2
5 files changed, 18 insertions, 51 deletions
diff --git a/src/libsyntax/ext/mbe/macro_parser.rs b/src/libsyntax/ext/mbe/macro_parser.rs
index b51384d3b15..8f49ba9572d 100644
--- a/src/libsyntax/ext/mbe/macro_parser.rs
+++ b/src/libsyntax/ext/mbe/macro_parser.rs
@@ -413,18 +413,6 @@ fn nameize<I: Iterator<Item = NamedMatch>>(
     Success(ret_val)
 }
 
-/// Generates an appropriate parsing failure message. For EOF, this is "unexpected end...". For
-/// other tokens, this is "unexpected token...".
-crate fn parse_failure_msg(tok: &Token) -> String {
-    match tok.kind {
-        token::Eof => "unexpected end of macro invocation".to_string(),
-        _ => format!(
-            "no rules expected the token `{}`",
-            pprust::token_to_string(tok)
-        ),
-    }
-}
-
 /// Performs a token equality check, ignoring syntax context (that is, an unhygienic comparison)
 fn token_name_eq(t1: &Token, t2: &Token) -> bool {
     if let (Some((ident1, is_raw1)), Some((ident2, is_raw2))) = (t1.ident(), t2.ident()) {
diff --git a/src/libsyntax/ext/mbe/macro_rules.rs b/src/libsyntax/ext/mbe/macro_rules.rs
index 816baadb12f..c24f6a66603 100644
--- a/src/libsyntax/ext/mbe/macro_rules.rs
+++ b/src/libsyntax/ext/mbe/macro_rules.rs
@@ -6,7 +6,7 @@ use crate::ext::base::{SyntaxExtension, SyntaxExtensionKind};
 use crate::ext::expand::{AstFragment, AstFragmentKind};
 use crate::ext::mbe;
 use crate::ext::mbe::macro_check;
-use crate::ext::mbe::macro_parser::{parse, parse_failure_msg};
+use crate::ext::mbe::macro_parser::parse;
 use crate::ext::mbe::macro_parser::{Error, Failure, Success};
 use crate::ext::mbe::macro_parser::{MatchedNonterminal, MatchedSeq, NamedParseResult};
 use crate::ext::mbe::transcribe::transcribe;
@@ -15,6 +15,7 @@ use crate::parse::parser::Parser;
 use crate::parse::token::TokenKind::*;
 use crate::parse::token::{self, NtTT, Token};
 use crate::parse::{Directory, ParseSess};
+use crate::print::pprust;
 use crate::symbol::{kw, sym, Symbol};
 use crate::tokenstream::{DelimSpan, TokenStream, TokenTree};
 
@@ -371,10 +372,6 @@ pub fn compile_declarative_macro(
                             tt.clone().into(),
                             true,
                             sess,
-                            features,
-                            &def.attrs,
-                            edition,
-                            def.id,
                         )
                         .pop()
                         .unwrap();
@@ -398,10 +395,6 @@ pub fn compile_declarative_macro(
                             tt.clone().into(),
                             false,
                             sess,
-                            features,
-                            &def.attrs,
-                            edition,
-                            def.id,
                         )
                         .pop()
                         .unwrap();
@@ -1184,3 +1177,15 @@ impl TokenTree {
         parse(cx.parse_sess(), tts, mtch, Some(directory), true)
     }
 }
+
+/// Generates an appropriate parsing failure message. For EOF, this is "unexpected end...". For
+/// other tokens, this is "unexpected token...".
+fn parse_failure_msg(tok: &Token) -> String {
+    match tok.kind {
+        token::Eof => "unexpected end of macro invocation".to_string(),
+        _ => format!(
+            "no rules expected the token `{}`",
+            pprust::token_to_string(tok),
+        ),
+    }
+}
diff --git a/src/libsyntax/ext/mbe/quoted.rs b/src/libsyntax/ext/mbe/quoted.rs
index 3952e29a5f0..8cb85bdef76 100644
--- a/src/libsyntax/ext/mbe/quoted.rs
+++ b/src/libsyntax/ext/mbe/quoted.rs
@@ -1,18 +1,15 @@
 use crate::ast;
-use crate::ast::NodeId;
 use crate::ext::mbe::macro_parser;
 use crate::ext::mbe::{TokenTree, KleeneOp, KleeneToken, SequenceRepetition, Delimited};
-use crate::feature_gate::Features;
 use crate::parse::token::{self, Token};
 use crate::parse::ParseSess;
 use crate::print::pprust;
 use crate::symbol::kw;
 use crate::tokenstream;
 
-use syntax_pos::{edition::Edition, Span};
+use syntax_pos::Span;
 
 use rustc_data_structures::sync::Lrc;
-use std::iter::Peekable;
 
 /// Takes a `tokenstream::TokenStream` and returns a `Vec<self::TokenTree>`. Specifically, this
 /// takes a generic `TokenStream`, such as is used in the rest of the compiler, and returns a
@@ -39,17 +36,13 @@ pub(super) fn parse(
     input: tokenstream::TokenStream,
     expect_matchers: bool,
     sess: &ParseSess,
-    features: &Features,
-    attrs: &[ast::Attribute],
-    edition: Edition,
-    macro_node_id: NodeId,
 ) -> Vec<TokenTree> {
     // Will contain the final collection of `self::TokenTree`
     let mut result = Vec::new();
 
     // For each token tree in `input`, parse the token into a `self::TokenTree`, consuming
     // additional trees if need be.
-    let mut trees = input.trees().peekable();
+    let mut trees = input.trees();
     while let Some(tree) = trees.next() {
         // Given the parsed tree, if there is a metavar and we are expecting matchers, actually
         // parse out the matcher (i.e., in `$id:ident` this would parse the `:` and `ident`).
@@ -58,10 +51,6 @@ pub(super) fn parse(
             &mut trees,
             expect_matchers,
             sess,
-            features,
-            attrs,
-            edition,
-            macro_node_id,
         );
         match tree {
             TokenTree::MetaVar(start_sp, ident) if expect_matchers => {
@@ -109,13 +98,9 @@ pub(super) fn parse(
 ///   unstable features or not.
 fn parse_tree(
     tree: tokenstream::TokenTree,
-    trees: &mut Peekable<impl Iterator<Item = tokenstream::TokenTree>>,
+    trees: &mut impl Iterator<Item = tokenstream::TokenTree>,
     expect_matchers: bool,
     sess: &ParseSess,
-    features: &Features,
-    attrs: &[ast::Attribute],
-    edition: Edition,
-    macro_node_id: NodeId,
 ) -> TokenTree {
     // Depending on what `tree` is, we could be parsing different parts of a macro
     match tree {
@@ -135,10 +120,6 @@ fn parse_tree(
                     tts.into(),
                     expect_matchers,
                     sess,
-                    features,
-                    attrs,
-                    edition,
-                    macro_node_id,
                 );
                 // Get the Kleene operator and optional separator
                 let (separator, kleene) = parse_sep_and_kleene_op(trees, span.entire(), sess);
@@ -192,10 +173,6 @@ fn parse_tree(
                     tts.into(),
                     expect_matchers,
                     sess,
-                    features,
-                    attrs,
-                    edition,
-                    macro_node_id,
                 ),
             }),
         ),
@@ -244,7 +221,7 @@ fn parse_kleene_op(
 /// 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.
 fn parse_sep_and_kleene_op(
-    input: &mut Peekable<impl Iterator<Item = tokenstream::TokenTree>>,
+    input: &mut impl Iterator<Item = tokenstream::TokenTree>,
     span: Span,
     sess: &ParseSess,
 ) -> (Option<Token>, KleeneToken) {
diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs
index b0833010fe0..2c10220c766 100644
--- a/src/libsyntax/lib.rs
+++ b/src/libsyntax/lib.rs
@@ -7,7 +7,6 @@
 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/",
        test(attr(deny(warnings))))]
 
-#![cfg_attr(bootstrap, feature(bind_by_move_pattern_guards))]
 #![feature(box_syntax)]
 #![feature(const_fn)]
 #![feature(const_transmute)]
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs
index d7c537be896..4fc29d70540 100644
--- a/src/libsyntax/visit.rs
+++ b/src/libsyntax/visit.rs
@@ -834,8 +834,6 @@ pub fn walk_param<'a, V: Visitor<'a>>(visitor: &mut V, param: &'a Param) {
 
 pub fn walk_arm<'a, V: Visitor<'a>>(visitor: &mut V, arm: &'a Arm) {
     visitor.visit_pat(&arm.pat);
-    // NOTE(or_patterns; Centril | dlrobertson):
-    // If you change this, also change the hack in `lowering.rs`.
     walk_list!(visitor, visit_expr, &arm.guard);
     visitor.visit_expr(&arm.body);
     walk_list!(visitor, visit_attribute, &arm.attrs);