Skip to content

Commit 457fa95

Browse files
committed
Use label instead of note to be more consistent with other lints
1 parent 77773ad commit 457fa95

File tree

7 files changed

+133
-283
lines changed

7 files changed

+133
-283
lines changed

compiler/rustc_lint/messages.ftl

+4-4
Original file line numberDiff line numberDiff line change
@@ -522,13 +522,13 @@ lint_opaque_hidden_inferred_bound = opaque type `{$ty}` does not satisfy its ass
522522
lint_opaque_hidden_inferred_bound_sugg = add this bound
523523
524524
lint_drop_ref = calls to `std::mem::drop` with a reference instead of an owned value
525-
.note = argument has type `{$arg_ty}`
525+
.label = argument has type `{$arg_ty}`
526526
527527
lint_drop_copy = calls to `std::mem::drop` with a value that implements `Copy`.
528-
.note = argument has type `{$arg_ty}`
528+
.label = argument has type `{$arg_ty}`
529529
530530
lint_forget_ref = calls to `std::mem::forget` with a reference instead of an owned value
531-
.note = argument has type `{$arg_ty}`
531+
.label = argument has type `{$arg_ty}`
532532
533533
lint_forget_copy = calls to `std::mem::forget` with a value that implements `Copy`.
534-
.note = argument has type `{$arg_ty}`
534+
.label = argument has type `{$arg_ty}`

compiler/rustc_lint/src/drop_forget_useless.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,16 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless {
123123
let drop_is_single_call_in_arm = is_single_call_in_arm(cx, arg, expr);
124124
match fn_name {
125125
sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => {
126-
cx.emit_spanned_lint(DROP_REF, expr.span, DropRefDiag { arg_ty, note: arg.span });
126+
cx.emit_spanned_lint(DROP_REF, expr.span, DropRefDiag { arg_ty, label: arg.span });
127127
},
128128
sym::mem_forget if arg_ty.is_ref() => {
129-
cx.emit_spanned_lint(FORGET_REF, expr.span, ForgetRefDiag { arg_ty, note: arg.span });
129+
cx.emit_spanned_lint(FORGET_REF, expr.span, ForgetRefDiag { arg_ty, label: arg.span });
130130
},
131131
sym::mem_drop if is_copy && !drop_is_single_call_in_arm => {
132-
cx.emit_spanned_lint(DROP_COPY, expr.span, DropCopyDiag { arg_ty, note: arg.span });
132+
cx.emit_spanned_lint(DROP_COPY, expr.span, DropCopyDiag { arg_ty, label: arg.span });
133133
}
134134
sym::mem_forget if is_copy => {
135-
cx.emit_spanned_lint(FORGET_COPY, expr.span, ForgetCopyDiag { arg_ty, note: arg.span });
135+
cx.emit_spanned_lint(FORGET_COPY, expr.span, ForgetCopyDiag { arg_ty, label: arg.span });
136136
}
137137
_ => return,
138138
};

compiler/rustc_lint/src/lints.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -667,32 +667,32 @@ pub struct ForLoopsOverFalliblesSuggestion<'a> {
667667
#[diag(lint_drop_ref)]
668668
pub struct DropRefDiag<'a> {
669669
pub arg_ty: Ty<'a>,
670-
#[note]
671-
pub note: Span,
670+
#[label]
671+
pub label: Span,
672672
}
673673

674674
#[derive(LintDiagnostic)]
675675
#[diag(lint_drop_copy)]
676676
pub struct DropCopyDiag<'a> {
677677
pub arg_ty: Ty<'a>,
678-
#[note]
679-
pub note: Span,
678+
#[label]
679+
pub label: Span,
680680
}
681681

682682
#[derive(LintDiagnostic)]
683683
#[diag(lint_forget_ref)]
684684
pub struct ForgetRefDiag<'a> {
685685
pub arg_ty: Ty<'a>,
686-
#[note]
687-
pub note: Span,
686+
#[label]
687+
pub label: Span,
688688
}
689689

690690
#[derive(LintDiagnostic)]
691691
#[diag(lint_forget_copy)]
692692
pub struct ForgetCopyDiag<'a> {
693693
pub arg_ty: Ty<'a>,
694-
#[note]
695-
pub note: Span,
694+
#[label]
695+
pub label: Span,
696696
}
697697

698698
// hidden_unicode_codepoints.rs

tests/ui/lint/drop_copy.stderr

