make emit_feature_err take a ParseSess
This commit is contained in:
@@ -679,16 +679,15 @@ impl GatedCfg {
|
||||
pub fn check_and_emit(&self, sess: &ParseSess, features: &Features) {
|
||||
let (cfg, feature, has_feature) = GATED_CFGS[self.index];
|
||||
if !has_feature(features) && !sess.codemap().span_allows_unstable(self.span) {
|
||||
let diagnostic = &sess.span_diagnostic;
|
||||
let explain = format!("`cfg({})` is experimental and subject to change", cfg);
|
||||
emit_feature_err(diagnostic, feature, self.span, GateIssue::Language, &explain);
|
||||
emit_feature_err(sess, feature, self.span, GateIssue::Language, &explain);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct Context<'a> {
|
||||
features: &'a Features,
|
||||
span_handler: &'a Handler,
|
||||
parse_sess: &'a ParseSess,
|
||||
cm: &'a CodeMap,
|
||||
plugin_attributes: &'a [(String, AttributeType)],
|
||||
}
|
||||
@@ -699,7 +698,7 @@ macro_rules! gate_feature_fn {
|
||||
let has_feature: bool = has_feature(&$cx.features);
|
||||
debug!("gate_feature(feature = {:?}, span = {:?}); has? {}", name, span, has_feature);
|
||||
if !has_feature && !cx.cm.span_allows_unstable(span) {
|
||||
emit_feature_err(cx.span_handler, name, span, GateIssue::Language, explain);
|
||||
emit_feature_err(cx.parse_sess, name, span, GateIssue::Language, explain);
|
||||
}
|
||||
}}
|
||||
}
|
||||
@@ -756,10 +755,10 @@ impl<'a> Context<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check_attribute(attr: &ast::Attribute, handler: &Handler,
|
||||
pub fn check_attribute(attr: &ast::Attribute, parse_sess: &ParseSess,
|
||||
cm: &CodeMap, features: &Features) {
|
||||
let cx = Context {
|
||||
features: features, span_handler: handler,
|
||||
features: features, parse_sess: parse_sess,
|
||||
cm: cm, plugin_attributes: &[]
|
||||
};
|
||||
cx.check_attribute(attr, true);
|
||||
@@ -788,8 +787,10 @@ pub enum GateIssue {
|
||||
Library(Option<u32>)
|
||||
}
|
||||
|
||||
pub fn emit_feature_err(diag: &Handler, feature: &str, span: Span, issue: GateIssue,
|
||||
pub fn emit_feature_err(sess: &ParseSess, feature: &str, span: Span, issue: GateIssue,
|
||||
explain: &str) {
|
||||
let diag = &sess.span_diagnostic;
|
||||
|
||||
let issue = match issue {
|
||||
GateIssue::Language => find_lang_feature_issue(feature),
|
||||
GateIssue::Library(lib) => lib,
|
||||
@@ -962,9 +963,10 @@ impl<'a> Visitor for PostExpansionVisitor<'a> {
|
||||
if attr::contains_name(&i.attrs[..], "simd") {
|
||||
gate_feature_post!(&self, simd, i.span,
|
||||
"SIMD types are experimental and possibly buggy");
|
||||
self.context.span_handler.span_warn(i.span,
|
||||
"the `#[simd]` attribute is deprecated, \
|
||||
use `#[repr(simd)]` instead");
|
||||
self.context.parse_sess.span_diagnostic.span_warn(i.span,
|
||||
"the `#[simd]` attribute \
|
||||
is deprecated, use \
|
||||
`#[repr(simd)]` instead");
|
||||
}
|
||||
for attr in &i.attrs {
|
||||
if attr.name() == "repr" {
|
||||
@@ -1273,7 +1275,7 @@ pub fn check_crate(krate: &ast::Crate,
|
||||
maybe_stage_features(&sess.span_diagnostic, krate, unstable);
|
||||
let ctx = Context {
|
||||
features: features,
|
||||
span_handler: &sess.span_diagnostic,
|
||||
parse_sess: sess,
|
||||
cm: sess.codemap(),
|
||||
plugin_attributes: plugin_attributes,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user