@@ -1660,7 +1660,11 @@ declare_lint! {
16601660 /// [`..` range expression]: https://doc.rust-lang.org/reference/expressions/range-expr.html
16611661 pub ELLIPSIS_INCLUSIVE_RANGE_PATTERNS ,
16621662 Warn ,
1663- "`...` range patterns are deprecated"
1663+ "`...` range patterns are deprecated" ,
1664+ @future_incompatible = FutureIncompatibleInfo {
1665+ reference: "issue #80165 <https://github.com/rust-lang/rust/issues/80165>" ,
1666+ edition: Some ( Edition :: Edition2021 ) ,
1667+ } ;
16641668}
16651669
16661670#[ derive( Default ) ]
@@ -1704,32 +1708,57 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
17041708 let suggestion = "use `..=` for an inclusive range" ;
17051709 if parenthesise {
17061710 self . node_id = Some ( pat. id ) ;
1707- cx. struct_span_lint ( ELLIPSIS_INCLUSIVE_RANGE_PATTERNS , pat. span , |lint| {
1708- let end = expr_to_string ( & end) ;
1709- let replace = match start {
1710- Some ( start) => format ! ( "&({}..={})" , expr_to_string( & start) , end) ,
1711- None => format ! ( "&(..={})" , end) ,
1712- } ;
1713- lint. build ( msg)
1714- . span_suggestion (
1715- pat. span ,
1716- suggestion,
1717- replace,
1718- Applicability :: MachineApplicable ,
1719- )
1720- . emit ( ) ;
1721- } ) ;
1711+ let end = expr_to_string ( & end) ;
1712+ let replace = match start {
1713+ Some ( start) => format ! ( "&({}..={})" , expr_to_string( & start) , end) ,
1714+ None => format ! ( "&(..={})" , end) ,
1715+ } ;
1716+ if join. edition ( ) >= Edition :: Edition2021 {
1717+ let mut err =
1718+ rustc_errors:: struct_span_err!( cx. sess, pat. span, E0783 , "{}" , msg, ) ;
1719+ err. span_suggestion (
1720+ pat. span ,
1721+ suggestion,
1722+ replace,
1723+ Applicability :: MachineApplicable ,
1724+ )
1725+ . emit ( ) ;
1726+ } else {
1727+ cx. struct_span_lint ( ELLIPSIS_INCLUSIVE_RANGE_PATTERNS , pat. span , |lint| {
1728+ lint. build ( msg)
1729+ . span_suggestion (
1730+ pat. span ,
1731+ suggestion,
1732+ replace,
1733+ Applicability :: MachineApplicable ,
1734+ )
1735+ . emit ( ) ;
1736+ } ) ;
1737+ }
17221738 } else {
1723- cx. struct_span_lint ( ELLIPSIS_INCLUSIVE_RANGE_PATTERNS , join, |lint| {
1724- lint. build ( msg)
1725- . span_suggestion_short (
1726- join,
1727- suggestion,
1728- "..=" . to_owned ( ) ,
1729- Applicability :: MachineApplicable ,
1730- )
1731- . emit ( ) ;
1732- } ) ;
1739+ let replace = "..=" . to_owned ( ) ;
1740+ if join. edition ( ) >= Edition :: Edition2021 {
1741+ let mut err =
1742+ rustc_errors:: struct_span_err!( cx. sess, pat. span, E0783 , "{}" , msg, ) ;
1743+ err. span_suggestion_short (
1744+ join,
1745+ suggestion,
1746+ replace,
1747+ Applicability :: MachineApplicable ,
1748+ )
1749+ . emit ( ) ;
1750+ } else {
1751+ cx. struct_span_lint ( ELLIPSIS_INCLUSIVE_RANGE_PATTERNS , join, |lint| {
1752+ lint. build ( msg)
1753+ . span_suggestion_short (
1754+ join,
1755+ suggestion,
1756+ replace,
1757+ Applicability :: MachineApplicable ,
1758+ )
1759+ . emit ( ) ;
1760+ } ) ;
1761+ }
17331762 } ;
17341763 }
17351764 }
0 commit comments