+30-68
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@ warning: calls to `std::mem::drop` with a value that implements `Copy`.
22
--> $DIR/drop_copy.rs:34:5
33
|
44
LL | drop(s1);
5-
| ^^^^^^^^
5+
| ^^^^^--^
6+
| |
7+
| argument has type `SomeStruct`
68
|
7-
note: argument has type `SomeStruct`
8-
--> $DIR/drop_copy.rs:34:10
9-
|
10-
LL | drop(s1);
11-
| ^^
129
note: the lint level is defined here
1310
--> $DIR/drop_copy.rs:3:9
1411
|
@@ -19,110 +16,75 @@ warning: calls to `std::mem::drop` with a value that implements `Copy`.
1916
--> $DIR/drop_copy.rs:35:5
2017
|
2118
LL | drop(s2);
22-
| ^^^^^^^^
23-
|
24-
note: argument has type `SomeStruct`
25-
--> $DIR/drop_copy.rs:35:10
26-
|
27-
LL | drop(s2);
28-
| ^^
19+
| ^^^^^--^
20+
| |
21+
| argument has type `SomeStruct`
2922

3023
warning: calls to `std::mem::drop` with a reference instead of an owned value
3124
--> $DIR/drop_copy.rs:36:5
3225
|
3326
LL | drop(s3);
34-
| ^^^^^^^^
35-
|
36-
note: argument has type `&SomeStruct`
37-
--> $DIR/drop_copy.rs:36:10
27+
| ^^^^^--^
28+
| |
29+
| argument has type `&SomeStruct`
3830
|
39-
LL | drop(s3);
40-
| ^^
4131
= note: `#[warn(drop_ref)]` on by default
4232

4333
warning: calls to `std::mem::drop` with a value that implements `Copy`.
4434
--> $DIR/drop_copy.rs:37:5
4535
|
4636
LL | drop(s4);
47-
| ^^^^^^^^
48-
|
49-
note: argument has type `SomeStruct`
50-
--> $DIR/drop_copy.rs:37:10
51-
|
52-
LL | drop(s4);
53-
| ^^
37+
| ^^^^^--^
38+
| |
39+
| argument has type `SomeStruct`
5440

5541
warning: calls to `std::mem::drop` with a reference instead of an owned value
5642
--> $DIR/drop_copy.rs:38:5
5743
|
5844
LL | drop(s5);
59-
| ^^^^^^^^
60-
|
61-
note: argument has type `&SomeStruct`
62-
--> $DIR/drop_copy.rs:38:10
63-
|
64-
LL | drop(s5);
65-
| ^^
45+
| ^^^^^--^
46+
| |
47+
| argument has type `&SomeStruct`
6648

6749
warning: calls to `std::mem::drop` with a reference instead of an owned value
6850
--> $DIR/drop_copy.rs:50:5
6951
|
7052
LL | drop(a2);
71-
| ^^^^^^^^
72-
|
73-
note: argument has type `&AnotherStruct`
74-
--> $DIR/drop_copy.rs:50:10
75-
|
76-
LL | drop(a2);
77-
| ^^
53+
| ^^^^^--^
54+
| |
55+
| argument has type `&AnotherStruct`
7856

7957
warning: calls to `std::mem::drop` with a reference instead of an owned value
8058
--> $DIR/drop_copy.rs:52:5
8159
|
8260
LL | drop(a4);
83-
| ^^^^^^^^
84-
|
85-
note: argument has type `&AnotherStruct`
86-
--> $DIR/drop_copy.rs:52:10
87-
|
88-
LL | drop(a4);
89-
| ^^
61+
| ^^^^^--^
62+
| |
63+
| argument has type `&AnotherStruct`
9064

9165
warning: calls to `std::mem::drop` with a value that implements `Copy`.
9266
--> $DIR/drop_copy.rs:71:13
9367
|
9468
LL | drop(println_and(13));
95-
| ^^^^^^^^^^^^^^^^^^^^^
96-
|
97-
note: argument has type `i32`
98-
--> $DIR/drop_copy.rs:71:18
99-
|
100-
LL | drop(println_and(13));
101-
| ^^^^^^^^^^^^^^^
69+
| ^^^^^---------------^
70+
| |
71+
| argument has type `i32`
10272

10373
warning: calls to `std::mem::drop` with a value that implements `Copy`.
10474
--> $DIR/drop_copy.rs:74:14
10575
|
10676
LL | 3 if drop(println_and(14)) == () => (),
107-
| ^^^^^^^^^^^^^^^^^^^^^
108-
|
109-
note: argument has type `i32`
110-
--> $DIR/drop_copy.rs:74:19
111-
|
112-
LL | 3 if drop(println_and(14)) == () => (),
113-
| ^^^^^^^^^^^^^^^
77+
| ^^^^^---------------^
78+
| |
79+
| argument has type `i32`
11480

11581
warning: calls to `std::mem::drop` with a value that implements `Copy`.
11682
--> $DIR/drop_copy.rs:76:14
11783
|
11884
LL | 4 => drop(2),
119-
| ^^^^^^^
120-
|
121-
note: argument has type `i32`
122-
--> $DIR/drop_copy.rs:76:19
123-
|
124-
LL | 4 => drop(2),
125-
| ^
85+
| ^^^^^-^
86+
| |
87+
| argument has type `i32`
12688

12789
warning: 10 warnings emitted
12890

0 commit comments

Comments
 (0)