1
+ // #![deny(rustc::diagnostic_outside_of_impl)]
2
+ // #![deny(rustc::untranslatable_diagnostic)]
3
+ //
1
4
//! Lints in the Rust compiler.
2
5
//!
3
6
//! This contains lints which can feasibly be implemented as their own
21
24
//! `late_lint_methods!` invocation in `lib.rs`.
22
25
23
26
use crate :: {
27
+ errors:: BuiltinEllpisisInclusiveRangePatterns ,
24
28
types:: { transparent_newtype_field, CItemKind } ,
25
29
EarlyContext , EarlyLintPass , LateContext , LateLintPass , LintContext ,
26
30
} ;
@@ -1760,18 +1764,11 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
1760
1764
None => format ! ( "&(..={})" , end) ,
1761
1765
} ;
1762
1766
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 ,
1771
1770
replace,
1772
- Applicability :: MachineApplicable ,
1773
- )
1774
- . emit ( ) ;
1771
+ } ) ;
1775
1772
} else {
1776
1773
cx. struct_span_lint ( ELLIPSIS_INCLUSIVE_RANGE_PATTERNS , pat. span , |lint| {
1777
1774
lint. build ( msg)
@@ -1787,18 +1784,11 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
1787
1784
} else {
1788
1785
let replace = "..=" ;
1789
1786
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
+ } ) ;
1802
1792
} else {
1803
1793
cx. struct_span_lint ( ELLIPSIS_INCLUSIVE_RANGE_PATTERNS , join, |lint| {
1804
1794
lint. build ( msg)
0 commit comments