Update codegen for 2018-05-03 nightly.

This commit is contained in:
Tim "S.D.Eagle" Zeitz 2018-05-04 10:19:44 +02:00 committed by Sergio Benitez
parent b876f233a8
commit 1dab03f929
3 changed files with 6 additions and 6 deletions

View File

@ -62,7 +62,7 @@ fn parse_code(ecx: &ExtCtxt, meta_item: &NestedMetaItem) -> Spanned<u16> {
let sp = meta_item.span(); let sp = meta_item.span();
if let Some((name, lit)) = meta_item.name_value() { if let Some((name, lit)) = meta_item.name_value() {
if name != &"code" { if name != "code" {
ecx.span_err(sp, "the first key, if any, must be 'code'"); ecx.span_err(sp, "the first key, if any, must be 'code'");
} else if let LitKind::Int(n, _) = lit.node { } else if let LitKind::Int(n, _) = lit.node {
return code_from_u128(span(n, lit.span)) return code_from_u128(span(n, lit.span))

View File

@ -169,7 +169,7 @@ fn parse_method(ecx: &ExtCtxt, meta_item: &NestedMetaItem) -> Spanned<Method> {
`HEAD`, `PATCH`, `OPTIONS`"; `HEAD`, `PATCH`, `OPTIONS`";
if let Some(word) = meta_item.word() { if let Some(word) = meta_item.word() {
if let Ok(method) = Method::from_str(&word.ident.name.as_str()) { if let Ok(method) = Method::from_str(&word.name().as_str()) {
if is_valid_method(method) { if is_valid_method(method) {
return span(method, word.span()); return span(method, word.span());
} }
@ -191,7 +191,7 @@ fn parse_path(ecx: &ExtCtxt,
-> (Spanned<Uri<'static>>, Option<Spanned<Ident>>) { -> (Spanned<Uri<'static>>, Option<Spanned<Ident>>) {
let sp = meta_item.span(); let sp = meta_item.span();
if let Some((name, lit)) = meta_item.name_value() { if let Some((name, lit)) = meta_item.name_value() {
if name != &"path" { if name != "path" {
ecx.span_err(sp, "the first key, if any, must be 'path'"); ecx.span_err(sp, "the first key, if any, must be 'path'");
} else if let LitKind::Str(ref s, _) = lit.node { } else if let LitKind::Str(ref s, _) = lit.node {
return validate_uri(ecx, &s.as_str(), lit.span); return validate_uri(ecx, &s.as_str(), lit.span);

View File

@ -2,15 +2,15 @@ use syntax::ast::{LitKind, NestedMetaItem, MetaItemKind, Lit};
use syntax::symbol::Symbol; use syntax::symbol::Symbol;
pub trait MetaItemExt { pub trait MetaItemExt {
fn name_value(&self) -> Option<(&Symbol, &Lit)>; fn name_value(&self) -> Option<(Symbol, &Lit)>;
fn str_lit(&self) -> Option<&Symbol>; fn str_lit(&self) -> Option<&Symbol>;
fn int_lit(&self) -> Option<u128>; fn int_lit(&self) -> Option<u128>;
} }
impl MetaItemExt for NestedMetaItem { impl MetaItemExt for NestedMetaItem {
fn name_value(&self) -> Option<(&Symbol, &Lit)> { fn name_value(&self) -> Option<(Symbol, &Lit)> {
self.meta_item().and_then(|mi| match mi.node { self.meta_item().and_then(|mi| match mi.node {
MetaItemKind::NameValue(ref l) => Some((&mi.ident.name, l)), MetaItemKind::NameValue(ref l) => Some((mi.name(), l)),
_ => None, _ => None,
}) })
} }