@@ -77,8 +77,9 @@ pub struct Lint {
7777 /// e.g. "imports that are never used"
7878 pub desc : & ' static str ,
7979
80- /// Deny lint after this edition
81- pub edition_deny : Option < Edition > ,
80+ /// Starting at the given edition, default to the given lint level. If this is `None`, then use
81+ /// `default_level`.
82+ pub edition_lint_opts : Option < ( Edition , Level ) > ,
8283}
8384
8485impl Lint {
@@ -88,41 +89,40 @@ impl Lint {
8889 }
8990
9091 pub fn default_level ( & self , session : & Session ) -> Level {
91- if let Some ( edition_deny) = self . edition_deny {
92- if session. edition ( ) >= edition_deny {
93- return Level :: Deny
94- }
95- }
96- self . default_level
92+ self . edition_lint_opts
93+ . filter ( |( e, _) | * e <= session. edition ( ) )
94+ . map ( |( _, l) | l)
95+ . unwrap_or ( self . default_level )
9796 }
9897}
9998
10099/// Declare a static item of type `&'static Lint`.
101100#[ macro_export]
102101macro_rules! declare_lint {
103- ( $vis: vis $NAME: ident, $Level: ident, $desc: expr, $edition : expr ) => (
102+ ( $vis: vis $NAME: ident, $Level: ident, $desc: expr) => (
104103 $vis static $NAME: & $crate:: lint:: Lint = & $crate:: lint:: Lint {
105104 name: stringify!( $NAME) ,
106105 default_level: $crate:: lint:: $Level,
107106 desc: $desc,
108- edition_deny : Some ( $edition )
107+ edition_lint_opts : None ,
109108 } ;
110109 ) ;
111- ( $vis: vis $NAME: ident, $Level: ident, $desc: expr) => (
110+ ( $vis: vis $NAME: ident, $Level: ident, $desc: expr,
111+ $lint_edition: expr => $edition_level: ident $( , ) ?
112+ ) => (
112113 $vis static $NAME: & $crate:: lint:: Lint = & $crate:: lint:: Lint {
113114 name: stringify!( $NAME) ,
114115 default_level: $crate:: lint:: $Level,
115116 desc: $desc,
116- edition_deny : None ,
117+ edition_lint_opts : Some ( ( $lint_edition , $crate :: lint :: Level :: $edition_level ) ) ,
117118 } ;
118119 ) ;
119120}
120121
121122/// Declare a static `LintArray` and return it as an expression.
122123#[ macro_export]
123124macro_rules! lint_array {
124- ( $( $lint: expr ) ,* , ) => { lint_array!( $( $lint ) ,* ) } ;
125- ( $( $lint: expr ) ,* ) => { {
125+ ( $( $lint: expr ) ,* $( , ) ?) => { {
126126 static ARRAY : LintArray = & [ $( & $lint ) ,* ] ;
127127 ARRAY
128128 } }
0 commit comments