about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRejyr <jerrylwang123@gmail.com>2022-08-28 13:37:00 -0400
committerRejyr <jerrylwang123@gmail.com>2023-01-09 17:07:25 -0500
commit5a90537b62573721c42a83c024d3d7ad031b758b (patch)
treed5eab190f7fe09b4616efd09018a5a39dc450c39
parent3020239de947ec52677e9b4e853a6a9fc073d1f9 (diff)
downloadrust-5a90537b62573721c42a83c024d3d7ad031b758b.tar.gz
rust-5a90537b62573721c42a83c024d3d7ad031b758b.zip
add: `lints.rs`
add: `lints.rs`
refactor: move `InvalidAtomicOrderingDiag` to `lints.rs`
-rw-r--r--compiler/rustc_lint/src/lib.rs3
-rw-r--r--compiler/rustc_lint/src/lints.rs11
-rw-r--r--compiler/rustc_lint/src/types.rs11
3 files changed, 15 insertions, 10 deletions
diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs
index 1275d6f223c..afcf8b54322 100644
--- a/compiler/rustc_lint/src/lib.rs
+++ b/compiler/rustc_lint/src/lib.rs
@@ -38,6 +38,8 @@
 #![feature(never_type)]
 #![feature(rustc_attrs)]
 #![recursion_limit = "256"]
+// #![deny(rustc::untranslatable_diagnostic)]
+// #![deny(rustc::diagnostic_outside_of_impl)]
 
 #[macro_use]
 extern crate rustc_middle;
@@ -60,6 +62,7 @@ mod internal;
 mod late;
 mod let_underscore;
 mod levels;
+mod lints;
 mod methods;
 mod non_ascii_idents;
 mod non_fmt_panic;
diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs
new file mode 100644
index 00000000000..1dc23ad9e92
--- /dev/null
+++ b/compiler/rustc_lint/src/lints.rs
@@ -0,0 +1,11 @@
+use rustc_macros::LintDiagnostic;
+use rustc_span::{Symbol, Span};
+
+#[derive(LintDiagnostic)]
+#[diag(lint_atomic_ordering_invalid)]
+#[help]
+pub struct InvalidAtomicOrderingDiag {
+    pub method: Symbol,
+    #[label]
+    pub fail_order_arg_span: Span,
+}
diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs
index fa415243ba0..7f3a501aeb0 100644
--- a/compiler/rustc_lint/src/types.rs
+++ b/compiler/rustc_lint/src/types.rs
@@ -1,3 +1,4 @@
+use crate::lints::InvalidAtomicOrderingDiag;
 use crate::{LateContext, LateLintPass, LintContext};
 use rustc_ast as ast;
 use rustc_attr as attr;
@@ -5,7 +6,6 @@ use rustc_data_structures::fx::FxHashSet;
 use rustc_errors::{fluent, Applicability, DiagnosticMessage};
 use rustc_hir as hir;
 use rustc_hir::{is_range_literal, Expr, ExprKind, Node};
-use rustc_macros::LintDiagnostic;
 use rustc_middle::ty::layout::{IntegerExt, LayoutOf, SizeSkeleton};
 use rustc_middle::ty::subst::SubstsRef;
 use rustc_middle::ty::{self, AdtKind, DefIdTree, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable};
@@ -1550,15 +1550,6 @@ impl InvalidAtomicOrdering {
         let Some(fail_ordering) = Self::match_ordering(cx, fail_order_arg) else { return };
 
         if matches!(fail_ordering, sym::Release | sym::AcqRel) {
-            #[derive(LintDiagnostic)]
-            #[diag(lint_atomic_ordering_invalid)]
-            #[help]
-            struct InvalidAtomicOrderingDiag {
-                method: Symbol,
-                #[label]
-                fail_order_arg_span: Span,
-            }
-
             cx.emit_spanned_lint(
                 INVALID_ATOMIC_ORDERING,
                 fail_order_arg.span,