add: lints.rs
add: `lints.rs` refactor: move `InvalidAtomicOrderingDiag` to `lints.rs`
This commit is contained in:
parent
3020239de9
commit
5a90537b62
3 changed files with 15 additions and 10 deletions
|
@ -38,6 +38,8 @@
|
||||||
#![feature(never_type)]
|
#![feature(never_type)]
|
||||||
#![feature(rustc_attrs)]
|
#![feature(rustc_attrs)]
|
||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
|
// #![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
// #![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate rustc_middle;
|
extern crate rustc_middle;
|
||||||
|
@ -60,6 +62,7 @@ mod internal;
|
||||||
mod late;
|
mod late;
|
||||||
mod let_underscore;
|
mod let_underscore;
|
||||||
mod levels;
|
mod levels;
|
||||||
|
mod lints;
|
||||||
mod methods;
|
mod methods;
|
||||||
mod non_ascii_idents;
|
mod non_ascii_idents;
|
||||||
mod non_fmt_panic;
|
mod non_fmt_panic;
|
||||||
|
|
11
compiler/rustc_lint/src/lints.rs
Normal file
11
compiler/rustc_lint/src/lints.rs
Normal file
|
@ -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,
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
use crate::lints::InvalidAtomicOrderingDiag;
|
||||||
use crate::{LateContext, LateLintPass, LintContext};
|
use crate::{LateContext, LateLintPass, LintContext};
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_attr as attr;
|
use rustc_attr as attr;
|
||||||
|
@ -5,7 +6,6 @@ use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_errors::{fluent, Applicability, DiagnosticMessage};
|
use rustc_errors::{fluent, Applicability, DiagnosticMessage};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::{is_range_literal, Expr, ExprKind, Node};
|
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::layout::{IntegerExt, LayoutOf, SizeSkeleton};
|
||||||
use rustc_middle::ty::subst::SubstsRef;
|
use rustc_middle::ty::subst::SubstsRef;
|
||||||
use rustc_middle::ty::{self, AdtKind, DefIdTree, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable};
|
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 };
|
let Some(fail_ordering) = Self::match_ordering(cx, fail_order_arg) else { return };
|
||||||
|
|
||||||
if matches!(fail_ordering, sym::Release | sym::AcqRel) {
|
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(
|
cx.emit_spanned_lint(
|
||||||
INVALID_ATOMIC_ORDERING,
|
INVALID_ATOMIC_ORDERING,
|
||||||
fail_order_arg.span,
|
fail_order_arg.span,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue