mirror of https://github.com/rwf2/Rocket.git
Update codegen for 2018-07-15 nightly.
This commit is contained in:
parent
9ac9cd462d
commit
9bdb38d6f1
|
@ -8,8 +8,8 @@ use yansi::Color::{Red, Yellow, Blue, White};
|
||||||
use version_check::{supports_features, is_min_version, is_min_date};
|
use version_check::{supports_features, is_min_version, is_min_date};
|
||||||
|
|
||||||
// Specifies the minimum nightly version needed to compile Rocket's codegen.
|
// Specifies the minimum nightly version needed to compile Rocket's codegen.
|
||||||
const MIN_DATE: &'static str = "2018-06-22";
|
const MIN_DATE: &'static str = "2018-07-15";
|
||||||
const MIN_VERSION: &'static str = "1.28.0-nightly";
|
const MIN_VERSION: &'static str = "1.29.0-nightly";
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let ok_channel = supports_features();
|
let ok_channel = supports_features();
|
||||||
|
|
|
@ -15,7 +15,7 @@ use syntax_ext::deriving::generic::MethodDef;
|
||||||
use syntax_ext::deriving::generic::{StaticStruct, Substructure, TraitDef, ty};
|
use syntax_ext::deriving::generic::{StaticStruct, Substructure, TraitDef, ty};
|
||||||
use syntax_ext::deriving::generic::combine_substructure as c_s;
|
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 \
|
static ONLY_STRUCTS_ERR: &'static str = "`FromForm` can only be derived for \
|
||||||
structures with named fields.";
|
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 {
|
Annotatable::Item(ref item) => match item.node {
|
||||||
ItemKind::Struct(_, ref generics) => {
|
ItemKind::Struct(_, ref generics) => {
|
||||||
let mut lifetimes = generics.params.iter()
|
let mut lifetimes = generics.params.iter()
|
||||||
.filter(|p| p.kind == GenericParamKind::Lifetime)
|
.filter(|p| p.is_lifetime())
|
||||||
.map(|p| p.ident.to_string());
|
.map(|p| p.ident.to_string());
|
||||||
|
|
||||||
let lifetime = lifetimes.next();
|
let lifetime = lifetimes.next();
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,12 +3,14 @@ mod arg_ext;
|
||||||
mod parser_ext;
|
mod parser_ext;
|
||||||
mod ident_ext;
|
mod ident_ext;
|
||||||
mod span_ext;
|
mod span_ext;
|
||||||
|
mod generics_ext;
|
||||||
|
|
||||||
pub use self::arg_ext::ArgExt;
|
pub use self::arg_ext::ArgExt;
|
||||||
pub use self::meta_item_ext::MetaItemExt;
|
pub use self::meta_item_ext::MetaItemExt;
|
||||||
pub use self::parser_ext::ParserExt;
|
pub use self::parser_ext::ParserExt;
|
||||||
pub use self::ident_ext::IdentExt;
|
pub use self::ident_ext::IdentExt;
|
||||||
pub use self::span_ext::SpanExt;
|
pub use self::span_ext::SpanExt;
|
||||||
|
pub use self::generics_ext::GenericParamExt;
|
||||||
|
|
||||||
use std::convert::AsRef;
|
use std::convert::AsRef;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue