Update codegen for 2018-07-15 nightly.

This commit is contained in:
Sergio Benitez 2018-07-16 01:07:07 -07:00
parent 9ac9cd462d
commit 9bdb38d6f1
4 changed files with 21 additions and 4 deletions

View File

@ -8,8 +8,8 @@ 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-06-22";
const MIN_VERSION: &'static str = "1.28.0-nightly";
const MIN_DATE: &'static str = "2018-07-15";
const MIN_VERSION: &'static str = "1.29.0-nightly";
fn main() {
let ok_channel = supports_features();

View File

@ -15,7 +15,7 @@ use syntax_ext::deriving::generic::MethodDef;
use syntax_ext::deriving::generic::{StaticStruct, Substructure, TraitDef, ty};
use syntax_ext::deriving::generic::combine_substructure as c_s;
use utils::{strip_ty_lifetimes, is_valid_ident, SpanExt};
use utils::{strip_ty_lifetimes, is_valid_ident, SpanExt, GenericParamExt};
static ONLY_STRUCTS_ERR: &'static str = "`FromForm` can only be derived for \
structures with named fields.";
@ -26,7 +26,7 @@ fn struct_lifetime(ecx: &mut ExtCtxt, item: &Annotatable, sp: Span) -> Option<St
Annotatable::Item(ref item) => match item.node {
ItemKind::Struct(_, ref generics) => {
let mut lifetimes = generics.params.iter()
.filter(|p| p.kind == GenericParamKind::Lifetime)
.filter(|p| p.is_lifetime())
.map(|p| p.ident.to_string());
let lifetime = lifetimes.next();

View File

@ -0,0 +1,15 @@
use syntax::ast::{GenericParam, GenericParamKind};
pub trait GenericParamExt {
/// Returns `true` if `self` is of kind `lifetime`.
fn is_lifetime(&self) -> bool;
}
impl GenericParamExt for GenericParam {
fn is_lifetime(&self) -> bool {
match self.kind {
GenericParamKind::Lifetime => true,
_ => false
}
}
}

View File

@ -3,12 +3,14 @@ mod arg_ext;
mod parser_ext;
mod ident_ext;
mod span_ext;
mod generics_ext;
pub use self::arg_ext::ArgExt;
pub use self::meta_item_ext::MetaItemExt;
pub use self::parser_ext::ParserExt;
pub use self::ident_ext::IdentExt;
pub use self::span_ext::SpanExt;
pub use self::generics_ext::GenericParamExt;
use std::convert::AsRef;