libsyntax_ext => 2018

This commit is contained in:
Taiki Endo
2019-02-04 21:49:54 +09:00
parent e858c2637f
commit 94f121ff3f
35 changed files with 269 additions and 268 deletions

View File

@@ -1,9 +1,11 @@
use self::ArgumentType::*;
use self::Position::*;
use ArgumentType::*;
use Position::*;
use fmt_macros as parse;
use errors::DiagnosticBuilder;
use crate::errors::DiagnosticBuilder;
use crate::errors::Applicability;
use syntax::ast;
use syntax::ext::base::{self, *};
use syntax::ext::build::AstBuilder;
@@ -13,7 +15,6 @@ use syntax::ptr::P;
use syntax::symbol::Symbol;
use syntax::tokenstream;
use syntax_pos::{MultiSpan, Span, DUMMY_SP};
use errors::Applicability;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use std::borrow::Cow;
@@ -184,7 +185,7 @@ fn parse_args<'a>(
}
impl<'a, 'b> Context<'a, 'b> {
fn resolve_name_inplace(&self, p: &mut parse::Piece) {
fn resolve_name_inplace(&self, p: &mut parse::Piece<'_>) {
// NOTE: the `unwrap_or` branch is needed in case of invalid format
// arguments, e.g., `format_args!("{foo}")`.
let lookup = |s| *self.names.get(s).unwrap_or(&0);
@@ -208,7 +209,7 @@ impl<'a, 'b> Context<'a, 'b> {
/// Verifies one piece of a parse string, and remembers it if valid.
/// All errors are not emitted as fatal so we can continue giving errors
/// about this and possibly other format strings.
fn verify_piece(&mut self, p: &parse::Piece) {
fn verify_piece(&mut self, p: &parse::Piece<'_>) {
match *p {
parse::String(..) => {}
parse::NextArgument(ref arg) => {
@@ -231,7 +232,7 @@ impl<'a, 'b> Context<'a, 'b> {
}
}
fn verify_count(&mut self, c: parse::Count) {
fn verify_count(&mut self, c: parse::Count<'_>) {
match c {
parse::CountImplied |
parse::CountIs(..) => {}
@@ -244,7 +245,7 @@ impl<'a, 'b> Context<'a, 'b> {
}
}
fn describe_num_args(&self) -> Cow<str> {
fn describe_num_args(&self) -> Cow<'_, str> {
match self.args.len() {
0 => "no arguments were given".into(),
1 => "there is 1 argument".into(),
@@ -385,11 +386,11 @@ impl<'a, 'b> Context<'a, 'b> {
self.count_args_index_offset = sofar;
}
fn rtpath(ecx: &ExtCtxt, s: &str) -> Vec<ast::Ident> {
fn rtpath(ecx: &ExtCtxt<'_>, s: &str) -> Vec<ast::Ident> {
ecx.std_path(&["fmt", "rt", "v1", s])
}
fn build_count(&self, c: parse::Count) -> P<ast::Expr> {
fn build_count(&self, c: parse::Count<'_>) -> P<ast::Expr> {
let sp = self.macsp;
let count = |c, arg| {
let mut path = Context::rtpath(self.ecx, "Count");
@@ -426,7 +427,7 @@ impl<'a, 'b> Context<'a, 'b> {
/// Build a static `rt::Argument` from a `parse::Piece` or append
/// to the `literal` string.
fn build_piece(&mut self,
piece: &parse::Piece,
piece: &parse::Piece<'_>,
arg_index_consumed: &mut Vec<usize>)
-> Option<P<ast::Expr>> {
let sp = self.macsp;
@@ -647,7 +648,7 @@ impl<'a, 'b> Context<'a, 'b> {
self.ecx.expr_call_global(self.macsp, path, fn_args)
}
fn format_arg(ecx: &ExtCtxt,
fn format_arg(ecx: &ExtCtxt<'_>,
macsp: Span,
mut sp: Span,
ty: &ArgumentType,
@@ -686,7 +687,7 @@ impl<'a, 'b> Context<'a, 'b> {
}
}
pub fn expand_format_args<'cx>(ecx: &'cx mut ExtCtxt,
pub fn expand_format_args<'cx>(ecx: &'cx mut ExtCtxt<'_>,
mut sp: Span,
tts: &[tokenstream::TokenTree])
-> Box<dyn base::MacResult + 'cx> {
@@ -703,7 +704,7 @@ pub fn expand_format_args<'cx>(ecx: &'cx mut ExtCtxt,
}
pub fn expand_format_args_nl<'cx>(
ecx: &'cx mut ExtCtxt,
ecx: &'cx mut ExtCtxt<'_>,
mut sp: Span,
tts: &[tokenstream::TokenTree],
) -> Box<dyn base::MacResult + 'cx> {
@@ -734,7 +735,7 @@ pub fn expand_format_args_nl<'cx>(
/// Take the various parts of `format_args!(efmt, args..., name=names...)`
/// and construct the appropriate formatting expression.
pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt,
pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt<'_>,
sp: Span,
efmt: P<ast::Expr>,
args: Vec<P<ast::Expr>>,
@@ -952,7 +953,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt,
piece
}).collect::<Vec<_>>();
let numbered_position_args = pieces.iter().any(|arg: &parse::Piece| {
let numbered_position_args = pieces.iter().any(|arg: &parse::Piece<'_>| {
match *arg {
parse::String(_) => false,
parse::NextArgument(arg) => {