@@ -679,16 +679,15 @@ impl GatedCfg {
679679 pub fn check_and_emit ( & self , sess : & ParseSess , features : & Features ) {
680680 let ( cfg, feature, has_feature) = GATED_CFGS [ self . index ] ;
681681 if !has_feature ( features) && !sess. codemap ( ) . span_allows_unstable ( self . span ) {
682- let diagnostic = & sess. span_diagnostic ;
683682 let explain = format ! ( "`cfg({})` is experimental and subject to change" , cfg) ;
684- emit_feature_err ( diagnostic , feature, self . span , GateIssue :: Language , & explain) ;
683+ emit_feature_err ( sess , feature, self . span , GateIssue :: Language , & explain) ;
685684 }
686685 }
687686}
688687
689688struct Context < ' a > {
690689 features : & ' a Features ,
691- span_handler : & ' a Handler ,
690+ parse_sess : & ' a ParseSess ,
692691 cm : & ' a CodeMap ,
693692 plugin_attributes : & ' a [ ( String , AttributeType ) ] ,
694693}
@@ -699,7 +698,7 @@ macro_rules! gate_feature_fn {
699698 let has_feature: bool = has_feature( & $cx. features) ;
700699 debug!( "gate_feature(feature = {:?}, span = {:?}); has? {}" , name, span, has_feature) ;
701700 if !has_feature && !cx. cm. span_allows_unstable( span) {
702- emit_feature_err( cx. span_handler , name, span, GateIssue :: Language , explain) ;
701+ emit_feature_err( cx. parse_sess , name, span, GateIssue :: Language , explain) ;
703702 }
704703 } }
705704}
@@ -756,10 +755,10 @@ impl<'a> Context<'a> {
756755 }
757756}
758757
759- pub fn check_attribute ( attr : & ast:: Attribute , handler : & Handler ,
758+ pub fn check_attribute ( attr : & ast:: Attribute , parse_sess : & ParseSess ,
760759 cm : & CodeMap , features : & Features ) {
761760 let cx = Context {
762- features : features, span_handler : handler ,
761+ features : features, parse_sess : parse_sess ,
763762 cm : cm, plugin_attributes : & [ ]
764763 } ;
765764 cx. check_attribute ( attr, true ) ;
@@ -788,8 +787,10 @@ pub enum GateIssue {
788787 Library ( Option < u32 > )
789788}
790789
791- pub fn emit_feature_err ( diag : & Handler , feature : & str , span : Span , issue : GateIssue ,
790+ pub fn emit_feature_err ( sess : & ParseSess , feature : & str , span : Span , issue : GateIssue ,
792791 explain : & str ) {
792+ let diag = & sess. span_diagnostic ;
793+
793794 let issue = match issue {
794795 GateIssue :: Language => find_lang_feature_issue ( feature) ,
795796 GateIssue :: Library ( lib) => lib,
@@ -962,9 +963,10 @@ impl<'a> Visitor for PostExpansionVisitor<'a> {
962963 if attr:: contains_name ( & i. attrs [ ..] , "simd" ) {
963964 gate_feature_post ! ( & self , simd, i. span,
964965 "SIMD types are experimental and possibly buggy" ) ;
965- self . context . span_handler . span_warn ( i. span ,
966- "the `#[simd]` attribute is deprecated, \
967- use `#[repr(simd)]` instead") ;
966+ self . context . parse_sess . span_diagnostic . span_warn ( i. span ,
967+ "the `#[simd]` attribute \
968+ is deprecated, use \
969+ `#[repr(simd)]` instead") ;
968970 }
969971 for attr in & i. attrs {
970972 if attr. name ( ) == "repr" {
@@ -1273,7 +1275,7 @@ pub fn check_crate(krate: &ast::Crate,
12731275 maybe_stage_features ( & sess. span_diagnostic , krate, unstable) ;
12741276 let ctx = Context {
12751277 features : features,
1276- span_handler : & sess. span_diagnostic ,
1278+ parse_sess : sess,
12771279 cm : sess. codemap ( ) ,
12781280 plugin_attributes : plugin_attributes,
12791281 } ;
0 commit comments