]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/ext/tt/macro_rules.rs
Rollup merge of #58273 - taiki-e:rename-dependency, r=matthewjasper
[rust.git] / src / libsyntax / ext / tt / macro_rules.rs
index a79f3271fcb180da46f69e3080ce77c834005e70..bd64bb010219b9131a74f424469594a8e1b01ddf 100644 (file)
@@ -1,6 +1,5 @@
 use crate::{ast, attr};
 use crate::edition::Edition;
-use crate::errors::FatalError;
 use crate::ext::base::{DummyResult, ExtCtxt, MacResult, SyntaxExtension};
 use crate::ext::base::{NormalTT, TTMacroExpander};
 use crate::ext::expand::{AstFragment, AstFragmentKind};
@@ -17,6 +16,7 @@
 use crate::symbol::Symbol;
 use crate::tokenstream::{DelimSpan, TokenStream, TokenTree};
 
+use errors::FatalError;
 use syntax_pos::{Span, DUMMY_SP, symbol::Ident};
 use log::debug;
 
@@ -25,7 +25,7 @@
 use std::collections::hash_map::Entry;
 
 use rustc_data_structures::sync::Lrc;
-use crate::errors::Applicability;
+use errors::Applicability;
 
 const VALID_FRAGMENT_NAMES_MSG: &str = "valid fragment specifiers are \
     `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, \
@@ -377,13 +377,13 @@ pub fn compile(
 
     if body.legacy {
         let allow_internal_unstable = attr::find_by_name(&def.attrs, "allow_internal_unstable")
-            .map_or(Vec::new(), |attr| attr
+            .map(|attr| attr
                 .meta_item_list()
                 .map(|list| list.iter()
                     .map(|it| it.name().unwrap_or_else(|| sess.span_diagnostic.span_bug(
                         it.span, "allow internal unstable expects feature names",
                     )))
-                    .collect()
+                    .collect::<Vec<Symbol>>().into()
                 )
                 .unwrap_or_else(|| {
                     sess.span_diagnostic.span_warn(
@@ -391,7 +391,7 @@ pub fn compile(
                         future this will become a hard error. Please use `allow_internal_unstable(\
                         foo, bar)` to only allow the `foo` and `bar` features",
                     );
-                    vec![Symbol::intern("allow_internal_unstable_backcompat_hack")]
+                    vec![Symbol::intern("allow_internal_unstable_backcompat_hack")].into()
                 })
             );
         let allow_internal_unsafe = attr::contains_name(&def.attrs, "allow_internal_unsafe");
@@ -449,7 +449,7 @@ fn check_lhs_nt_follows(sess: &ParseSess,
     // after parsing/expansion. we can report every error in every macro this way.
 }
 
-/// Check that the lhs contains no repetition which could match an empty token
+/// Checks that the lhs contains no repetition which could match an empty token
 /// tree, because then the matcher would hang indefinitely.
 fn check_lhs_no_empty_seq(sess: &ParseSess, tts: &[quoted::TokenTree]) -> bool {
     use quoted::TokenTree;
@@ -977,8 +977,8 @@ fn token_can_be_followed_by_any(tok: &quoted::TokenTree) -> bool {
     }
 }
 
-/// True if a fragment of type `frag` can be followed by any sort of
-/// token.  We use this (among other things) as a useful approximation
+/// Returns `true` if a fragment of type `frag` can be followed by any sort of
+/// token. We use this (among other things) as a useful approximation
 /// for when `frag` can be followed by a repetition like `$(...)*` or
 /// `$(...)+`. In general, these can be a bit tricky to reason about,
 /// so we adopt a conservative position that says that any fragment
@@ -1007,7 +1007,7 @@ enum IsInFollow {
     Invalid(String, &'static str),
 }
 
-/// True if `frag` can legally be followed by the token `tok`. For
+/// Returns `true` if `frag` can legally be followed by the token `tok`. For
 /// fragments that can consume an unbounded number of tokens, `tok`
 /// must be within a well-defined follow set. This is intended to
 /// guarantee future compatibility: for example, without this rule, if