migrate: BuiltinEllipsisInclusiveRangePatterns
This commit is contained in:
parent
7a6ae2367d
commit
5d302d1148
@ -1,3 +1,6 @@
|
||||
// #![deny(rustc::diagnostic_outside_of_impl)]
|
||||
// #![deny(rustc::untranslatable_diagnostic)]
|
||||
//
|
||||
//! Lints in the Rust compiler.
|
||||
//!
|
||||
//! This contains lints which can feasibly be implemented as their own
|
||||
@ -21,6 +24,7 @@
|
||||
//! `late_lint_methods!` invocation in `lib.rs`.
|
||||
|
||||
use crate::{
|
||||
errors::BuiltinEllpisisInclusiveRangePatterns,
|
||||
types::{transparent_newtype_field, CItemKind},
|
||||
EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext,
|
||||
};
|
||||
@ -1760,18 +1764,11 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
|
||||
None => format!("&(..={})", end),
|
||||
};
|
||||
if join.edition() >= Edition::Edition2021 {
|
||||
let mut err = cx.sess().struct_span_err_with_code(
|
||||
pat.span,
|
||||
msg,
|
||||
rustc_errors::error_code!(E0783),
|
||||
);
|
||||
err.span_suggestion(
|
||||
pat.span,
|
||||
suggestion,
|
||||
cx.sess().emit_err(BuiltinEllpisisInclusiveRangePatterns {
|
||||
span: pat.span,
|
||||
suggestion: pat.span,
|
||||
replace,
|
||||
Applicability::MachineApplicable,
|
||||
)
|
||||
.emit();
|
||||
});
|
||||
} else {
|
||||
cx.struct_span_lint(ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, pat.span, |lint| {
|
||||
lint.build(msg)
|
||||
@ -1787,18 +1784,11 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
|
||||
} else {
|
||||
let replace = "..=";
|
||||
if join.edition() >= Edition::Edition2021 {
|
||||
let mut err = cx.sess().struct_span_err_with_code(
|
||||
pat.span,
|
||||
msg,
|
||||
rustc_errors::error_code!(E0783),
|
||||
);
|
||||
err.span_suggestion_short(
|
||||
join,
|
||||
suggestion,
|
||||
replace,
|
||||
Applicability::MachineApplicable,
|
||||
)
|
||||
.emit();
|
||||
cx.sess().emit_err(BuiltinEllpisisInclusiveRangePatterns {
|
||||
span: pat.span,
|
||||
suggestion: join,
|
||||
replace: replace.to_string(),
|
||||
});
|
||||
} else {
|
||||
cx.struct_span_lint(ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, join, |lint| {
|
||||
lint.build(msg)
|
||||
|
@ -70,3 +70,13 @@ pub struct UnknownTool {
|
||||
#[help]
|
||||
pub is_nightly_build: Option<()>,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(lint::builtin_ellipsis_inclusive_range_patterns, code = "E0783")]
|
||||
pub struct BuiltinEllpisisInclusiveRangePatterns {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
#[suggestion_short(code = "{replace}", applicability = "machine-applicable")]
|
||||
pub suggestion: Span,
|
||||
pub replace: String,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user