@@ -679,16 +679,15 @@ impl GatedCfg {
679
679
pub fn check_and_emit ( & self , sess : & ParseSess , features : & Features ) {
680
680
let ( cfg, feature, has_feature) = GATED_CFGS [ self . index ] ;
681
681
if !has_feature ( features) && !sess. codemap ( ) . span_allows_unstable ( self . span ) {
682
- let diagnostic = & sess. span_diagnostic ;
683
682
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) ;
685
684
}
686
685
}
687
686
}
688
687
689
688
struct Context < ' a > {
690
689
features : & ' a Features ,
691
- span_handler : & ' a Handler ,
690
+ parse_sess : & ' a ParseSess ,
692
691
cm : & ' a CodeMap ,
693
692
plugin_attributes : & ' a [ ( String , AttributeType ) ] ,
694
693
}
@@ -699,7 +698,7 @@ macro_rules! gate_feature_fn {
699
698
let has_feature: bool = has_feature( & $cx. features) ;
700
699
debug!( "gate_feature(feature = {:?}, span = {:?}); has? {}" , name, span, has_feature) ;
701
700
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) ;
703
702
}
704
703
} }
705
704
}
@@ -756,10 +755,10 @@ impl<'a> Context<'a> {
756
755
}
757
756
}
758
757
759
- pub fn check_attribute ( attr : & ast:: Attribute , handler : & Handler ,
758
+ pub fn check_attribute ( attr : & ast:: Attribute , parse_sess : & ParseSess ,
760
759
cm : & CodeMap , features : & Features ) {
761
760
let cx = Context {
762
- features : features, span_handler : handler ,
761
+ features : features, parse_sess : parse_sess ,
763
762
cm : cm, plugin_attributes : & [ ]
764
763
} ;
765
764
cx. check_attribute ( attr, true ) ;
@@ -788,8 +787,10 @@ pub enum GateIssue {
788
787
Library ( Option < u32 > )
789
788
}
790
789
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 ,
792
791
explain : & str ) {
792
+ let diag = & sess. span_diagnostic ;
793
+
793
794
let issue = match issue {
794
795
GateIssue :: Language => find_lang_feature_issue ( feature) ,
795
796
GateIssue :: Library ( lib) => lib,
@@ -962,9 +963,10 @@ impl<'a> Visitor for PostExpansionVisitor<'a> {
962
963
if attr:: contains_name ( & i. attrs [ ..] , "simd" ) {
963
964
gate_feature_post ! ( & self , simd, i. span,
964
965
"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") ;
968
970
}
969
971
for attr in & i. attrs {
970
972
if attr. name ( ) == "repr" {
@@ -1273,7 +1275,7 @@ pub fn check_crate(krate: &ast::Crate,
1273
1275
maybe_stage_features ( & sess. span_diagnostic , krate, unstable) ;
1274
1276
let ctx = Context {
1275
1277
features : features,
1276
- span_handler : & sess. span_diagnostic ,
1278
+ parse_sess : sess,
1277
1279
cm : sess. codemap ( ) ,
1278
1280
plugin_attributes : plugin_attributes,
1279
1281
} ;
0 commit comments