Skip to content

Commit

Permalink
Fix lifetime mismatch between LateContext and Ty
Browse files Browse the repository at this point in the history
  • Loading branch information
tesuji committed Jun 19, 2019
1 parent 3217799 commit 5e887b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions clippy_lints/src/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,12 @@ fn is_len_call(expr: &Expr, var: Name) -> bool {
false
}

fn is_end_eq_array_len(cx: &LateContext<'_, '_>, end: &Expr, limits: ast::RangeLimits, indexed_ty: Ty<'_>) -> bool {
fn is_end_eq_array_len<'tcx>(
cx: &LateContext<'_, 'tcx>,
end: &Expr,
limits: ast::RangeLimits,
indexed_ty: Ty<'tcx>,
) -> bool {
if_chain! {
if let ExprKind::Lit(ref lit) = end.node;
if let ast::LitKind::Int(end_int, _) = lit.node;
Expand Down Expand Up @@ -1982,7 +1987,7 @@ fn is_ref_iterable_type(cx: &LateContext<'_, '_>, e: &Expr) -> bool {
match_type(cx, ty, &paths::BTREESET)
}

fn is_iterable_array(ty: Ty<'_>, cx: &LateContext<'_, '_>) -> bool {
fn is_iterable_array<'tcx>(ty: Ty<'tcx>, cx: &LateContext<'_, 'tcx>) -> bool {
// IntoIterator is currently only implemented for array sizes <= 32 in rustc
match ty.sty {
ty::Array(_, n) => (0..=32).contains(&n.assert_usize(cx.tcx).expect("array length")),
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1773,7 +1773,7 @@ fn derefs_to_slice<'a, 'tcx>(
expr: &'tcx hir::Expr,
ty: Ty<'tcx>,
) -> Option<&'tcx hir::Expr> {
fn may_slice(cx: &LateContext<'_, '_>, ty: Ty<'_>) -> bool {
fn may_slice<'a>(cx: &LateContext<'_, 'a>, ty: Ty<'a>) -> bool {
match ty.sty {
ty::Slice(_) => true,
ty::Adt(def, _) if def.is_box() => may_slice(cx, ty.boxed_ty()),
Expand Down

0 comments on commit 5e887b2

Please sign in to comment.