@@ -76,10 +76,22 @@ pub struct LintStore {
76
76
/// is true if the lint group was added by a plugin.
77
77
lint_groups : FnvHashMap < & ' static str , ( Vec < LintId > , bool ) > ,
78
78
79
+ /// Extra info for future incompatibility lints, descibing the
80
+ /// issue or RFC that caused the incompatibility.
81
+ future_incompatible : FnvHashMap < LintId , FutureIncompatibleInfo > ,
82
+
79
83
/// Maximum level a lint can be
80
84
lint_cap : Option < Level > ,
81
85
}
82
86
87
+ /// Extra information for a future incompatibility lint. See the call
88
+ /// to `register_future_incompatible` in `librustc_lint/lib.rs` for
89
+ /// guidelines.
90
+ pub struct FutureIncompatibleInfo {
91
+ pub id : LintId ,
92
+ pub reference : & ' static str // e.g., a URL for an issue/PR/RFC or error code
93
+ }
94
+
83
95
/// The targed of the `by_name` map, which accounts for renaming/deprecation.
84
96
enum TargetLint {
85
97
/// A direct lint target
@@ -124,6 +136,7 @@ impl LintStore {
124
136
late_passes : Some ( vec ! ( ) ) ,
125
137
by_name : FnvHashMap ( ) ,
126
138
levels : FnvHashMap ( ) ,
139
+ future_incompatible : FnvHashMap ( ) ,
127
140
lint_groups : FnvHashMap ( ) ,
128
141
lint_cap : None ,
129
142
}
@@ -183,6 +196,20 @@ impl LintStore {
183
196
}
184
197
}
185
198
199
+ pub fn register_future_incompatible ( & mut self ,
200
+ sess : Option < & Session > ,
201
+ lints : Vec < FutureIncompatibleInfo > ) {
202
+ let ids = lints. iter ( ) . map ( |f| f. id ) . collect ( ) ;
203
+ self . register_group ( sess, false , "future_incompatible" , ids) ;
204
+ for info in lints {
205
+ self . future_incompatible . insert ( info. id , info) ;
206
+ }
207
+ }
208
+
209
+ pub fn future_incompatible ( & self , id : LintId ) -> Option < & FutureIncompatibleInfo > {
210
+ self . future_incompatible . get ( & id)
211
+ }
212
+
186
213
pub fn register_group ( & mut self , sess : Option < & Session > ,
187
214
from_plugin : bool , name : & ' static str ,
188
215
to : Vec < LintId > ) {
@@ -418,14 +445,18 @@ pub fn raw_struct_lint<'a>(sess: &'a Session,
418
445
} ;
419
446
420
447
// Check for future incompatibility lints and issue a stronger warning.
421
- let future_incompat_lints = & lints. lint_groups [ builtin:: FUTURE_INCOMPATIBLE ] ;
422
- let this_id = LintId :: of ( lint) ;
423
- if future_incompat_lints. 0 . iter ( ) . any ( |& id| id == this_id) {
424
- let msg = "this lint will become a HARD ERROR in a future release!" ;
448
+ if let Some ( future_incompatible) = lints. future_incompatible ( LintId :: of ( lint) ) {
449
+ let explanation = format ! ( "this was previously accepted by the compiler \
450
+ but is being phased out; \
451
+ it will become a hard error in a future release!") ;
452
+ let citation = format ! ( "for more information, see {}" ,
453
+ future_incompatible. reference) ;
425
454
if let Some ( sp) = span {
426
- err. span_note ( sp, msg) ;
455
+ err. fileline_warn ( sp, & explanation) ;
456
+ err. fileline_note ( sp, & citation) ;
427
457
} else {
428
- err. note ( msg) ;
458
+ err. warn ( & explanation) ;
459
+ err. note ( & citation) ;
429
460
}
430
461
}
431
462
0 commit comments