Skip to content

Commit 474e9a1

Browse files
committed
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`.
1 parent 6669c2c commit 474e9a1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

clippy_lints/src/redundant_clone.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
209209
if !used_later {
210210
let span = terminator.source_info.span;
211211
let scope = terminator.source_info.scope;
212-
let node = if let mir::ClearCrossCrate::Set(scope_local_data) = &mir.source_scopes[scope].local_data {
213-
scope_local_data.lint_root
214-
} else {
215-
unreachable!()
216-
};
212+
let node = mir.source_scopes[scope]
213+
.local_data
214+
.as_ref()
215+
.assert_crate_local()
216+
.lint_root;
217217

218218
if_chain! {
219219
if let Some(snip) = snippet_opt(cx, span);

0 commit comments

Comments
 (0)