Skip to content

Commit edd9dbc

Browse files
committed
Auto merge of #45985 - arielb1:unsafe-dedup, r=eddyb
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. r? @eddyb
2 parents 1410d56 + c0f7cce commit edd9dbc

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
@@ -127,7 +127,6 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
127127
let UnsafetyCheckResult {
128128
violations, unsafe_blocks
129129
} = self.tcx.unsafety_check_result(def_id);
130-
self.inherited_blocks.extend(unsafe_blocks.iter().cloned());
131130
self.register_violations(&violations, &unsafe_blocks);
132131
}
133132
}

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)