From 6669c2c6cea0c68b074cca972131a8f3fd9083a6 Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Mon, 2 Dec 2019 09:51:35 +0100 Subject: [PATCH 1/2] Rustup to https://github.com/rust-lang/rust/pull/66789 --- clippy_lints/src/redundant_clone.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/redundant_clone.rs b/clippy_lints/src/redundant_clone.rs index 478ca2e04ffb..386881368f3a 100644 --- a/clippy_lints/src/redundant_clone.rs +++ b/clippy_lints/src/redundant_clone.rs @@ -208,8 +208,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone { if !used_later { let span = terminator.source_info.span; - let node = if let mir::ClearCrossCrate::Set(scope_local_data) = &mir.source_scope_local_data { - scope_local_data[terminator.source_info.scope].lint_root + let scope = terminator.source_info.scope; + let node = if let mir::ClearCrossCrate::Set(scope_local_data) = &mir.source_scopes[scope].local_data { + scope_local_data.lint_root } else { unreachable!() }; From 474e9a131dd036fecb0503d00796c13e5efdf7f3 Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Mon, 2 Dec 2019 11:50:46 +0100 Subject: [PATCH 2/2] Use assert_crate_local for a more explicit error `assert_crate_local` does the same as the previous `if let` but with a more explicit error message if it's not a `ClearCrossCrate::Set`. --- clippy_lints/src/redundant_clone.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/clippy_lints/src/redundant_clone.rs b/clippy_lints/src/redundant_clone.rs index 386881368f3a..8ad8e45a2dbf 100644 --- a/clippy_lints/src/redundant_clone.rs +++ b/clippy_lints/src/redundant_clone.rs @@ -209,11 +209,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone { if !used_later { let span = terminator.source_info.span; let scope = terminator.source_info.scope; - let node = if let mir::ClearCrossCrate::Set(scope_local_data) = &mir.source_scopes[scope].local_data { - scope_local_data.lint_root - } else { - unreachable!() - }; + let node = mir.source_scopes[scope] + .local_data + .as_ref() + .assert_crate_local() + .lint_root; if_chain! { if let Some(snip) = snippet_opt(cx, span);