Skip to content

Commit 5a90537

Browse files
committed
add: lints.rs
add: `lints.rs` refactor: move `InvalidAtomicOrderingDiag` to `lints.rs`
1 parent 3020239 commit 5a90537

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

compiler/rustc_lint/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#![feature(never_type)]
3939
#![feature(rustc_attrs)]
4040
#![recursion_limit = "256"]
41+
// #![deny(rustc::untranslatable_diagnostic)]
42+
// #![deny(rustc::diagnostic_outside_of_impl)]
4143

4244
#[macro_use]
4345
extern crate rustc_middle;
@@ -60,6 +62,7 @@ mod internal;
6062
mod late;
6163
mod let_underscore;
6264
mod levels;
65+
mod lints;
6366
mod methods;
6467
mod non_ascii_idents;
6568
mod non_fmt_panic;

compiler/rustc_lint/src/lints.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use rustc_macros::LintDiagnostic;
2+
use rustc_span::{Symbol, Span};
3+
4+
#[derive(LintDiagnostic)]
5+
#[diag(lint_atomic_ordering_invalid)]
6+
#[help]
7+
pub struct InvalidAtomicOrderingDiag {
8+
pub method: Symbol,
9+
#[label]
10+
pub fail_order_arg_span: Span,
11+
}

compiler/rustc_lint/src/types.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
use crate::lints::InvalidAtomicOrderingDiag;
12
use crate::{LateContext, LateLintPass, LintContext};
23
use rustc_ast as ast;
34
use rustc_attr as attr;
45
use rustc_data_structures::fx::FxHashSet;
56
use rustc_errors::{fluent, Applicability, DiagnosticMessage};
67
use rustc_hir as hir;
78
use rustc_hir::{is_range_literal, Expr, ExprKind, Node};
8-
use rustc_macros::LintDiagnostic;
99
use rustc_middle::ty::layout::{IntegerExt, LayoutOf, SizeSkeleton};
1010
use rustc_middle::ty::subst::SubstsRef;
1111
use rustc_middle::ty::{self, AdtKind, DefIdTree, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable};
@@ -1550,15 +1550,6 @@ impl InvalidAtomicOrdering {
15501550
let Some(fail_ordering) = Self::match_ordering(cx, fail_order_arg) else { return };
15511551

15521552
if matches!(fail_ordering, sym::Release | sym::AcqRel) {
1553-
#[derive(LintDiagnostic)]
1554-
#[diag(lint_atomic_ordering_invalid)]
1555-
#[help]
1556-
struct InvalidAtomicOrderingDiag {
1557-
method: Symbol,
1558-
#[label]
1559-
fail_order_arg_span: Span,
1560-
}
1561-
15621553
cx.emit_spanned_lint(
15631554
INVALID_ATOMIC_ORDERING,
15641555
fail_order_arg.span,

0 commit comments

Comments
 (0)