Fix the tests that got broken by the fixes

This commit is contained in:
flip1995 2018-06-25 02:06:57 +02:00
parent c83fd39e0e
commit 535c168791
No known key found for this signature in database
GPG key ID: 9F184E1164831181
3 changed files with 39 additions and 33 deletions

View file

@ -101,38 +101,40 @@ fn check_fn_inner<'a, 'tcx>(
}
let mut bounds_lts = Vec::new();
generics.params.iter().for_each(|param| match param.kind {
GenericParamKind::Lifetime { .. } => {},
GenericParamKind::Type { .. } => {
for bound in &param.bounds {
let mut visitor = RefVisitor::new(cx);
walk_param_bound(&mut visitor, bound);
if visitor.lts.iter().any(|lt| matches!(lt, RefLt::Named(_))) {
return;
}
if let GenericBound::Trait(ref trait_ref, _) = *bound {
let params = &trait_ref
.trait_ref
.path
.segments
.last()
.expect("a path must have at least one segment")
.args;
if let Some(ref params) = *params {
params.args.iter().for_each(|param| match param {
GenericArg::Lifetime(bound) => {
if bound.name.name() != "'static" && !bound.is_elided() {
return;
}
bounds_lts.push(bound);
},
_ => {},
});
let types = generics.params.iter().filter_map(|param| match param.kind {
GenericParamKind::Type { .. } => Some(param),
GenericParamKind::Lifetime { .. } => None,
});
for typ in types {
for bound in &typ.bounds {
let mut visitor = RefVisitor::new(cx);
walk_param_bound(&mut visitor, bound);
if visitor.lts.iter().any(|lt| matches!(lt, RefLt::Named(_))) {
return;
}
if let GenericBound::Trait(ref trait_ref, _) = *bound {
let params = &trait_ref
.trait_ref
.path
.segments
.last()
.expect("a path must have at least one segment")
.args;
if let Some(ref params) = *params {
let lifetimes = params.args.iter().filter_map(|arg| match arg {
GenericArg::Lifetime(lt) => Some(lt),
GenericArg::Type(_) => None,
});
for bound in lifetimes {
if bound.name.name() != "'static" && !bound.is_elided() {
return;
}
bounds_lts.push(bound);
}
}
}
},
});
}
}
if could_use_elision(cx, decl, body, &generics.params, bounds_lts) {
span_lint(
cx,

View file

@ -225,8 +225,10 @@ fn check_fn(cx: &LateContext, decl: &FnDecl, fn_id: NodeId, opt_body_id: Option<
if let [ref bx] = *pp.segments;
if let Some(ref params) = bx.args;
if !params.parenthesized;
if let [ref inner] = *params.args;
if let GenericArg::Type(inner) = inner;
if let Some(inner) = params.args.iter().find_map(|arg| match arg {
GenericArg::Type(ty) => Some(ty),
GenericArg::Lifetime(_) => None,
});
then {
let replacement = snippet_opt(cx, inner.span);
if let Some(r) = replacement {

View file

@ -304,8 +304,10 @@ fn check_ty_rptr(cx: &LateContext, ast_ty: &hir::Ty, is_local: bool, lt: &Lifeti
if let [ref bx] = *path.segments;
if let Some(ref params) = bx.args;
if !params.parenthesized;
if let [ref inner] = *params.args;
if let GenericArg::Type(inner) = inner;
if let Some(inner) = params.args.iter().find_map(|arg| match arg {
GenericArg::Type(ty) => Some(ty),
GenericArg::Lifetime(_) => None,
});
then {
if is_any_trait(inner) {
// Ignore `Box<Any>` types, see #1884 for details.