Skip to content

Commit a92037f

Browse files
committed
[option_option]: Fix duplicate diagnostics
1 parent 7ee75f8 commit a92037f

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

clippy_lints/src/types/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_hir::{
1515
Body, FnDecl, FnRetTy, GenericArg, ImplItem, ImplItemKind, Item, ItemKind, Local, MutTy, QPath, TraitItem,
1616
TraitItemKind, TyKind,
1717
};
18-
use rustc_lint::{LateContext, LateLintPass};
18+
use rustc_lint::{LateContext, LateLintPass, LintContext};
1919
use rustc_session::impl_lint_pass;
2020
use rustc_span::def_id::LocalDefId;
2121
use rustc_span::Span;
@@ -392,6 +392,10 @@ impl<'tcx> LateLintPass<'tcx> for Types {
392392
}
393393

394394
fn check_field_def(&mut self, cx: &LateContext<'tcx>, field: &hir::FieldDef<'tcx>) {
395+
if rustc_middle::lint::in_external_macro(cx.sess(), field.span) {
396+
return;
397+
}
398+
395399
let is_exported = cx.effective_visibilities.is_exported(field.def_id);
396400

397401
self.check_ty(

tests/ui/option_option.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//@compile-flags: -Zdeduplicate-diagnostics=yes
2-
31
#![deny(clippy::option_option)]
42
#![allow(clippy::unnecessary_wraps)]
53

tests/ui/option_option.stderr

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,77 @@
11
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
2-
--> tests/ui/option_option.rs:6:10
2+
--> tests/ui/option_option.rs:4:10
33
|
44
LL | const C: Option<Option<i32>> = None;
55
| ^^^^^^^^^^^^^^^^^^^
66
|
77
note: the lint level is defined here
8-
--> tests/ui/option_option.rs:3:9
8+
--> tests/ui/option_option.rs:1:9
99
|
1010
LL | #![deny(clippy::option_option)]
1111
| ^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
14-
--> tests/ui/option_option.rs:8:11
14+
--> tests/ui/option_option.rs:6:11
1515
|
1616
LL | static S: Option<Option<i32>> = None;
1717
| ^^^^^^^^^^^^^^^^^^^
1818

1919
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
20-
--> tests/ui/option_option.rs:11:13
20+
--> tests/ui/option_option.rs:9:13
2121
|
2222
LL | fn input(_: Option<Option<u8>>) {}
2323
| ^^^^^^^^^^^^^^^^^^
2424

2525
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
26-
--> tests/ui/option_option.rs:14:16
26+
--> tests/ui/option_option.rs:12:16
2727
|
2828
LL | fn output() -> Option<Option<u8>> {
2929
| ^^^^^^^^^^^^^^^^^^
3030

3131
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
32-
--> tests/ui/option_option.rs:19:27
32+
--> tests/ui/option_option.rs:17:27
3333
|
3434
LL | fn output_nested() -> Vec<Option<Option<u8>>> {
3535
| ^^^^^^^^^^^^^^^^^^
3636

3737
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
38-
--> tests/ui/option_option.rs:25:30
38+
--> tests/ui/option_option.rs:23:30
3939
|
4040
LL | fn output_nested_nested() -> Option<Option<Option<u8>>> {
4141
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
4242

4343
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
44-
--> tests/ui/option_option.rs:31:8
44+
--> tests/ui/option_option.rs:29:8
4545
|
4646
LL | x: Option<Option<u8>>,
4747
| ^^^^^^^^^^^^^^^^^^
4848

4949
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
50-
--> tests/ui/option_option.rs:36:23
50+
--> tests/ui/option_option.rs:34:23
5151
|
5252
LL | fn struct_fn() -> Option<Option<u8>> {
5353
| ^^^^^^^^^^^^^^^^^^
5454

5555
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
56-
--> tests/ui/option_option.rs:43:22
56+
--> tests/ui/option_option.rs:41:22
5757
|
5858
LL | fn trait_fn() -> Option<Option<u8>>;
5959
| ^^^^^^^^^^^^^^^^^^
6060

6161
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
62-
--> tests/ui/option_option.rs:48:11
62+
--> tests/ui/option_option.rs:46:11
6363
|
6464
LL | Tuple(Option<Option<u8>>),
6565
| ^^^^^^^^^^^^^^^^^^
6666

6767
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
68-
--> tests/ui/option_option.rs:50:17
68+
--> tests/ui/option_option.rs:48:17
6969
|
7070
LL | Struct { x: Option<Option<u8>> },
7171
| ^^^^^^^^^^^^^^^^^^
7272

7373
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
74-
--> tests/ui/option_option.rs:92:14
74+
--> tests/ui/option_option.rs:90:14
7575
|
7676
LL | foo: Option<Option<Cow<'a, str>>>,
7777
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)