Skip to content

Commit 3cecf81

Browse files
committed
Fix one instance of rustfmt refusing to work with a lengthy string literal, and change "unsafe fn" to "unsafe fn"
1 parent 9411232 commit 3cecf81

File tree

4 files changed

+51
-41
lines changed

4 files changed

+51
-41
lines changed

compiler/rustc_middle/src/mir/query.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ pub enum UnusedUnsafe {
122122
// `unsafe` block nested under another (used) `unsafe` block
123123
// ``… because it's nested under this `unsafe` block``
124124
InUnsafeBlock(hir::HirId),
125-
// `unsafe` block nested under `unsafe` fn
126-
// ``… because it's nested under this `unsafe` fn``
125+
// `unsafe` block nested under `unsafe fn`
126+
// ``… because it's nested under this `unsafe fn` ``
127127
//
128128
// the second HirId here indicates the first usage of the `unsafe` block,
129129
// which allows retrival of the LintLevelSource for why that operation would

compiler/rustc_mir_transform/src/check_unsafety.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -548,11 +548,21 @@ fn report_unused_unsafe(tcx: TyCtxt<'_>, kind: UnusedUnsafe, id: HirId) {
548548
db.span_label(
549549
tcx.sess.source_map().guess_head_span(tcx.hir().span(id)),
550550
format!("because it's nested under this `unsafe` fn"),
551+
)
552+
.note(
553+
"this `unsafe` block does contain unsafe operations, \
554+
but those are already allowed in an `unsafe fn`",
551555
);
552-
db.note("this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn");
553-
let (level, source) = tcx.lint_level_at_node(UNSAFE_OP_IN_UNSAFE_FN, usage_lint_root);
556+
let (level, source) =
557+
tcx.lint_level_at_node(UNSAFE_OP_IN_UNSAFE_FN, usage_lint_root);
554558
assert_eq!(level, Level::Allow);
555-
lint::explain_lint_level_source(tcx.sess, UNSAFE_OP_IN_UNSAFE_FN, Level::Allow, source, &mut db);
559+
lint::explain_lint_level_source(
560+
tcx.sess,
561+
UNSAFE_OP_IN_UNSAFE_FN,
562+
Level::Allow,
563+
source,
564+
&mut db,
565+
);
556566
}
557567
}
558568

src/test/ui/span/lint-unused-unsafe.mir.stderr

+34-34
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ LL | unsafe fn bad5() { unsafe { unsf() } }
3636
| |
3737
| because it's nested under this `unsafe` fn
3838
|
39-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
39+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
4040
= note: `#[allow(unsafe_op_in_unsafe_fn)]` on by default
4141

