("non_ascii_idents", "1.0.0", Active),
("thread_local", "1.0.0", Active),
("link_args", "1.0.0", Active),
- ("phase", "1.0.0", Removed),
("plugin_registrar", "1.0.0", Active),
("log_syntax", "1.0.0", Active),
("trace_macros", "1.0.0", Active),
("rustc_diagnostic_macros", "1.0.0", Active),
("unboxed_closures", "1.0.0", Active),
+ ("reflect", "1.0.0", Active),
("import_shadowing", "1.0.0", Removed),
("advanced_slice_patterns", "1.0.0", Active),
("tuple_indexing", "1.0.0", Accepted),
// OIBIT specific features
("optin_builtin_traits", "1.0.0", Active),
- // int and uint are now deprecated
- ("int_uint", "1.0.0", Active),
-
// macro reexport needs more discussion and stabilization
("macro_reexport", "1.0.0", Active),
("no_mangle", Normal),
("no_link", Normal),
("derive", Normal),
- ("should_fail", Normal),
("should_panic", Normal),
("ignore", Normal),
("no_implicit_prelude", Normal),
// FIXME: #19470 this shouldn't be needed forever
("old_orphan_check", Whitelisted),
- ("rustc_paren_sugar", Whitelisted), // FIXME: #18101 temporary unboxed closure hack
+
+ ("rustc_paren_sugar", Gated("unboxed_closures",
+ "unboxed_closures are still evolving")),
+ ("rustc_reflect_like", Gated("reflect",
+ "defining reflective traits is still evolving")),
// Crate level attributes
("crate_name", CrateLevel),
features: Vec<&'static str>,
span_handler: &'a SpanHandler,
cm: &'a CodeMap,
- do_warnings: bool,
}
impl<'a> Context<'a> {
emit_feature_err(self.span_handler, feature, span, explain);
}
}
-
- fn warn_feature(&self, feature: &str, span: Span, explain: &str) {
- if !self.has_feature(feature) && self.do_warnings {
- emit_feature_warn(self.span_handler, feature, span, explain);
- }
- }
fn has_feature(&self, feature: &str) -> bool {
self.features.iter().any(|&n| n == feature)
}
visit::walk_foreign_item(self, i)
}
- fn visit_ty(&mut self, t: &ast::Ty) {
- match t.node {
- ast::TyPath(None, ref p) => {
- match &*p.segments {
-
- [ast::PathSegment { identifier, .. }] => {
- let name = token::get_ident(identifier);
- let msg = if name == "int" {
- Some("the `int` type is deprecated; \
- use `isize` or a fixed-sized integer")
- } else if name == "uint" {
- Some("the `uint` type is deprecated; \
- use `usize` or a fixed-sized integer")
- } else {
- None
- };
-
- if let Some(msg) = msg {
- self.context.warn_feature("int_uint", t.span, msg)
- }
- }
- _ => {}
- }
- }
- _ => {}
- }
- visit::walk_ty(self, t);
- }
-
fn visit_expr(&mut self, e: &ast::Expr) {
match e.node {
ast::ExprBox(..) | ast::ExprUnary(ast::UnOp::UnUniq, _) => {
"box expression syntax is experimental; \
you can call `Box::new` instead.");
}
- ast::ExprLit(ref lit) => {
- match lit.node {
- ast::LitInt(_, ty) => {
- let msg = if let ast::SignedIntLit(ast::TyIs(true), _) = ty {
- Some("the `i` and `is` suffixes on integers are deprecated; \
- use `isize` or one of the fixed-sized suffixes")
- } else if let ast::UnsignedIntLit(ast::TyUs(true)) = ty {
- Some("the `u` and `us` suffixes on integers are deprecated; \
- use `usize` or one of the fixed-sized suffixes")
- } else {
- None
- };
- if let Some(msg) = msg {
- self.context.warn_feature("int_uint", e.span, msg);
- }
- }
- _ => {}
- }
- }
_ => {}
}
visit::walk_expr(self, e);
}
}
-fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::Crate,
- do_warnings: bool,
+fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler,
+ krate: &ast::Crate,
check: F)
-> Features
where F: FnOnce(&mut Context, &ast::Crate)
let mut cx = Context {
features: Vec::new(),
span_handler: span_handler,
- do_warnings: do_warnings,
cm: cm,
};
pub fn check_crate_macros(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::Crate)
-> Features {
- check_crate_inner(cm, span_handler, krate, true,
+ check_crate_inner(cm, span_handler, krate,
|ctx, krate| visit::walk_crate(&mut MacroVisitor { context: ctx }, krate))
}
-pub fn check_crate(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::Crate,
- do_warnings: bool) -> Features
+pub fn check_crate(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::Crate)
+ -> Features
{
- check_crate_inner(cm, span_handler, krate, do_warnings,
+ check_crate_inner(cm, span_handler, krate,
|ctx, krate| visit::walk_crate(&mut PostExpansionVisitor { context: ctx },
krate))
}