Skip to content

Commit

Permalink
Update codegen for 2018-04-06 nightly.
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioBenitez committed Apr 7, 2018
1 parent 56e24bd commit 53061f2
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion codegen/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use yansi::Color::{Red, Yellow, Blue, White};
use version_check::{supports_features, is_min_version, is_min_date};

// Specifies the minimum nightly version needed to compile Rocket's codegen.
const MIN_DATE: &'static str = "2018-04-03";
const MIN_DATE: &'static str = "2018-04-06";
const MIN_VERSION: &'static str = "1.27.0-nightly";

fn main() {
Expand Down
3 changes: 1 addition & 2 deletions codegen/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ use syntax::ext::base::{DummyResult, ExtCtxt, MacResult, MacEager};
use syntax::parse::token::Token;
use syntax::ptr::P;

#[inline]
pub fn prefix_paths(prefix: &str, paths: &mut Vec<Path>) {
for p in paths {
let last = p.segments.len() - 1;
let last_seg = &mut p.segments[last];
last_seg.identifier = last_seg.identifier.prepend(prefix);
last_seg.ident = last_seg.ident.prepend(prefix);
}
}

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 @@ -170,12 +170,12 @@ pub fn param_to_ident(ecx: &ExtCtxt, s: Spanned<&str>) -> Option<Spanned<Ident>>

fn parse_method(ecx: &ExtCtxt, meta_item: &NestedMetaItem) -> Spanned<Method> {
if let Some(word) = meta_item.word() {
if let Ok(method) = Method::from_str(&word.name().as_str()) {
if let Ok(method) = Method::from_str(&word.ident.name.as_str()) {
if is_valid_method(method) {
return span(method, word.span());
}
} else {
let msg = format!("'{}' is not a valid HTTP method.", word.name());
let msg = format!("'{}' is not a valid HTTP method.", word.ident);
ecx.span_err(word.span(), &msg);
}
}
Expand Down
2 changes: 1 addition & 1 deletion codegen/src/utils/arg_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub trait ArgExt {
impl ArgExt for Arg {
fn ident(&self) -> Option<&Ident> {
match self.pat.node {
PatKind::Ident(_, ref ident, _) => Some(&ident.node),
PatKind::Ident(_, ref ident, _) => Some(&ident),
_ => None,
}
}
Expand Down
5 changes: 3 additions & 2 deletions codegen/src/utils/ident_ext.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::fmt::Display;
use syntax::ast::Ident;
use syntax::symbol::Symbol;

pub trait IdentExt {
fn prepend<T: Display>(&self, other: T) -> Ident;
Expand All @@ -9,11 +10,11 @@ pub trait IdentExt {
impl IdentExt for Ident {
fn prepend<T: Display>(&self, other: T) -> Ident {
let new_ident = format!("{}{}", other, self.name);
Ident::from_str(new_ident.as_str())
Ident::new(Symbol::intern(&new_ident), self.span)
}

fn append<T: Display>(&self, other: T) -> Ident {
let new_ident = format!("{}{}", self.name, other);
Ident::from_str(new_ident.as_str())
Ident::new(Symbol::intern(&new_ident), self.span)
}
}
2 changes: 1 addition & 1 deletion codegen/src/utils/meta_item_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub trait MetaItemExt {
impl MetaItemExt for NestedMetaItem {
fn name_value(&self) -> Option<(&Symbol, &Lit)> {
self.meta_item().and_then(|mi| match mi.node {
MetaItemKind::NameValue(ref l) => Some((&mi.name, l)),
MetaItemKind::NameValue(ref l) => Some((&mi.ident.name, l)),
_ => None,
})
}
Expand Down

0 comments on commit 53061f2

Please sign in to comment.