diff --git a/codegen/build.rs b/codegen/build.rs index 5d108b0c..6e57575c 100644 --- a/codegen/build.rs +++ b/codegen/build.rs @@ -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(); diff --git a/codegen/src/decorators/derive_form.rs b/codegen/src/decorators/derive_form.rs index 39430e37..7f65e7de 100644 --- a/codegen/src/decorators/derive_form.rs +++ b/codegen/src/decorators/derive_form.rs @@ -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 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(); diff --git a/codegen/src/utils/generics_ext.rs b/codegen/src/utils/generics_ext.rs new file mode 100644 index 00000000..c2497e5a --- /dev/null +++ b/codegen/src/utils/generics_ext.rs @@ -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 + } + } +} diff --git a/codegen/src/utils/mod.rs b/codegen/src/utils/mod.rs index 75b4ef45..a610bb59 100644 --- a/codegen/src/utils/mod.rs +++ b/codegen/src/utils/mod.rs @@ -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;