|
1 | 1 | #![deny(rustc::untranslatable_diagnostic)] |
2 | 2 | #![deny(rustc::diagnostic_outside_of_impl)] |
3 | 3 | use crate::lints::{ |
4 | | - AtomicOrderingFence, AtomicOrderingLoad, AtomicOrderingStore, InvalidAtomicOrderingDiag, |
5 | | - OnlyCastu8ToChar, OverflowingBinHex, OverflowingBinHexSign, OverflowingBinHexSub, |
6 | | - OverflowingInt, OverflowingLiteral, OverflowingUInt, RangeEndpointOutOfRange, |
7 | | - UnusedComparisons, VariantSizeDifferencesDiag, |
| 4 | + AtomicOrderingFence, AtomicOrderingLoad, AtomicOrderingStore, ImproperCTypes, |
| 5 | + InvalidAtomicOrderingDiag, OnlyCastu8ToChar, OverflowingBinHex, OverflowingBinHexSign, |
| 6 | + OverflowingBinHexSub, OverflowingInt, OverflowingLiteral, OverflowingUInt, |
| 7 | + RangeEndpointOutOfRange, UnusedComparisons, VariantSizeDifferencesDiag, |
8 | 8 | }; |
9 | 9 | use crate::{LateContext, LateLintPass, LintContext}; |
10 | 10 | use rustc_ast as ast; |
@@ -1131,27 +1131,21 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { |
1131 | 1131 | CItemKind::Declaration => IMPROPER_CTYPES, |
1132 | 1132 | CItemKind::Definition => IMPROPER_CTYPES_DEFINITIONS, |
1133 | 1133 | }; |
1134 | | - |
1135 | | - self.cx.struct_span_lint(lint, sp, fluent::lint_improper_ctypes, |lint| { |
1136 | | - let item_description = match self.mode { |
1137 | | - CItemKind::Declaration => "block", |
1138 | | - CItemKind::Definition => "fn", |
| 1134 | + let desc = match self.mode { |
| 1135 | + CItemKind::Declaration => "block", |
| 1136 | + CItemKind::Definition => "fn", |
| 1137 | + }; |
| 1138 | + let span_note = if let ty::Adt(def, _) = ty.kind() |
| 1139 | + && let Some(sp) = self.cx.tcx.hir().span_if_local(def.did()) { |
| 1140 | + Some(sp) |
| 1141 | + } else { |
| 1142 | + None |
1139 | 1143 | }; |
1140 | | - #[allow(rustc::diagnostic_outside_of_impl)] |
1141 | | - lint.set_arg("ty", ty); |
1142 | | - lint.set_arg("desc", item_description); |
1143 | | - lint.span_label(sp, fluent::label); |
1144 | | - if let Some(help) = help { |
1145 | | - lint.help(help); |
1146 | | - } |
1147 | | - lint.note(note); |
1148 | | - if let ty::Adt(def, _) = ty.kind() { |
1149 | | - if let Some(sp) = self.cx.tcx.hir().span_if_local(def.did()) { |
1150 | | - lint.span_note(sp, fluent::note); |
1151 | | - } |
1152 | | - } |
1153 | | - lint |
1154 | | - }); |
| 1144 | + self.cx.emit_spanned_lint( |
| 1145 | + lint, |
| 1146 | + sp, |
| 1147 | + ImproperCTypes { ty, desc, label: sp, help, note, span_note }, |
| 1148 | + ); |
1155 | 1149 | } |
1156 | 1150 |
|
1157 | 1151 | fn check_for_opaque_ty(&mut self, sp: Span, ty: Ty<'tcx>) -> bool { |
|
0 commit comments