diff options
Diffstat (limited to 'src/librustc/lint/builtin.rs')
| -rw-r--r-- | src/librustc/lint/builtin.rs | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 425e34cd9f0..1d446817c18 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -506,7 +506,7 @@ impl BoxPointers { if n_uniq > 0 { let s = ty_to_string(cx.tcx, ty); let m = format!("type uses owned (Box type) pointers: {}", s); - cx.span_lint(BOX_POINTERS, span, m[]); + cx.span_lint(BOX_POINTERS, span, m.index(&FullRange)); } } } @@ -586,7 +586,7 @@ impl LintPass for RawPointerDerive { } fn check_item(&mut self, cx: &Context, item: &ast::Item) { - if !attr::contains_name(item.attrs[], "automatically_derived") { + if !attr::contains_name(item.attrs.index(&FullRange), "automatically_derived") { return } let did = match item.node { @@ -769,11 +769,11 @@ impl LintPass for UnusedResults { ty::ty_enum(did, _) => { if ast_util::is_local(did) { if let ast_map::NodeItem(it) = cx.tcx.map.get(did.node) { - warned |= check_must_use(cx, it.attrs[], s.span); + warned |= check_must_use(cx, it.attrs.index(&FullRange), s.span); } } else { csearch::get_item_attrs(&cx.sess().cstore, did, |attrs| { - warned |= check_must_use(cx, attrs[], s.span); + warned |= check_must_use(cx, attrs.index(&FullRange), s.span); }); } } @@ -795,7 +795,7 @@ impl LintPass for UnusedResults { msg.push_str(s.get()); } } - cx.span_lint(UNUSED_MUST_USE, sp, msg[]); + cx.span_lint(UNUSED_MUST_USE, sp, msg.index(&FullRange)); return true; } } @@ -841,7 +841,7 @@ impl NonCamelCaseTypes { } else { format!("{} `{}` should have a camel case name such as `{}`", sort, s, c) }; - cx.span_lint(NON_CAMEL_CASE_TYPES, span, m[]); + cx.span_lint(NON_CAMEL_CASE_TYPES, span, m.index(&FullRange)); } } } @@ -981,7 +981,7 @@ impl NonSnakeCase { if !is_snake_case(ident) { cx.span_lint(NON_SNAKE_CASE, span, format!("{} `{}` should have a snake case name such as `{}`", - sort, s, to_snake_case(s.get()))[]); + sort, s, to_snake_case(s.get())).index(&FullRange)); } } } @@ -1068,7 +1068,7 @@ impl LintPass for NonUpperCaseGlobals { format!("static constant `{}` should have an uppercase name \ such as `{}`", s.get(), s.get().chars().map(|c| c.to_uppercase()) - .collect::<String>()[])[]); + .collect::<String>().index(&FullRange)).index(&FullRange)); } } _ => {} @@ -1085,7 +1085,7 @@ impl LintPass for NonUpperCaseGlobals { format!("static constant in pattern `{}` should have an uppercase \ name such as `{}`", s.get(), s.get().chars().map(|c| c.to_uppercase()) - .collect::<String>()[])[]); + .collect::<String>().index(&FullRange)).index(&FullRange)); } } _ => {} @@ -1110,7 +1110,7 @@ impl UnusedParens { if !necessary { cx.span_lint(UNUSED_PARENS, value.span, format!("unnecessary parentheses around {}", - msg)[]) + msg).index(&FullRange)) } } @@ -1212,7 +1212,7 @@ impl LintPass for UnusedImportBraces { let m = format!("braces around {} is unnecessary", token::get_ident(*name).get()); cx.span_lint(UNUSED_IMPORT_BRACES, view_item.span, - m[]); + m.index(&FullRange)); }, _ => () } @@ -1251,7 +1251,7 @@ impl LintPass for NonShorthandFieldPatterns { if ident.node.as_str() == fieldpat.node.ident.as_str() { cx.span_lint(NON_SHORTHAND_FIELD_PATTERNS, fieldpat.span, format!("the `{}:` in this pattern is redundant and can \ - be removed", ident.node.as_str())[]) + be removed", ident.node.as_str()).index(&FullRange)) } } } @@ -1355,7 +1355,7 @@ impl LintPass for UnusedMut { fn check_expr(&mut self, cx: &Context, e: &ast::Expr) { if let ast::ExprMatch(_, ref arms, _) = e.node { for a in arms.iter() { - self.check_unused_mut_pat(cx, a.pats[]) + self.check_unused_mut_pat(cx, a.pats.index(&FullRange)) } } } @@ -1476,7 +1476,7 @@ impl MissingDoc { }); if !has_doc { cx.span_lint(MISSING_DOCS, sp, - format!("missing documentation for {}", desc)[]); + format!("missing documentation for {}", desc).index(&FullRange)); } } } @@ -1490,7 +1490,7 @@ impl LintPass for MissingDoc { let doc_hidden = self.doc_hidden() || attrs.iter().any(|attr| { attr.check_name("doc") && match attr.meta_item_list() { None => false, - Some(l) => attr::contains_name(l[], "hidden"), + Some(l) => attr::contains_name(l.index(&FullRange), "hidden"), } }); self.doc_hidden_stack.push(doc_hidden); @@ -1512,7 +1512,7 @@ impl LintPass for MissingDoc { } fn check_crate(&mut self, cx: &Context, krate: &ast::Crate) { - self.check_missing_docs_attrs(cx, None, krate.attrs[], + self.check_missing_docs_attrs(cx, None, krate.attrs.index(&FullRange), krate.span, "crate"); } @@ -1526,7 +1526,7 @@ impl LintPass for MissingDoc { ast::ItemTy(..) => "a type alias", _ => return }; - self.check_missing_docs_attrs(cx, Some(it.id), it.attrs[], + self.check_missing_docs_attrs(cx, Some(it.id), it.attrs.index(&FullRange), it.span, desc); } @@ -1539,13 +1539,13 @@ impl LintPass for MissingDoc { // Otherwise, doc according to privacy. This will also check // doc for default methods defined on traits. - self.check_missing_docs_attrs(cx, Some(m.id), m.attrs[], + self.check_missing_docs_attrs(cx, Some(m.id), m.attrs.index(&FullRange), m.span, "a method"); } } fn check_ty_method(&mut self, cx: &Context, tm: &ast::TypeMethod) { - self.check_missing_docs_attrs(cx, Some(tm.id), tm.attrs[], + self.check_missing_docs_attrs(cx, Some(tm.id), tm.attrs.index(&FullRange), tm.span, "a type method"); } @@ -1555,14 +1555,14 @@ impl LintPass for MissingDoc { let cur_struct_def = *self.struct_def_stack.last() .expect("empty struct_def_stack"); self.check_missing_docs_attrs(cx, Some(cur_struct_def), - sf.node.attrs[], sf.span, + sf.node.attrs.index(&FullRange), sf.span, "a struct field") } } } fn check_variant(&mut self, cx: &Context, v: &ast::Variant, _: &ast::Generics) { - self.check_missing_docs_attrs(cx, Some(v.node.id), v.node.attrs[], + self.check_missing_docs_attrs(cx, Some(v.node.id), v.node.attrs.index(&FullRange), v.span, "a variant"); assert!(!self.in_variant); self.in_variant = true; @@ -1674,7 +1674,7 @@ impl Stability { _ => format!("use of {} item", label) }; - cx.span_lint(lint, span, msg[]); + cx.span_lint(lint, span, msg.index(&FullRange)); } fn is_internal(&self, cx: &Context, span: Span) -> bool { |
