Skip to content

Commit 73bdf67

Browse files
committed
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
1 parent b23c76e commit 73bdf67

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/librustc_mir/transform/check_unsafety.rs

-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
128128
let UnsafetyCheckResult {
129129
violations, unsafe_blocks
130130
} = self.tcx.unsafety_check_result(def_id);
131-
self.inherited_blocks.extend(unsafe_blocks.iter().cloned());
132131
self.register_violations(&violations, &unsafe_blocks);
133132
}
134133
}

src/test/ui/issue-45107-unnecessary-unsafe-in-closure.stderr

+9-8
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@ error: unnecessary `unsafe` block
3636
| |_________________^ unnecessary `unsafe` block
3737
|
3838
note: because it's nested under this `unsafe` block
39-
--> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:17:13
39+
--> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:15:5
4040
|
41-
17 | / unsafe {
41+
15 | / unsafe {
42+
16 | | let f = |v: &mut Vec<_>| {
43+
17 | | unsafe {
4244
18 | | v.set_len(24);
43-
19 | | |w: &mut Vec<u32>| { unsafe {
44-
20 | | w.set_len(32);
45-
21 | | } };
46-
22 | | }
47-
| |_____________^
45+
... |
46+
29 | | f(&mut v);
47+
30 | | }
48+
| |_____^
4849

4950
error: unnecessary `unsafe` block
5051
--> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:23:34
@@ -67,5 +68,5 @@ note: because it's nested under this `unsafe` block
6768
30 | | }
6869
| |_____^
6970

70-
error: aborting due to 6 previous errors
71+
error: aborting due to 3 previous errors
7172

0 commit comments

Comments
 (0)