diff options
| author | Jason Newcomb <jsnewcomb@pm.me> | 2022-02-07 10:29:45 -0500 |
|---|---|---|
| committer | Jason Newcomb <jsnewcomb@pm.me> | 2022-06-28 12:48:49 -0400 |
| commit | 15df2289ea1b9e90eaa37890dcecc155946bb6ac (patch) | |
| tree | c5942a9bde0ecb55efe25fb3e104f5180d3c0dee /clippy_utils/src | |
| parent | 9788107931ed6d86fc14cebca3d15b7da0d082c4 (diff) | |
| download | rust-15df2289ea1b9e90eaa37890dcecc155946bb6ac.tar.gz rust-15df2289ea1b9e90eaa37890dcecc155946bb6ac.zip | |
Code cleanup
Diffstat (limited to 'clippy_utils/src')
| -rw-r--r-- | clippy_utils/src/lib.rs | 11 | ||||
| -rw-r--r-- | clippy_utils/src/ty.rs | 1 |
2 files changed, 3 insertions, 9 deletions
diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index ca056e7c1a0..a2772edf738 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -2215,19 +2215,12 @@ pub fn walk_to_expr_usage<'tcx, T>( _ => return None, }; match parent.kind { - ExprKind::If(child, ..) | ExprKind::Match(child, ..) if child.hir_id != child_id => { - child_id = parent_id; - continue; - }, + ExprKind::If(child, ..) | ExprKind::Match(child, ..) if child.hir_id != child_id => child_id = parent_id, ExprKind::Break(Destination { target_id: Ok(id), .. }, _) => { child_id = id; iter = map.parent_iter(id); - continue; - }, - ExprKind::Block(..) => { - child_id = parent_id; - continue; }, + ExprKind::Block(..) => child_id = parent_id, _ => return None, } } diff --git a/clippy_utils/src/ty.rs b/clippy_utils/src/ty.rs index 2c19e8a7adb..6ca36eed4e6 100644 --- a/clippy_utils/src/ty.rs +++ b/clippy_utils/src/ty.rs @@ -775,6 +775,7 @@ pub fn for_each_top_level_late_bound_region<B>( ty.visit_with(&mut V { index: 0, f }) } +/// Gets the struct or enum variant from the given `Res` pub fn variant_of_res<'tcx>(cx: &LateContext<'tcx>, res: Res) -> Option<&'tcx VariantDef> { match res { Res::Def(DefKind::Struct, id) => Some(cx.tcx.adt_def(id).non_enum_variant()), |
