Update codegen for 2018-06-22 nightly (2/2).

This commit is contained in:
jeb 2018-06-18 20:31:15 -10:00 committed by Sergio Benitez
parent 69c953edc9
commit 5b8f8eebc6
3 changed files with 30 additions and 8 deletions

View File

@ -3,7 +3,7 @@ use std::fmt::Display;
use syntax::codemap::Span;
use syntax::ext::base::{DummyResult, ExtCtxt, MacEager, MacResult};
use syntax::tokenstream::{TokenStream, TokenTree};
use syntax::ast::{self, MacDelimiter, Ident};
use syntax::ast::{self, GenericArg, MacDelimiter, Ident};
use syntax::symbol::Symbol;
use syntax::parse::PResult;
use syntax::ext::build::AstBuilder;
@ -132,8 +132,8 @@ pub fn uri_internal(
// path for call: <T as FromUriParam<_>>::from_uri_param
let idents = split_idents("rocket::http::uri::FromUriParam");
let generics = vec![ecx.ty(span, ast::TyKind::Infer)];
let trait_path = ecx.path_all(span, true, idents, vec![], generics, vec![]);
let generics = vec![GenericArg::Type(ecx.ty(span, ast::TyKind::Infer))];
let trait_path = ecx.path_all(span, true, idents, generics, vec![]);
let method = Ident::new(Symbol::intern("from_uri_param"), span);
let (qself, path) = ecx.qpath(ty.clone(), trait_path, method);

View File

@ -4,9 +4,8 @@ use syntax::codemap::{Spanned, Span};
use syntax::ext::base::ExtCtxt;
use syntax::symbol::LocalInternedString;
use syntax::ast::{self, Expr, Name, Ident, Path};
use syntax::parse::PResult;
use syntax::parse::{SeqSep, PResult};
use syntax::parse::token::{DelimToken, Token};
use syntax::parse::common::SeqSep;
use syntax::parse::parser::{Parser, PathStyle};
use syntax::print::pprust::ty_to_string;
use syntax::ptr::P;

View File

@ -1,8 +1,8 @@
use syntax::codemap;
use syntax::parse::{token, SeqSep, PResult};
use syntax::parse::parser::{PathStyle, Parser};
use syntax::parse::PResult;
use syntax::ast::{self, Path, StrStyle, Ident};
use syntax::parse::token::Token::{Eof, Comma};
use syntax::parse::common::SeqSep;
use syntax::ast::{self, Path, StrStyle, Ident};
use syntax::symbol::Symbol;
pub trait ParserExt<'a> {
@ -14,6 +14,10 @@ pub trait ParserExt<'a> {
// Like `parse_ident` but also looks for an `ident` in a `Pat`.
fn parse_ident_inc_pat(&mut self) -> PResult<'a, Ident>;
// Duplicates previously removed method in libsyntax.
fn parse_seq<T, F>(&mut self, bra: &token::Token, ket: &token::Token, sep: SeqSep, f: F)
-> PResult<'a, codemap::Spanned<Vec<T>>> where F: FnMut(&mut Parser<'a>) -> PResult<'a, T>;
}
impl<'a> ParserExt<'a> for Parser<'a> {
@ -53,4 +57,23 @@ impl<'a> ParserExt<'a> for Parser<'a> {
Ok(ident)
})
}
// Duplicates previously removed method in libsyntax. NB: Do not use this
// function unless you actually plan to place the spanned list in the AST.
fn parse_seq<T, F>(
&mut self,
bra: &token::Token,
ket: &token::Token,
sep: SeqSep,
f: F
) -> PResult<'a, codemap::Spanned<Vec<T>>>
where F: FnMut(&mut Parser<'a>) -> PResult<'a, T>
{
let lo = self.span;
self.expect(bra)?;
let result = self.parse_seq_to_before_end(ket, sep, f)?;
let hi = self.span;
self.bump();
Ok(codemap::respan(lo.to(hi), result))
}
}