Auto merge of #6198 - montrivo:needless-lifetime, r=flip1995

needless-lifetime / multiple where clause predicates regression

Closes #6159.

changelog: fix regression in needless-lifetimes
This commit is contained in:
bors 2020-10-25 11:15:01 +00:00
commit 38be214724
2 changed files with 15 additions and 2 deletions

View File

@ -414,7 +414,7 @@ fn has_where_lifetimes<'tcx>(cx: &LateContext<'tcx>, where_clause: &'tcx WhereCl
let mut visitor = RefVisitor::new(cx);
// walk the type F, it may not contain LT refs
walk_ty(&mut visitor, &pred.bounded_ty);
if !visitor.lts.is_empty() {
if !visitor.all_lts().is_empty() {
return true;
}
// if the bounds define new lifetimes, they are fine to occur
@ -424,7 +424,9 @@ fn has_where_lifetimes<'tcx>(cx: &LateContext<'tcx>, where_clause: &'tcx WhereCl
walk_param_bound(&mut visitor, bound);
}
// and check that all lifetimes are allowed
return visitor.all_lts().iter().any(|it| !allowed_lts.contains(it));
if visitor.all_lts().iter().any(|it| !allowed_lts.contains(it)) {
return true;
}
},
WherePredicate::EqPredicate(ref pred) => {
let mut visitor = RefVisitor::new(cx);

View File

@ -357,4 +357,15 @@ mod nested_elision_sites {
}
}
mod issue6159 {
use std::ops::Deref;
pub fn apply_deref<'a, T, F, R>(x: &'a T, f: F) -> R
where
T: Deref,
F: FnOnce(&'a T::Target) -> R,
{
f(x.deref())
}
}
fn main() {}