1+ // #![deny(rustc::diagnostic_outside_of_impl)]
2+ // #![deny(rustc::untranslatable_diagnostic)]
3+ //
14//! Lints in the Rust compiler.
25//!
36//! This contains lints which can feasibly be implemented as their own
2124//! `late_lint_methods!` invocation in `lib.rs`.
2225
2326use crate :: {
27+ errors:: BuiltinEllpisisInclusiveRangePatterns ,
2428 types:: { transparent_newtype_field, CItemKind } ,
2529 EarlyContext , EarlyLintPass , LateContext , LateLintPass , LintContext ,
2630} ;
@@ -1760,18 +1764,11 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
17601764 None => format ! ( "&(..={})" , end) ,
17611765 } ;
17621766 if join. edition ( ) >= Edition :: Edition2021 {
1763- let mut err = cx. sess ( ) . struct_span_err_with_code (
1764- pat. span ,
1765- msg,
1766- rustc_errors:: error_code!( E0783 ) ,
1767- ) ;
1768- err. span_suggestion (
1769- pat. span ,
1770- suggestion,
1767+ cx. sess ( ) . emit_err ( BuiltinEllpisisInclusiveRangePatterns {
1768+ span : pat. span ,
1769+ suggestion : pat. span ,
17711770 replace,
1772- Applicability :: MachineApplicable ,
1773- )
1774- . emit ( ) ;
1771+ } ) ;
17751772 } else {
17761773 cx. struct_span_lint ( ELLIPSIS_INCLUSIVE_RANGE_PATTERNS , pat. span , |lint| {
17771774 lint. build ( msg)
@@ -1787,18 +1784,11 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
17871784 } else {
17881785 let replace = "..=" ;
17891786 if join. edition ( ) >= Edition :: Edition2021 {
1790- let mut err = cx. sess ( ) . struct_span_err_with_code (
1791- pat. span ,
1792- msg,
1793- rustc_errors:: error_code!( E0783 ) ,
1794- ) ;
1795- err. span_suggestion_short (
1796- join,
1797- suggestion,
1798- replace,
1799- Applicability :: MachineApplicable ,
1800- )
1801- . emit ( ) ;
1787+ cx. sess ( ) . emit_err ( BuiltinEllpisisInclusiveRangePatterns {
1788+ span : pat. span ,
1789+ suggestion : join,
1790+ replace : replace. to_string ( ) ,
1791+ } ) ;
18021792 } else {
18031793 cx. struct_span_lint ( ELLIPSIS_INCLUSIVE_RANGE_PATTERNS , join, |lint| {
18041794 lint. build ( msg)
0 commit comments