4242
error: unnecessary `unsafe` block
@@ -60,7 +60,7 @@ LL | unsafe {
6060
LL | unsafe {
6161
| ^^^^^^ unnecessary `unsafe` block
6262
|
63-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
63+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
6464

6565
error: unnecessary `unsafe` block
6666
--> $DIR/lint-unused-unsafe.rs:71:9
@@ -281,7 +281,7 @@ LL | unsafe {
281281
LL | unsafe { unsf() }
282282
| ^^^^^^ unnecessary `unsafe` block
283283
|
284-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
284+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
285285
note: the lint level is defined here
286286
--> $DIR/lint-unused-unsafe.rs:191:13
287287
|
@@ -297,7 +297,7 @@ LL | unsafe fn granularity_2() {
297297
LL | unsafe { unsf() }
298298
| ^^^^^^ unnecessary `unsafe` block
299299
|
300-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
300+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
301301

302302
error: unnecessary `unsafe` block
303303
--> $DIR/lint-unused-unsafe.rs:196:13
@@ -308,7 +308,7 @@ LL | unsafe fn granularity_2() {
308308
LL | unsafe { unsf() }
309309
| ^^^^^^ unnecessary `unsafe` block
310310
|
311-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
311+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
312312

313313
error: unnecessary `unsafe` block
314314
--> $DIR/lint-unused-unsafe.rs:202:9
@@ -318,7 +318,7 @@ LL | unsafe fn top_level_used_2() {
318318
LL | unsafe {
319319
| ^^^^^^ unnecessary `unsafe` block
320320
|
321-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
321+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
322322
note: the lint level is defined here
323323
--> $DIR/lint-unused-unsafe.rs:200:13
324324
|
@@ -334,7 +334,7 @@ LL | unsafe fn top_level_used_2() {
334334
LL | unsafe { unsf() }
335335
| ^^^^^^ unnecessary `unsafe` block
336336
|
337-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
337+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
338338

339339
error: unnecessary `unsafe` block
340340
--> $DIR/lint-unused-unsafe.rs:205:13
@@ -345,7 +345,7 @@ LL | unsafe fn top_level_used_2() {
345345
LL | unsafe { unsf() }
346346
| ^^^^^^ unnecessary `unsafe` block
347347
|
348-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
348+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
349349

350350
error: unnecessary `unsafe` block
351351
--> $DIR/lint-unused-unsafe.rs:206:13
@@ -356,7 +356,7 @@ LL | unsafe fn top_level_used_2() {
356356
LL | unsafe { unsf() }
357357
| ^^^^^^ unnecessary `unsafe` block
358358
|
359-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
359+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
360360

361361
error: unnecessary `unsafe` block
362362
--> $DIR/lint-unused-unsafe.rs:217:17
@@ -405,7 +405,7 @@ LL | unsafe fn granular_disallow_op_in_unsafe_fn_3() {
405405
LL | unsafe {
406406
| ^^^^^^ unnecessary `unsafe` block
407407
|
408-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
408+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
409409
note: the lint level is defined here
410410
--> $DIR/lint-unused-unsafe.rs:249:13
411411
|
@@ -639,7 +639,7 @@ LL | let _ = || unsafe {
639639
LL | let _ = || unsafe { unsf() };
640640
| ^^^^^^ unnecessary `unsafe` block
641641
|
642-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
642+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
643643
note: the lint level is defined here
644644
--> $DIR/lint-unused-unsafe.rs:403:13
645645
|
@@ -655,7 +655,7 @@ LL | unsafe fn granularity_2() {
655655
LL | let _ = || unsafe { unsf() };
656656
| ^^^^^^ unnecessary `unsafe` block
657657
|
658-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
658+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
659659

660660
error: unnecessary `unsafe` block
661661
--> $DIR/lint-unused-unsafe.rs:408:24
@@ -666,7 +666,7 @@ LL | unsafe fn granularity_2() {
666666
LL | let _ = || unsafe { unsf() };
667667
| ^^^^^^ unnecessary `unsafe` block
668668
|
669-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
669+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
670670

671671
error: unnecessary `unsafe` block
672672
--> $DIR/lint-unused-unsafe.rs:414:20
@@ -676,7 +676,7 @@ LL | unsafe fn top_level_used_2() {
676676
LL | let _ = || unsafe {
677677
| ^^^^^^ unnecessary `unsafe` block
678678
|
679-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
679+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
680680
note: the lint level is defined here
681681
--> $DIR/lint-unused-unsafe.rs:412:13
682682
|
@@ -692,7 +692,7 @@ LL | unsafe fn top_level_used_2() {
692692
LL | let _ = || unsafe { unsf() };
693693
| ^^^^^^ unnecessary `unsafe` block
694694
|
695-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
695+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
696696

697697
error: unnecessary `unsafe` block
698698
--> $DIR/lint-unused-unsafe.rs:417:24
@@ -703,7 +703,7 @@ LL | unsafe fn top_level_used_2() {
703703
LL | let _ = || unsafe { unsf() };
704704
| ^^^^^^ unnecessary `unsafe` block
705705
|
706-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
706+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
707707

708708
error: unnecessary `unsafe` block
709709
--> $DIR/lint-unused-unsafe.rs:418:24
@@ -714,7 +714,7 @@ LL | unsafe fn top_level_used_2() {
714714
LL | let _ = || unsafe { unsf() };
715715
| ^^^^^^ unnecessary `unsafe` block
716716
|
717-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
717+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
718718

719719
error: unnecessary `unsafe` block
720720
--> $DIR/lint-unused-unsafe.rs:429:28
@@ -763,7 +763,7 @@ LL | unsafe fn granular_disallow_op_in_unsafe_fn_3() {
763763
LL | let _ = || unsafe {
764764
| ^^^^^^ unnecessary `unsafe` block
765765
|
766-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
766+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
767767
note: the lint level is defined here
768768
--> $DIR/lint-unused-unsafe.rs:461:13
769769
|
@@ -997,7 +997,7 @@ LL | let _ = || unsafe {
997997
LL | let _ = || unsafe { let _ = || unsf(); };
998998
| ^^^^^^ unnecessary `unsafe` block
999999
|
1000-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
1000+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
10011001
note: the lint level is defined here
10021002
--> $DIR/lint-unused-unsafe.rs:616:13
10031003
|
@@ -1013,7 +1013,7 @@ LL | unsafe fn granularity_2() {
10131013
LL | let _ = || unsafe { let _ = || unsf(); };
10141014
| ^^^^^^ unnecessary `unsafe` block
10151015
|
1016-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
1016+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
10171017

10181018
error: unnecessary `unsafe` block
10191019
--> $DIR/lint-unused-unsafe.rs:621:24
@@ -1024,7 +1024,7 @@ LL | unsafe fn granularity_2() {
10241024
LL | let _ = || unsafe { let _ = || unsf(); };
10251025
| ^^^^^^ unnecessary `unsafe` block
10261026
|
1027-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
1027+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
10281028

10291029
error: unnecessary `unsafe` block
10301030
--> $DIR/lint-unused-unsafe.rs:627:20
@@ -1034,7 +1034,7 @@ LL | unsafe fn top_level_used_2() {
10341034
LL | let _ = || unsafe {
10351035
| ^^^^^^ unnecessary `unsafe` block
10361036
|
1037-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
1037+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
10381038
note: the lint level is defined here
10391039
--> $DIR/lint-unused-unsafe.rs:625:13
10401040
|
@@ -1050,7 +1050,7 @@ LL | unsafe fn top_level_used_2() {
10501050
LL | let _ = || unsafe { let _ = || unsf(); };
10511051
| ^^^^^^ unnecessary `unsafe` block
10521052
|
1053-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
1053+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
10541054

10551055
error: unnecessary `unsafe` block
10561056
--> $DIR/lint-unused-unsafe.rs:630:24
@@ -1061,7 +1061,7 @@ LL | unsafe fn top_level_used_2() {
10611061
LL | let _ = || unsafe { let _ = || unsf(); };
10621062
| ^^^^^^ unnecessary `unsafe` block
10631063
|
1064-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
1064+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
10651065

10661066
error: unnecessary `unsafe` block
10671067
--> $DIR/lint-unused-unsafe.rs:631:24
@@ -1072,7 +1072,7 @@ LL | unsafe fn top_level_used_2() {
10721072
LL | let _ = || unsafe { let _ = || unsf(); };
10731073
| ^^^^^^ unnecessary `unsafe` block
10741074
|
1075-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
1075+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
10761076

10771077
error: unnecessary `unsafe` block
10781078
--> $DIR/lint-unused-unsafe.rs:642:28
@@ -1121,7 +1121,7 @@ LL | unsafe fn granular_disallow_op_in_unsafe_fn_3() {
11211121
LL | let _ = || unsafe {
11221122
| ^^^^^^ unnecessary `unsafe` block
11231123
|
1124-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
1124+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
11251125
note: the lint level is defined here
11261126
--> $DIR/lint-unused-unsafe.rs:674:13
11271127
|
@@ -1144,7 +1144,7 @@ LL | unsafe fn multiple_unsafe_op_in_unsafe_fn_allows() {
11441144
LL | unsafe {
11451145
| ^^^^^^ unnecessary `unsafe` block
11461146
|
1147-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
1147+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
11481148
note: the lint level is defined here
11491149
--> $DIR/lint-unused-unsafe.rs:721:21
11501150
|
@@ -1199,7 +1199,7 @@ LL | async unsafe fn async_blocks() {
11991199
LL | let _ = async { unsafe { let _ = async { unsf() }; }};
12001200
| ^^^^^^ unnecessary `unsafe` block
12011201
|
1202-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
1202+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
12031203
note: the lint level is defined here
12041204
--> $DIR/lint-unused-unsafe.rs:747:17
12051205
|
@@ -1215,7 +1215,7 @@ LL | async unsafe fn async_blocks() {
12151215
LL | let _ = async { unsafe { let _ = async { unsf() }; }};
12161216
| ^^^^^^ unnecessary `unsafe` block
12171217
|
1218-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
1218+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
12191219

12201220
error: unnecessary `unsafe` block
12211221
--> $DIR/lint-unused-unsafe.rs:752:33
@@ -1226,7 +1226,7 @@ LL | async unsafe fn async_blocks() {
12261226
LL | let _ = async { unsafe { let _ = async { unsf() }; }};
12271227
| ^^^^^^ unnecessary `unsafe` block
12281228
|
1229-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
1229+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
12301230

12311231
error: unnecessary `unsafe` block
12321232
--> $DIR/lint-unused-unsafe.rs:754:29
@@ -1237,7 +1237,7 @@ LL | async unsafe fn async_blocks() {
12371237
LL | let _ = async { unsafe {
12381238
| ^^^^^^ unnecessary `unsafe` block
12391239
|
1240-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
1240+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
12411241

12421242
error: unnecessary `unsafe` block
12431243
--> $DIR/lint-unused-unsafe.rs:756:33
@@ -1248,7 +1248,7 @@ LL | async unsafe fn async_blocks() {
12481248
LL | let _ = async { unsafe { let _ = async { unsf() }; }};
12491249
| ^^^^^^ unnecessary `unsafe` block
12501250
|
1251-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
1251+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
12521252

12531253
error: unnecessary `unsafe` block
12541254
--> $DIR/lint-unused-unsafe.rs:757:33
@@ -1259,7 +1259,7 @@ LL | async unsafe fn async_blocks() {
12591259
LL | let _ = async { unsafe { let _ = async { unsf() }; }};
12601260
| ^^^^^^ unnecessary `unsafe` block
12611261
|
1262-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
1262+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
12631263

12641264
error: unnecessary `unsafe` block
12651265
--> $DIR/lint-unused-unsafe.rs:758:33
@@ -1270,7 +1270,7 @@ LL | async unsafe fn async_blocks() {
12701270
LL | let _ = async { unsafe { let _ = async { unsf() }; }};
12711271
| ^^^^^^ unnecessary `unsafe` block
12721272
|
1273-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
1273+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
12741274

12751275
error: unnecessary `unsafe` block
12761276
--> $DIR/lint-unused-unsafe.rs:768:22

src/test/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.mir.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ LL | unsafe fn allow_level() {
9090
LL | unsafe { unsf() }
9191
| ^^^^^^ unnecessary `unsafe` block
9292
|
93-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
93+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
9494
note: the lint level is defined here
9595
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:51:9
9696
|
@@ -106,7 +106,7 @@ LL | unsafe fn nested_allow_level() {
106106
LL | unsafe { unsf() }
107107
| ^^^^^^ unnecessary `unsafe` block
108108
|
109-
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe` fn
109+
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
110110
note: the lint level is defined here
111111
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:63:13
112112
|

0 commit comments

Comments
 (0)