migrate: BuiltinEllipsisInclusiveRangePatterns
This commit is contained in:
parent
7a6ae2367d
commit
5d302d1148
2 changed files with 23 additions and 23 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
// #![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
|
// #![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
//
|
||||||
//! Lints in the Rust compiler.
|
//! Lints in the Rust compiler.
|
||||||
//!
|
//!
|
||||||
//! This contains lints which can feasibly be implemented as their own
|
//! This contains lints which can feasibly be implemented as their own
|
||||||
|
@ -21,6 +24,7 @@
|
||||||
//! `late_lint_methods!` invocation in `lib.rs`.
|
//! `late_lint_methods!` invocation in `lib.rs`.
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
errors::BuiltinEllpisisInclusiveRangePatterns,
|
||||||
types::{transparent_newtype_field, CItemKind},
|
types::{transparent_newtype_field, CItemKind},
|
||||||
EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext,
|
EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext,
|
||||||
};
|
};
|
||||||
|
@ -1760,18 +1764,11 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
|
||||||
None => format!("&(..={})", end),
|
None => format!("&(..={})", end),
|
||||||
};
|
};
|
||||||
if join.edition() >= Edition::Edition2021 {
|
if join.edition() >= Edition::Edition2021 {
|
||||||
let mut err = cx.sess().struct_span_err_with_code(
|
cx.sess().emit_err(BuiltinEllpisisInclusiveRangePatterns {
|
||||||
pat.span,
|
span: pat.span,
|
||||||
msg,
|
suggestion: pat.span,
|
||||||
rustc_errors::error_code!(E0783),
|
|
||||||
);
|
|
||||||
err.span_suggestion(
|
|
||||||
pat.span,
|
|
||||||
suggestion,
|
|
||||||
replace,
|
replace,
|
||||||
Applicability::MachineApplicable,
|
});
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
} else {
|
} else {
|
||||||
cx.struct_span_lint(ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, pat.span, |lint| {
|
cx.struct_span_lint(ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, pat.span, |lint| {
|
||||||
lint.build(msg)
|
lint.build(msg)
|
||||||
|
@ -1787,18 +1784,11 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
|
||||||
} else {
|
} else {
|
||||||
let replace = "..=";
|
let replace = "..=";
|
||||||
if join.edition() >= Edition::Edition2021 {
|
if join.edition() >= Edition::Edition2021 {
|
||||||
let mut err = cx.sess().struct_span_err_with_code(
|
cx.sess().emit_err(BuiltinEllpisisInclusiveRangePatterns {
|
||||||
pat.span,
|
span: pat.span,
|
||||||
msg,
|
suggestion: join,
|
||||||
rustc_errors::error_code!(E0783),
|
replace: replace.to_string(),
|
||||||
);
|
});
|
||||||
err.span_suggestion_short(
|
|
||||||
join,
|
|
||||||
suggestion,
|
|
||||||
replace,
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
} else {
|
} else {
|
||||||
cx.struct_span_lint(ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, join, |lint| {
|
cx.struct_span_lint(ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, join, |lint| {
|
||||||
lint.build(msg)
|
lint.build(msg)
|
||||||
|
|
|
@ -70,3 +70,13 @@ pub struct UnknownTool {
|
||||||
#[help]
|
#[help]
|
||||||
pub is_nightly_build: Option<()>,
|
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…
Add table
Add a link
Reference in a new issue