From c0f7cce96e1bf2122ce00afb735a9feb493638ca Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Tue, 14 Nov 2017 16:01:50 +0200 Subject: [PATCH] check_unsafety: fix unused unsafe block duplication The duplicate error message is later removed by error message deduplication, but it still appears on beta and is still a bug --- src/librustc_mir/transform/check_unsafety.rs | 1 - ...e-45107-unnecessary-unsafe-in-closure.stderr | 17 +++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index cbf1b0b0899..86d5f1fd1b9 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -128,7 +128,6 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> { let UnsafetyCheckResult { violations, unsafe_blocks } = self.tcx.unsafety_check_result(def_id); - self.inherited_blocks.extend(unsafe_blocks.iter().cloned()); self.register_violations(&violations, &unsafe_blocks); } } diff --git a/src/test/ui/issue-45107-unnecessary-unsafe-in-closure.stderr b/src/test/ui/issue-45107-unnecessary-unsafe-in-closure.stderr index 5c58b19c7fb..be6b1e30a59 100644 --- a/src/test/ui/issue-45107-unnecessary-unsafe-in-closure.stderr +++ b/src/test/ui/issue-45107-unnecessary-unsafe-in-closure.stderr @@ -36,15 +36,16 @@ error: unnecessary `unsafe` block | |_________________^ unnecessary `unsafe` block | note: because it's nested under this `unsafe` block - --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:17:13 + --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:15:5 | -17 | / unsafe { +15 | / unsafe { +16 | | let f = |v: &mut Vec<_>| { +17 | | unsafe { 18 | | v.set_len(24); -19 | | |w: &mut Vec| { unsafe { -20 | | w.set_len(32); -21 | | } }; -22 | | } - | |_____________^ +... | +29 | | f(&mut v); +30 | | } + | |_____^ error: unnecessary `unsafe` block --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:23:34 @@ -67,5 +68,5 @@ note: because it's nested under this `unsafe` block 30 | | } | |_____^ -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors