use self::TargetLint::*;
use middle::privacy::ExportedItems;
-use middle::ty::{mod, Ty};
+use middle::ty::{self, Ty};
use session::{early_error, Session};
use lint::{Level, LevelSource, Lint, LintId, LintArray, LintPass, LintPassObject};
use lint::{Default, CommandLine, Node, Allow, Warn, Deny, Forbid};
}
pub fn get_lints<'t>(&'t self) -> &'t [(&'static Lint, bool)] {
- self.lints.as_slice()
+ self.lints[]
}
pub fn get_lint_groups<'t>(&'t self) -> Vec<(&'static str, Vec<LintId>, bool)> {
match (sess, from_plugin) {
// We load builtin lints first, so a duplicate is a compiler bug.
// Use early_error when handling -W help with no crate.
- (None, _) => early_error(msg.as_slice()),
- (Some(sess), false) => sess.bug(msg.as_slice()),
+ (None, _) => early_error(msg[]),
+ (Some(sess), false) => sess.bug(msg[]),
// A duplicate name from a plugin is a user error.
- (Some(sess), true) => sess.err(msg.as_slice()),
+ (Some(sess), true) => sess.err(msg[]),
}
}
match (sess, from_plugin) {
// We load builtin lints first, so a duplicate is a compiler bug.
// Use early_error when handling -W help with no crate.
- (None, _) => early_error(msg.as_slice()),
- (Some(sess), false) => sess.bug(msg.as_slice()),
+ (None, _) => early_error(msg[]),
+ (Some(sess), false) => sess.bug(msg[]),
// A duplicate name from a plugin is a user error.
- (Some(sess), true) => sess.err(msg.as_slice()),
+ (Some(sess), true) => sess.err(msg[]),
}
}
}
}
pub fn register_builtin(&mut self, sess: Option<&Session>) {
- macro_rules! add_builtin ( ( $sess:ident, $($name:ident),*, ) => (
- {$(
- self.register_pass($sess, false, box builtin::$name as LintPassObject);
- )*}
- ));
-
- macro_rules! add_builtin_with_new ( ( $sess:ident, $($name:ident),*, ) => (
- {$(
- self.register_pass($sess, false, box builtin::$name::new() as LintPassObject);
- )*}
- ));
-
- macro_rules! add_lint_group ( ( $sess:ident, $name:expr, $($lint:ident),* ) => (
- self.register_group($sess, false, $name, vec![$(LintId::of(builtin::$lint)),*]);
- ));
+ macro_rules! add_builtin {
+ ($sess:ident, $($name:ident),*,) => (
+ {$(
+ self.register_pass($sess, false, box builtin::$name as LintPassObject);
+ )*}
+ )
+ }
+
+ macro_rules! add_builtin_with_new {
+ ($sess:ident, $($name:ident),*,) => (
+ {$(
+ self.register_pass($sess, false, box builtin::$name::new() as LintPassObject);
+ )*}
+ )
+ }
+
+ macro_rules! add_lint_group {
+ ($sess:ident, $name:expr, $($lint:ident),*) => (
+ self.register_group($sess, false, $name, vec![$(LintId::of(builtin::$lint)),*]);
+ )
+ }
add_builtin!(sess,
HardwiredLints,
add_builtin_with_new!(sess,
TypeLimits,
- RawPointerDeriving,
+ RawPointerDerive,
MissingDoc,
);
self.register_renamed("unknown_crate_type", "unknown_crate_types");
self.register_renamed("variant_size_difference", "variant_size_differences");
self.register_renamed("transmute_fat_ptr", "fat_ptr_transmutes");
+ self.register_renamed("raw_pointer_deriving", "raw_pointer_derive");
}
let warning = format!("lint {} has been renamed to {}",
lint_name, new_name);
match span {
- Some(span) => sess.span_warn(span, warning.as_slice()),
- None => sess.warn(warning.as_slice()),
+ Some(span) => sess.span_warn(span, warning[]),
+ None => sess.warn(warning[]),
};
Some(lint_id)
}
pub fn process_command_line(&mut self, sess: &Session) {
for &(ref lint_name, level) in sess.opts.lint_opts.iter() {
- match self.find_lint(lint_name.as_slice(), sess, None) {
+ match self.find_lint(lint_name[], sess, None) {
Some(lint_id) => self.set_level(lint_id, (level, CommandLine)),
None => {
match self.lint_groups.iter().map(|(&x, pair)| (x, pair.0.clone()))
.collect::<FnvHashMap<&'static str,
Vec<LintId>>>()
- .get(lint_name.as_slice()) {
+ .get(lint_name[]) {
Some(v) => {
v.iter()
.map(|lint_id: &LintId|
.collect::<Vec<()>>();
}
None => sess.err(format!("unknown {} flag: {}",
- level.as_str(), lint_name).as_slice()),
+ level.as_str(), lint_name)[]),
}
}
}
if level == Forbid { level = Deny; }
match (level, span) {
- (Warn, Some(sp)) => sess.span_warn(sp, msg.as_slice()),
- (Warn, None) => sess.warn(msg.as_slice()),
- (Deny, Some(sp)) => sess.span_err(sp, msg.as_slice()),
- (Deny, None) => sess.err(msg.as_slice()),
+ (Warn, Some(sp)) => sess.span_warn(sp, msg[]),
+ (Warn, None) => sess.warn(msg[]),
+ (Deny, Some(sp)) => sess.span_err(sp, msg[]),
+ (Deny, None) => sess.err(msg[]),
_ => sess.bug("impossible level in raw_emit_lint"),
}
None => {
self.span_lint(builtin::UNKNOWN_LINTS, span,
format!("unknown `{}` attribute: `{}`",
- level.as_str(), lint_name).as_slice());
+ level.as_str(), lint_name)[]);
continue;
}
}
self.tcx.sess.span_err(span,
format!("{}({}) overruled by outer forbid({})",
level.as_str(), lint_name,
- lint_name).as_slice());
+ lint_name)[]);
} else if now != level {
let src = self.lints.get_level_source(lint_id).1;
self.level_stack.push((lint_id, (now, src)));
impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
fn visit_item(&mut self, it: &ast::Item) {
- self.with_lint_attrs(it.attrs.as_slice(), |cx| {
+ self.with_lint_attrs(it.attrs[], |cx| {
run_lints!(cx, check_item, it);
cx.visit_ids(|v| v.visit_item(it));
visit::walk_item(cx, it);
}
fn visit_foreign_item(&mut self, it: &ast::ForeignItem) {
- self.with_lint_attrs(it.attrs.as_slice(), |cx| {
+ self.with_lint_attrs(it.attrs[], |cx| {
run_lints!(cx, check_foreign_item, it);
visit::walk_foreign_item(cx, it);
})
}
fn visit_view_item(&mut self, i: &ast::ViewItem) {
- self.with_lint_attrs(i.attrs.as_slice(), |cx| {
+ self.with_lint_attrs(i.attrs[], |cx| {
run_lints!(cx, check_view_item, i);
cx.visit_ids(|v| v.visit_view_item(i));
visit::walk_view_item(cx, i);
body: &'v ast::Block, span: Span, id: ast::NodeId) {
match fk {
visit::FkMethod(_, _, m) => {
- self.with_lint_attrs(m.attrs.as_slice(), |cx| {
+ self.with_lint_attrs(m.attrs[], |cx| {
run_lints!(cx, check_fn, fk, decl, body, span, id);
cx.visit_ids(|v| {
v.visit_fn(fk, decl, body, span, id);
}
fn visit_ty_method(&mut self, t: &ast::TypeMethod) {
- self.with_lint_attrs(t.attrs.as_slice(), |cx| {
+ self.with_lint_attrs(t.attrs[], |cx| {
run_lints!(cx, check_ty_method, t);
visit::walk_ty_method(cx, t);
})
}
fn visit_struct_field(&mut self, s: &ast::StructField) {
- self.with_lint_attrs(s.node.attrs.as_slice(), |cx| {
+ self.with_lint_attrs(s.node.attrs[], |cx| {
run_lints!(cx, check_struct_field, s);
visit::walk_struct_field(cx, s);
})
}
fn visit_variant(&mut self, v: &ast::Variant, g: &ast::Generics) {
- self.with_lint_attrs(v.node.attrs.as_slice(), |cx| {
+ self.with_lint_attrs(v.node.attrs[], |cx| {
run_lints!(cx, check_variant, v, g);
visit::walk_variant(cx, v, g);
run_lints!(cx, check_variant_post, v, g);
None => {}
Some(lints) => {
for (lint_id, span, msg) in lints.into_iter() {
- self.span_lint(lint_id.lint, span, msg.as_slice())
+ self.span_lint(lint_id.lint, span, msg[])
}
}
}
let mut cx = Context::new(tcx, krate, exported_items);
// Visit the whole crate.
- cx.with_lint_attrs(krate.attrs.as_slice(), |cx| {
+ cx.with_lint_attrs(krate.attrs[], |cx| {
cx.visit_id(ast::CRATE_NODE_ID);
cx.visit_ids(|v| {
v.visited_outermost = true;
for &(lint, span, ref msg) in v.iter() {
tcx.sess.span_bug(span,
format!("unprocessed lint {} at {}: {}",
- lint.as_str(), tcx.map.node_to_string(*id), *msg).as_slice())
+ lint.as_str(), tcx.map.node_to_string(*id), *msg)[])
}
}