Skip to content

Commit b0dba74

Browse files
committedSep 26, 2016
make emit_feature_err take a ParseSess
1 parent 9966397 commit b0dba74

File tree

12 files changed

+26
-24
lines changed

12 files changed

+26
-24
lines changed
 

‎src/librustc/middle/stability.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,8 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
411411
&feature, &r),
412412
None => format!("use of unstable library feature '{}'", &feature)
413413
};
414-
emit_feature_err(&self.tcx.sess.parse_sess.span_diagnostic,
415-
&feature, span, GateIssue::Library(Some(issue)), &msg);
414+
emit_feature_err(&self.tcx.sess.parse_sess, &feature, span,
415+
GateIssue::Library(Some(issue)), &msg);
416416
}
417417
}
418418
Some(&Stability { ref level, ref feature, .. }) => {

‎src/librustc_passes/static_recursion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl<'a, 'ast: 'a> CheckItemRecursionVisitor<'a, 'ast> {
143143
});
144144
if any_static {
145145
if !self.sess.features.borrow().static_recursion {
146-
emit_feature_err(&self.sess.parse_sess.span_diagnostic,
146+
emit_feature_err(&self.sess.parse_sess,
147147
"static_recursion",
148148
*self.root_span,
149149
GateIssue::Language,

‎src/librustc_typeck/astconv.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
795795
// For now, require that parenthetical notation be used
796796
// only with `Fn()` etc.
797797
if !self.tcx().sess.features.borrow().unboxed_closures && trait_def.paren_sugar {
798-
emit_feature_err(&self.tcx().sess.parse_sess.span_diagnostic,
798+
emit_feature_err(&self.tcx().sess.parse_sess,
799799
"unboxed_closures", span, GateIssue::Language,
800800
"\
801801
the precise format of `Fn`-family traits' \
@@ -807,7 +807,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
807807
// For now, require that parenthetical notation be used
808808
// only with `Fn()` etc.
809809
if !self.tcx().sess.features.borrow().unboxed_closures && !trait_def.paren_sugar {
810-
emit_feature_err(&self.tcx().sess.parse_sess.span_diagnostic,
810+
emit_feature_err(&self.tcx().sess.parse_sess,
811811
"unboxed_closures", span, GateIssue::Language,
812812
"\
813813
parenthetical notation is only stable when used with `Fn`-family traits");

‎src/librustc_typeck/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3256,7 +3256,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
32563256
if let Some((def_id, variant)) = variant {
32573257
if variant.kind == ty::VariantKind::Tuple &&
32583258
!self.tcx.sess.features.borrow().relaxed_adts {
3259-
emit_feature_err(&self.tcx.sess.parse_sess.span_diagnostic,
3259+
emit_feature_err(&self.tcx.sess.parse_sess,
32603260
"relaxed_adts", span, GateIssue::Language,
32613261
"tuple structs and variants in struct patterns are unstable");
32623262
}

‎src/libsyntax/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl<'a> StripUnconfigured<'a> {
157157
// flag the offending attributes
158158
for attr in attrs.iter() {
159159
if !self.features.map(|features| features.stmt_expr_attributes).unwrap_or(true) {
160-
emit_feature_err(&self.sess.span_diagnostic,
160+
emit_feature_err(&self.sess,
161161
"stmt_expr_attributes",
162162
attr.span,
163163
GateIssue::Language,

‎src/libsyntax/ext/expand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
344344
// Detect use of feature-gated or invalid attributes on macro invoations
345345
// since they will not be detected after macro expansion.
346346
for attr in attrs.iter() {
347-
feature_gate::check_attribute(&attr, &self.cx.parse_sess.span_diagnostic,
347+
feature_gate::check_attribute(&attr, &self.cx.parse_sess,
348348
&self.cx.parse_sess.codemap(),
349349
&self.cx.ecfg.features.unwrap());
350350
}

‎src/libsyntax/feature_gate.rs

+13-11
Original file line numberDiff line numberDiff line change
@@ -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

689688
struct 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
};

‎src/libsyntax_ext/asm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt,
5353
tts: &[tokenstream::TokenTree])
5454
-> Box<base::MacResult + 'cx> {
5555
if !cx.ecfg.enable_asm() {
56-
feature_gate::emit_feature_err(&cx.parse_sess.span_diagnostic,
56+
feature_gate::emit_feature_err(&cx.parse_sess,
5757
"asm",
5858
sp,
5959
feature_gate::GateIssue::Language,

‎src/libsyntax_ext/concat_idents.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt,
2323
tts: &[TokenTree])
2424
-> Box<base::MacResult + 'cx> {
2525
if !cx.ecfg.enable_concat_idents() {
26-
feature_gate::emit_feature_err(&cx.parse_sess.span_diagnostic,
26+
feature_gate::emit_feature_err(&cx.parse_sess,
2727
"concat_idents",
2828
sp,
2929
feature_gate::GateIssue::Language,

‎src/libsyntax_ext/deriving/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ pub fn expand_derive(cx: &mut ExtCtxt,
221221
// the old custom derive mechanism. If the feature isn't enabled, we
222222
// issue an error, otherwise manufacture the `derive_Foo` attribute.
223223
} else if !cx.ecfg.enable_custom_derive() {
224-
feature_gate::emit_feature_err(&cx.parse_sess.span_diagnostic,
224+
feature_gate::emit_feature_err(&cx.parse_sess,
225225
"custom_derive",
226226
titem.span,
227227
feature_gate::GateIssue::Language,

‎src/libsyntax_ext/log_syntax.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut base::ExtCtxt,
1919
tts: &[tokenstream::TokenTree])
2020
-> Box<base::MacResult + 'cx> {
2121
if !cx.ecfg.enable_log_syntax() {
22-
feature_gate::emit_feature_err(&cx.parse_sess.span_diagnostic,
22+
feature_gate::emit_feature_err(&cx.parse_sess,
2323
"log_syntax",
2424
sp,
2525
feature_gate::GateIssue::Language,

‎src/libsyntax_ext/trace_macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub fn expand_trace_macros(cx: &mut ExtCtxt,
2020
tt: &[TokenTree])
2121
-> Box<base::MacResult + 'static> {
2222
if !cx.ecfg.enable_trace_macros() {
23-
feature_gate::emit_feature_err(&cx.parse_sess.span_diagnostic,
23+
feature_gate::emit_feature_err(&cx.parse_sess,
2424
"trace_macros",
2525
sp,
2626
feature_gate::GateIssue::Language,

0 commit comments

Comments
 (0)
Please sign in to comment.