Skip to content

update codegen to reflect latest nightly AST code API #630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion codegen/src/parser/catch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn parse_code(ecx: &ExtCtxt, meta_item: &NestedMetaItem) -> Spanned<u16> {

let sp = meta_item.span();
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'");
} else if let LitKind::Int(n, _) = lit.node {
return code_from_u128(span(n, lit.span))
Expand Down
4 changes: 2 additions & 2 deletions codegen/src/parser/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ fn parse_method(ecx: &ExtCtxt, meta_item: &NestedMetaItem) -> Spanned<Method> {
`HEAD`, `PATCH`, `OPTIONS`";

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) {
return span(method, word.span());
}
Expand All @@ -191,7 +191,7 @@ fn parse_path(ecx: &ExtCtxt,
-> (Spanned<Uri<'static>>, Option<Spanned<Ident>>) {
let sp = meta_item.span();
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'");
} else if let LitKind::Str(ref s, _) = lit.node {
return validate_uri(ecx, &s.as_str(), lit.span);
Expand Down
6 changes: 3 additions & 3 deletions codegen/src/utils/meta_item_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ use syntax::ast::{LitKind, NestedMetaItem, MetaItemKind, Lit};
use syntax::symbol::Symbol;

pub trait MetaItemExt {
fn name_value(&self) -> Option<(&Symbol, &Lit)>;
fn name_value(&self) -> Option<(Symbol, &Lit)>;
fn str_lit(&self) -> Option<&Symbol>;
fn int_lit(&self) -> Option<u128>;
}

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 {
MetaItemKind::NameValue(ref l) => Some((&mi.ident.name, l)),
MetaItemKind::NameValue(ref l) => Some((mi.name(), l)),
_ => None,
})
}
Expand Down