diff options
Diffstat (limited to 'src/librustc/lint/context.rs')
| -rw-r--r-- | src/librustc/lint/context.rs | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 5c0fd894436..fa451e03ab9 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -104,7 +104,7 @@ impl LintStore { } pub fn get_lints<'t>(&'t self) -> &'t [(&'static Lint, bool)] { - self.lints[] + self.lints.index(&FullRange) } pub fn get_lint_groups<'t>(&'t self) -> Vec<(&'static str, Vec<LintId>, bool)> { @@ -124,11 +124,11 @@ impl LintStore { 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[]), - (Some(sess), false) => sess.bug(msg[]), + (None, _) => early_error(msg.index(&FullRange)), + (Some(sess), false) => sess.bug(msg.index(&FullRange)), // A duplicate name from a plugin is a user error. - (Some(sess), true) => sess.err(msg[]), + (Some(sess), true) => sess.err(msg.index(&FullRange)), } } @@ -149,11 +149,11 @@ impl LintStore { 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[]), - (Some(sess), false) => sess.bug(msg[]), + (None, _) => early_error(msg.index(&FullRange)), + (Some(sess), false) => sess.bug(msg.index(&FullRange)), // A duplicate name from a plugin is a user error. - (Some(sess), true) => sess.err(msg[]), + (Some(sess), true) => sess.err(msg.index(&FullRange)), } } } @@ -267,8 +267,8 @@ impl LintStore { let warning = format!("lint {} has been renamed to {}", lint_name, new_name); match span { - Some(span) => sess.span_warn(span, warning[]), - None => sess.warn(warning[]), + Some(span) => sess.span_warn(span, warning.index(&FullRange)), + None => sess.warn(warning.index(&FullRange)), }; Some(lint_id) } @@ -278,13 +278,13 @@ impl LintStore { 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[], sess, None) { + match self.find_lint(lint_name.index(&FullRange), 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[]) { + .get(lint_name.index(&FullRange)) { Some(v) => { v.iter() .map(|lint_id: &LintId| @@ -292,7 +292,7 @@ impl LintStore { .collect::<Vec<()>>(); } None => sess.err(format!("unknown {} flag: {}", - level.as_str(), lint_name)[]), + level.as_str(), lint_name).index(&FullRange)), } } } @@ -403,10 +403,10 @@ pub fn raw_emit_lint(sess: &Session, lint: &'static Lint, if level == Forbid { level = Deny; } match (level, span) { - (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[]), + (Warn, Some(sp)) => sess.span_warn(sp, msg.index(&FullRange)), + (Warn, None) => sess.warn(msg.index(&FullRange)), + (Deny, Some(sp)) => sess.span_err(sp, msg.index(&FullRange)), + (Deny, None) => sess.err(msg.index(&FullRange)), _ => sess.bug("impossible level in raw_emit_lint"), } @@ -499,7 +499,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> { None => { self.span_lint(builtin::UNKNOWN_LINTS, span, format!("unknown `{}` attribute: `{}`", - level.as_str(), lint_name)[]); + level.as_str(), lint_name).index(&FullRange)); continue; } } @@ -515,7 +515,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> { self.tcx.sess.span_err(span, format!("{}({}) overruled by outer forbid({})", level.as_str(), lint_name, - lint_name)[]); + lint_name).index(&FullRange)); } else if now != level { let src = self.lints.get_level_source(lint_id).1; self.level_stack.push((lint_id, (now, src))); @@ -550,7 +550,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> { impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> { fn visit_item(&mut self, it: &ast::Item) { - self.with_lint_attrs(it.attrs[], |cx| { + self.with_lint_attrs(it.attrs.index(&FullRange), |cx| { run_lints!(cx, check_item, it); cx.visit_ids(|v| v.visit_item(it)); visit::walk_item(cx, it); @@ -558,14 +558,14 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> { } fn visit_foreign_item(&mut self, it: &ast::ForeignItem) { - self.with_lint_attrs(it.attrs[], |cx| { + self.with_lint_attrs(it.attrs.index(&FullRange), |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[], |cx| { + self.with_lint_attrs(i.attrs.index(&FullRange), |cx| { run_lints!(cx, check_view_item, i); cx.visit_ids(|v| v.visit_view_item(i)); visit::walk_view_item(cx, i); @@ -591,7 +591,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> { body: &'v ast::Block, span: Span, id: ast::NodeId) { match fk { visit::FkMethod(_, _, m) => { - self.with_lint_attrs(m.attrs[], |cx| { + self.with_lint_attrs(m.attrs.index(&FullRange), |cx| { run_lints!(cx, check_fn, fk, decl, body, span, id); cx.visit_ids(|v| { v.visit_fn(fk, decl, body, span, id); @@ -607,7 +607,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> { } fn visit_ty_method(&mut self, t: &ast::TypeMethod) { - self.with_lint_attrs(t.attrs[], |cx| { + self.with_lint_attrs(t.attrs.index(&FullRange), |cx| { run_lints!(cx, check_ty_method, t); visit::walk_ty_method(cx, t); }) @@ -624,14 +624,14 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> { } fn visit_struct_field(&mut self, s: &ast::StructField) { - self.with_lint_attrs(s.node.attrs[], |cx| { + self.with_lint_attrs(s.node.attrs.index(&FullRange), |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[], |cx| { + self.with_lint_attrs(v.node.attrs.index(&FullRange), |cx| { run_lints!(cx, check_variant, v, g); visit::walk_variant(cx, v, g); run_lints!(cx, check_variant_post, v, g); @@ -725,7 +725,7 @@ impl<'a, 'tcx> IdVisitingOperation for Context<'a, 'tcx> { None => {} Some(lints) => { for (lint_id, span, msg) in lints.into_iter() { - self.span_lint(lint_id.lint, span, msg[]) + self.span_lint(lint_id.lint, span, msg.index(&FullRange)) } } } @@ -771,7 +771,7 @@ pub fn check_crate(tcx: &ty::ctxt, let mut cx = Context::new(tcx, krate, exported_items); // Visit the whole crate. - cx.with_lint_attrs(krate.attrs[], |cx| { + cx.with_lint_attrs(krate.attrs.index(&FullRange), |cx| { cx.visit_id(ast::CRATE_NODE_ID); cx.visit_ids(|v| { v.visited_outermost = true; @@ -791,7 +791,7 @@ pub fn check_crate(tcx: &ty::ctxt, 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)[]) + lint.as_str(), tcx.map.node_to_string(*id), *msg).index(&FullRange)) } } |
