Merge pull request #2302 from bkchr/rust_nightly_21_22_2017

Fixes compilation with rust version 2017-12-21
This commit is contained in:
Nick Cameron 2017-12-22 15:24:57 +13:00 committed by GitHub
commit c813b98e96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 11 deletions

View File

@ -1869,7 +1869,12 @@ fn rewrite_fn_base(
// A conservative estimation, to goal is to be over all parens in generics
let args_start = fn_sig
.generics
.ty_params
.params
.iter()
.filter_map(|p| match p {
&ast::GenericParam::Type(ref t) => Some(t),
_ => None,
})
.last()
.map_or(lo_after_visibility, |tp| end_typaram(tp));
let args_end = if fd.inputs.is_empty() {
@ -2363,15 +2368,22 @@ fn rewrite_generics_inner(
}
}
if generics.lifetimes.is_empty() && generics.ty_params.is_empty() {
if generics.params.is_empty() {
return Some(String::new());
}
let generics_args = generics
.lifetimes
.params
.iter()
.filter_map(|p| match p {
&ast::GenericParam::Lifetime(ref l) => Some(l),
_ => None,
})
.map(|lt| GenericsArg::Lifetime(lt))
.chain(generics.ty_params.iter().map(|ty| GenericsArg::TyParam(ty)));
.chain(generics.params.iter().filter_map(|ty| match ty {
&ast::GenericParam::Type(ref ty) => Some(GenericsArg::TyParam(ty)),
_ => None,
}));
let items = itemize_list(
context.codemap,
generics_args,

View File

@ -413,7 +413,7 @@ impl Rewrite for ast::WherePredicate {
// TODO: dead spans?
let result = match *self {
ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate {
ref bound_lifetimes,
ref bound_generic_params,
ref bounded_ty,
ref bounds,
..
@ -422,9 +422,13 @@ impl Rewrite for ast::WherePredicate {
let colon = type_bound_colon(context);
if !bound_lifetimes.is_empty() {
let lifetime_str: String = bound_lifetimes
if bound_generic_params.iter().filter(|p| p.is_lifetime_param()).count() > 0 {
let lifetime_str: String = bound_generic_params
.iter()
.filter_map(|p| match p {
&ast::GenericParam::Lifetime(ref l) => Some(l),
_ => None,
})
.map(|lt| lt.rewrite(context, shape))
.collect::<Option<Vec<_>>>()?
.join(", ");
@ -590,9 +594,13 @@ impl Rewrite for ast::TyParam {
impl Rewrite for ast::PolyTraitRef {
fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
if !self.bound_lifetimes.is_empty() {
let lifetime_str: String = self.bound_lifetimes
if self.bound_generic_params.iter().filter(|p| p.is_lifetime_param()).count() > 0 {
let lifetime_str: String = self.bound_generic_params
.iter()
.filter_map(|p| match p {
&ast::GenericParam::Lifetime(ref l) => Some(l),
_ => None,
})
.map(|lt| lt.rewrite(context, shape))
.collect::<Option<Vec<_>>>()?
.join(", ");
@ -746,14 +754,18 @@ fn rewrite_bare_fn(
) -> Option<String> {
let mut result = String::with_capacity(128);
if !bare_fn.lifetimes.is_empty() {
if bare_fn.generic_params.iter().filter(|p| p.is_lifetime_param()).count() > 0 {
result.push_str("for<");
// 6 = "for<> ".len(), 4 = "for<".
// This doesn't work out so nicely for mutliline situation with lots of
// rightward drift. If that is a problem, we could use the list stuff.
result.push_str(&bare_fn
.lifetimes
.generic_params
.iter()
.filter_map(|p| match p {
&ast::GenericParam::Lifetime(ref l) => Some(l),
_ => None,
})
.map(|l| {
l.rewrite(
context,