@@ -29,6 +29,7 @@ use self::TargetLint::*;
2929use std:: slice;
3030use lint:: { EarlyLintPassObject , LateLintPassObject } ;
3131use lint:: { Level , Lint , LintId , LintPass , LintBuffer } ;
32+ use lint:: builtin:: BuiltinLintDiagnostics ;
3233use lint:: levels:: { LintLevelSets , LintLevelsBuilder } ;
3334use middle:: privacy:: AccessLevels ;
3435use rustc_serialize:: { Decoder , Decodable , Encoder , Encodable } ;
@@ -92,6 +93,7 @@ pub struct BufferedEarlyLint {
9293 pub ast_id : ast:: NodeId ,
9394 pub span : MultiSpan ,
9495 pub msg : String ,
96+ pub diagnostic : BuiltinLintDiagnostics ,
9597}
9698
9799/// Extra information for a future incompatibility lint. See the call
@@ -446,6 +448,16 @@ pub trait LintContext<'tcx>: Sized {
446448 self . lookup ( lint, span, msg) . emit ( ) ;
447449 }
448450
451+ fn lookup_and_emit_with_diagnostics < S : Into < MultiSpan > > ( & self ,
452+ lint : & ' static Lint ,
453+ span : Option < S > ,
454+ msg : & str ,
455+ diagnostic : BuiltinLintDiagnostics ) {
456+ let mut db = self . lookup ( lint, span, msg) ;
457+ diagnostic. run ( self . sess ( ) , & mut db) ;
458+ db. emit ( ) ;
459+ }
460+
449461 fn lookup < S : Into < MultiSpan > > ( & self ,
450462 lint : & ' static Lint ,
451463 span : Option < S > ,
@@ -516,9 +528,10 @@ impl<'a> EarlyContext<'a> {
516528
517529 fn check_id ( & mut self , id : ast:: NodeId ) {
518530 for early_lint in self . buffered . take ( id) {
519- self . lookup_and_emit ( early_lint. lint_id . lint ,
520- Some ( early_lint. span . clone ( ) ) ,
521- & early_lint. msg ) ;
531+ self . lookup_and_emit_with_diagnostics ( early_lint. lint_id . lint ,
532+ Some ( early_lint. span . clone ( ) ) ,
533+ & early_lint. msg ,
534+ early_lint. diagnostic ) ;
522535 }
523536 }
524537}
0 commit comments