From 903ef47e1954b9f1a634e56df2633ce088f53978 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Fri, 28 Feb 2020 10:17:09 +0900 Subject: [PATCH 1/2] Return early if generator_drop.is_some() --- clippy_lints/src/redundant_clone.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clippy_lints/src/redundant_clone.rs b/clippy_lints/src/redundant_clone.rs index ddb0c7484348..1b4e507d47bc 100644 --- a/clippy_lints/src/redundant_clone.rs +++ b/clippy_lints/src/redundant_clone.rs @@ -82,6 +82,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone { let mir = cx.tcx.optimized_mir(def_id); let mir_read_only = mir.unwrap_read_only(); + if mir.generator_drop.is_some() { + return; + } + let maybe_storage_live_result = MaybeStorageLive .into_engine(cx.tcx, mir, def_id) .iterate_to_fixpoint() From 1be95fee75e34f0ffe464e4cf6540a47f76de5de Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Fri, 28 Feb 2020 18:28:22 +0900 Subject: [PATCH 2/2] Add a regression test --- tests/ui/crashes/ice-5238.rs | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tests/ui/crashes/ice-5238.rs diff --git a/tests/ui/crashes/ice-5238.rs b/tests/ui/crashes/ice-5238.rs new file mode 100644 index 000000000000..5ea324127fce --- /dev/null +++ b/tests/ui/crashes/ice-5238.rs @@ -0,0 +1,9 @@ +// Regression test for #5238 + +#![feature(generators, generator_trait)] + +fn main() { + let _ = || { + yield; + }; +}