diff options
| author | GuillaumeGomez <guillaume1.gomez@gmail.com> | 2015-02-04 21:48:12 +0100 |
|---|---|---|
| committer | GuillaumeGomez <guillaume1.gomez@gmail.com> | 2015-02-06 12:03:46 +0100 |
| commit | 7b973ba827076fcee194521b21a3b30caab41012 (patch) | |
| tree | 3533b7aba112b9c40f3b1c3ff768af6ba799f65a | |
| parent | 93fe5c82bfc58019cd799d9ceca8e22b380cfa60 (diff) | |
| download | rust-7b973ba827076fcee194521b21a3b30caab41012.tar.gz rust-7b973ba827076fcee194521b21a3b30caab41012.zip | |
Update to last version, remove "[]" as much as possible
36 files changed, 114 insertions, 115 deletions
diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 30863c81aa2..44e40ee297f 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -801,10 +801,10 @@ impl LintPass for UnusedResults { None => {} Some(s) => { msg.push_str(": "); - msg.push_str(&s[]); + msg.push_str(&s); } } - cx.span_lint(UNUSED_MUST_USE, sp, &msg[]); + cx.span_lint(UNUSED_MUST_USE, sp, &msg); return true; } } @@ -844,7 +844,7 @@ impl NonCamelCaseTypes { let s = token::get_ident(ident); if !is_camel_case(ident) { - let c = to_camel_case(&s[]); + let c = to_camel_case(&s); let m = if c.is_empty() { format!("{} `{}` should have a camel case name such as `CamelCase`", sort, s) } else { @@ -996,7 +996,7 @@ impl NonSnakeCase { let s = token::get_ident(ident); if !is_snake_case(ident) { - let sc = NonSnakeCase::to_snake_case(&s[]); + let sc = NonSnakeCase::to_snake_case(&s); if sc != &s[] { cx.span_lint(NON_SNAKE_CASE, span, &*format!("{} `{}` should have a snake case name such as `{}`", @@ -1078,7 +1078,7 @@ impl NonUpperCaseGlobals { let s = token::get_ident(ident); if s.chars().any(|c| c.is_lowercase()) { - let uc: String = NonSnakeCase::to_snake_case(&s[]).chars() + let uc: String = NonSnakeCase::to_snake_case(&s).chars() .map(|c| c.to_uppercase()).collect(); if uc != &s[] { cx.span_lint(NON_UPPER_CASE_GLOBALS, span, @@ -1241,7 +1241,7 @@ impl LintPass for UnusedImportBraces { match items[0].node { ast::PathListIdent {ref name, ..} => { let m = format!("braces around {} is unnecessary", - &token::get_ident(*name)[]); + &token::get_ident(*name)); cx.span_lint(UNUSED_IMPORT_BRACES, item.span, &m[]); }, diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 0db7c802abb..18628f6903f 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -341,7 +341,7 @@ pub fn gather_attrs(attrs: &[ast::Attribute]) -> Vec<Result<(InternedString, Level, Span), Span>> { let mut out = vec!(); for attr in attrs { - let level = match Level::from_str(&attr.name()[]) { + let level = match Level::from_str(&attr.name()) { None => continue, Some(lvl) => lvl, }; @@ -499,7 +499,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> { continue; } Ok((lint_name, level, span)) => { - match self.lints.find_lint(&lint_name[], &self.tcx.sess, Some(span)) { + match self.lints.find_lint(&lint_name, &self.tcx.sess, Some(span)) { Some(lint_id) => vec![(lint_id, level, span)], None => { match self.lints.lint_groups.get(&lint_name[]) { diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 304ff80845c..d15c902c7e1 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -170,7 +170,7 @@ impl<'a> CrateReader<'a> { fn process_crate(&self, c: &ast::Crate) { for a in c.attrs.iter().filter(|m| m.name() == "link_args") { match a.value_str() { - Some(ref linkarg) => self.sess.cstore.add_used_link_args(&linkarg[]), + Some(ref linkarg) => self.sess.cstore.add_used_link_args(&linkarg), None => { /* fallthrough */ } } } @@ -237,7 +237,7 @@ impl<'a> CrateReader<'a> { .collect::<Vec<&ast::Attribute>>(); for m in &link_args { match m.value_str() { - Some(linkarg) => self.sess.cstore.add_used_link_args(&linkarg[]), + Some(linkarg) => self.sess.cstore.add_used_link_args(&linkarg), None => { /* fallthrough */ } } } diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index e0ea1573681..37055f851b4 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -86,7 +86,7 @@ pub struct EncodeContext<'a, 'tcx: 'a> { } fn encode_name(rbml_w: &mut Encoder, name: ast::Name) { - rbml_w.wr_tagged_str(tag_paths_data_name, &token::get_name(name)[]); + rbml_w.wr_tagged_str(tag_paths_data_name, &token::get_name(name)); } fn encode_impl_type_basename(rbml_w: &mut Encoder, name: ast::Ident) { @@ -372,7 +372,7 @@ fn encode_path<PI: Iterator<Item=PathElem>>(rbml_w: &mut Encoder, path: PI) { ast_map::PathMod(_) => tag_path_elem_mod, ast_map::PathName(_) => tag_path_elem_name }; - rbml_w.wr_tagged_str(tag, &token::get_name(pe.name())[]); + rbml_w.wr_tagged_str(tag, &token::get_name(pe.name())); } rbml_w.end_tag(); } @@ -1695,7 +1695,7 @@ fn encode_paren_sugar(rbml_w: &mut Encoder, paren_sugar: bool) { fn encode_associated_type_names(rbml_w: &mut Encoder, names: &[ast::Name]) { rbml_w.start_tag(tag_associated_type_names); for &name in names { - rbml_w.wr_tagged_str(tag_associated_type_name, &token::get_name(name)[]); + rbml_w.wr_tagged_str(tag_associated_type_name, &token::get_name(name)); } rbml_w.end_tag(); } diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 12573bf0ffd..dda34426bfc 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -249,11 +249,11 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat) span_warn!(cx.tcx.sess, p.span, E0170, "pattern binding `{}` is named the same as one \ of the variants of the type `{}`", - &token::get_ident(ident.node)[], ty_to_string(cx.tcx, pat_ty)); + &token::get_ident(ident.node), ty_to_string(cx.tcx, pat_ty)); span_help!(cx.tcx.sess, p.span, "if you meant to match on a variant, \ consider making the path in the pattern qualified: `{}::{}`", - ty_to_string(cx.tcx, pat_ty), &token::get_ident(ident.node)[]); + ty_to_string(cx.tcx, pat_ty), &token::get_ident(ident.node)); } } } diff --git a/src/librustc/middle/infer/error_reporting.rs b/src/librustc/middle/infer/error_reporting.rs index 90b43dd7f7d..1b513a13588 100644 --- a/src/librustc/middle/infer/error_reporting.rs +++ b/src/librustc/middle/infer/error_reporting.rs @@ -1439,7 +1439,7 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> { } infer::BoundRegionInCoherence(name) => { format!(" for lifetime parameter `{}` in coherence check", - &token::get_name(name)[]) + &token::get_name(name)) } infer::UpvarRegion(ref upvar_id, _) => { format!(" for capture of `{}` by closure", diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 9b9e3ec9474..e817573b89c 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -239,12 +239,12 @@ impl<'a, 'tcx> Checker<'a, 'tcx> { if !self.active_features.contains(feature) { let msg = match *reason { Some(ref r) => format!("use of unstable library feature '{}': {}", - &feature[], &r[]), - None => format!("use of unstable library feature '{}'", &feature[]) + &feature, &r), + None => format!("use of unstable library feature '{}'", &feature) }; emit_feature_warn(&self.tcx.sess.parse_sess.span_diagnostic, - &feature[], span, &msg[]); + &feature, span, &msg); } } Some(..) => { diff --git a/src/librustc/middle/traits/error_reporting.rs b/src/librustc/middle/traits/error_reporting.rs index 0343d9af28d..2197cbeb85d 100644 --- a/src/librustc/middle/traits/error_reporting.rs +++ b/src/librustc/middle/traits/error_reporting.rs @@ -86,7 +86,7 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, }).collect::<HashMap<String, String>>(); generic_map.insert("Self".to_string(), trait_ref.self_ty().user_string(infcx.tcx)); - let parser = Parser::new(&istring[]); + let parser = Parser::new(&istring); let mut errored = false; let err: String = parser.filter_map(|p| { match p { diff --git a/src/librustc/middle/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs index 7456cc8cb0f..ee3fd681a00 100644 --- a/src/librustc/middle/weak_lang_items.rs +++ b/src/librustc/middle/weak_lang_items.rs @@ -110,7 +110,7 @@ impl<'a, 'v> Visitor<'v> for Context<'a> { fn visit_foreign_item(&mut self, i: &ast::ForeignItem) { match lang_items::extract(&i.attrs) { None => {} - Some(lang_item) => self.register(&lang_item[], i.span), + Some(lang_item) => self.register(&lang_item, i.span), } visit::walk_foreign_item(self, i) } diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index a7a5ea4c7b4..c72b7fdf7ad 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -277,7 +277,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String { match ident { Some(i) => { s.push(' '); - s.push_str(&token::get_ident(i)[]); + s.push_str(&token::get_ident(i)); } _ => { } } diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 03f004ccb67..3abb1b694e6 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -907,7 +907,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { match loan_path.kind { LpUpvar(ty::UpvarId{ var_id: id, closure_expr_id: _ }) | LpVar(id) => { - out.push_str(&ty::local_var_name_str(self.tcx, id)[]); + out.push_str(&ty::local_var_name_str(self.tcx, id)); } LpDowncast(ref lp_base, variant_def_id) => { @@ -924,7 +924,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { match fname { mc::NamedField(fname) => { out.push('.'); - out.push_str(&token::get_name(fname)[]); + out.push_str(&token::get_name(fname)); } mc::PositionalField(idx) => { out.push('.'); diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index fe42817a9c4..2f25f34a92a 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -1020,7 +1020,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> { self.handle_external_def(def, def_visibility, &*child_name_bindings, - &token::get_name(name)[], + &token::get_name(name), name, root); } diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 0d87f2a17df..a261599a706 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1093,7 +1093,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } else { result.push_str("::") } - result.push_str(&token::get_name(*name)[]); + result.push_str(&token::get_name(*name)); }; result } @@ -1708,7 +1708,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { debug!("(resolving glob import) writing resolution `{}` in `{}` \ to `{}`", - &token::get_name(name)[], + &token::get_name(name), self.module_to_string(&*containing_module), self.module_to_string(module_)); @@ -1725,7 +1725,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let msg = format!("a {} named `{}` has already been imported \ in this module", namespace_name, - &token::get_name(name)[]); + &token::get_name(name)); span_err!(self.session, import_directive.span, E0251, "{}", msg); } else { let target = Target::new(containing_module.clone(), @@ -1757,7 +1757,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { name: Name, namespace: Namespace) { debug!("check_for_conflicting_import: {}; target exists: {}", - &token::get_name(name)[], + &token::get_name(name), target.is_some()); match *target { @@ -1768,7 +1768,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { TypeNS => "type", ValueNS => "value", }, - &token::get_name(name)[]); + &token::get_name(name)); span_err!(self.session, import_span, E0252, "{}", &msg[]); } Some(_) | None => {} @@ -1804,7 +1804,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let msg = format!("import `{0}` conflicts with imported \ crate in this module \ (maybe you meant `use {0}::*`?)", - &token::get_name(name)[]); + &token::get_name(name)); span_err!(self.session, import_span, E0254, "{}", &msg[]); } Some(_) | None => {} @@ -1826,7 +1826,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { if let Some(ref value) = *name_bindings.value_def.borrow() { let msg = format!("import `{}` conflicts with value \ in this module", - &token::get_name(name)[]); + &token::get_name(name)); span_err!(self.session, import_span, E0255, "{}", &msg[]); if let Some(span) = value.value_span { self.session.span_note(span, @@ -1844,7 +1844,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { None => { let msg = format!("import `{}` conflicts with type in \ this module", - &token::get_name(name)[]); + &token::get_name(name)); span_err!(self.session, import_span, E0256, "{}", &msg[]); if let Some(span) = ty.type_span { self.session.span_note(span, @@ -1866,7 +1866,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { _ => { let msg = format!("import `{}` conflicts with existing \ submodule", - &token::get_name(name)[]); + &token::get_name(name)); span_err!(self.session, import_span, E0258, "{}", &msg[]); if let Some(span) = ty.type_span { self.session.span_note(span, @@ -1892,7 +1892,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { span_err!(self.session, span, E0259, "an external crate named `{}` has already \ been imported into this module", - &token::get_name(name)[]); + &token::get_name(name)); } } @@ -1906,7 +1906,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { "the name `{}` conflicts with an external \ crate that has been imported into this \ module", - &token::get_name(name)[]); + &token::get_name(name)); } } @@ -2417,7 +2417,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { allow_private_imports: bool) -> ResolveResult<(Target, bool)> { debug!("(resolving name in module) resolving `{}` in `{}`", - &token::get_name(name)[], + &token::get_name(name), self.module_to_string(&*module_)); // First, check the direct children of the module. @@ -2493,7 +2493,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { // We're out of luck. debug!("(resolving name in module) failed to resolve `{}`", - &token::get_name(name)[]); + &token::get_name(name)); return Failed(None); } @@ -4372,7 +4372,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let mut smallest = 0; for (i, other) in maybes.iter().enumerate() { - values[i] = lev_distance(name, &other[]); + values[i] = lev_distance(name, &other); if values[i] <= values[smallest] { smallest = i; diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index bfeb73bb546..9f26e9182ab 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -293,7 +293,7 @@ pub fn mangle<PI: Iterator<Item=PathElem>>(path: PI, // First, connect each component with <len, name> pairs. for e in path { - push(&mut n, &token::get_name(e.name())[]) + push(&mut n, &token::get_name(e.name())) } match hash { diff --git a/src/librustc_trans/save/mod.rs b/src/librustc_trans/save/mod.rs index 49fd040b25a..e80564097df 100644 --- a/src/librustc_trans/save/mod.rs +++ b/src/librustc_trans/save/mod.rs @@ -355,7 +355,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> { }, }; - let qualname = format!("{}::{}", qualname, &get_ident(method.pe_ident())[]); + let qualname = format!("{}::{}", qualname, &get_ident(method.pe_ident())); let qualname = &qualname[]; // record the decl for this def (if it has one) @@ -525,7 +525,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> { self.fmt.static_str(item.span, sub_span, item.id, - &get_ident(item.ident)[], + &get_ident(item.ident), &qualname[], &value[], &ty_to_string(&*typ)[], @@ -548,7 +548,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> { self.fmt.static_str(item.span, sub_span, item.id, - &get_ident(item.ident)[], + &get_ident(item.ident), &qualname[], "", &ty_to_string(&*typ)[], @@ -607,7 +607,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> { } for variant in &enum_definition.variants { let name = get_ident(variant.node.name); - let name = &name[]; + let name = &name; let mut qualname = enum_name.clone(); qualname.push_str("::"); qualname.push_str(name); @@ -1094,7 +1094,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> { sub_span, item.id, mod_id, - &get_ident(ident)[], + &get_ident(ident), self.cur_scope); self.write_sub_paths_truncated(path, true); } @@ -1149,7 +1149,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> { } ast::ItemExternCrate(ref s) => { let name = get_ident(item.ident); - let name = &name[]; + let name = &name; let location = match *s { Some((ref s, _)) => s.to_string(), None => name.to_string(), @@ -1259,7 +1259,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> { }, }; - qualname.push_str(&get_ident(method_type.ident)[]); + qualname.push_str(&get_ident(method_type.ident)); let qualname = &qualname[]; let sub_span = self.span.sub_span_after_keyword(method_type.span, keywords::Fn); diff --git a/src/librustc_trans/trans/asm.rs b/src/librustc_trans/trans/asm.rs index 7ec371cec25..e419be65fc4 100644 --- a/src/librustc_trans/trans/asm.rs +++ b/src/librustc_trans/trans/asm.rs @@ -83,7 +83,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm) .connect(","); let mut clobbers = ia.clobbers.iter() - .map(|s| format!("~{{{}}}", &s[])) + .map(|s| format!("~{{{}}}", &s)) .collect::<Vec<String>>() .connect(","); let more_clobbers = get_clobbers(); diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index 089292fa64e..6a97d393ba8 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -2248,7 +2248,7 @@ pub fn update_linkage(ccx: &CrateContext, let item = ccx.tcx().map.get(id); if let ast_map::NodeItem(i) = item { if let Some(name) = attr::first_attr_value_str_by_name(&i.attrs, "linkage") { - if let Some(linkage) = llvm_linkage_by_name(&name[]) { + if let Some(linkage) = llvm_linkage_by_name(&name) { llvm::SetLinkage(llval, linkage); } else { ccx.sess().span_fatal(i.span, "invalid linkage specified"); @@ -2824,9 +2824,9 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef { match attr::first_attr_value_str_by_name(&i.attrs[], "link_section") { Some(sect) => { - if contains_null(§[]) { + if contains_null(§) { ccx.sess().fatal(&format!("Illegal null byte in link_section value: `{}`", - §[])[]); + §)[]); } unsafe { let buf = CString::from_slice(sect.as_bytes()); @@ -2869,7 +2869,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef { let abi = ccx.tcx().map.get_foreign_abi(id); let ty = ty::node_id_to_type(ccx.tcx(), ni.id); let name = foreign::link_name(&*ni); - foreign::register_foreign_item_fn(ccx, abi, ty, &name[]) + foreign::register_foreign_item_fn(ccx, abi, ty, &name) } ast::ForeignItemStatic(..) => { foreign::register_static(ccx, &*ni) diff --git a/src/librustc_trans/trans/consts.rs b/src/librustc_trans/trans/consts.rs index 18968e6f885..15fa566d548 100644 --- a/src/librustc_trans/trans/consts.rs +++ b/src/librustc_trans/trans/consts.rs @@ -58,13 +58,13 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: &ast::Lit) } } ast::LitFloat(ref fs, t) => { - C_floating(&fs[], Type::float_from_ty(cx, t)) + C_floating(&fs, Type::float_from_ty(cx, t)) } ast::LitFloatUnsuffixed(ref fs) => { let lit_float_ty = ty::node_id_to_type(cx.tcx(), e.id); match lit_float_ty.sty { ty::ty_float(t) => { - C_floating(&fs[], Type::float_from_ty(cx, t)) + C_floating(&fs, Type::float_from_ty(cx, t)) } _ => { cx.sess().span_bug(lit.span, diff --git a/src/librustc_trans/trans/debuginfo.rs b/src/librustc_trans/trans/debuginfo.rs index 400f03dbb51..c57afcf2ada 100644 --- a/src/librustc_trans/trans/debuginfo.rs +++ b/src/librustc_trans/trans/debuginfo.rs @@ -1350,7 +1350,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, // Get_template_parameters() will append a `<...>` clause to the function // name if necessary. - let mut function_name = String::from_str(&token::get_ident(ident)[]); + let mut function_name = String::from_str(&token::get_ident(ident)); let template_parameters = get_template_parameters(cx, generics, param_substs, @@ -2237,13 +2237,13 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> { .get_unique_type_id_of_enum_variant( cx, self.enum_type, - &non_null_variant_name[]); + &non_null_variant_name); // Now we can create the metadata of the artificial struct let artificial_struct_metadata = composite_type_metadata(cx, artificial_struct_llvm_type, - &non_null_variant_name[], + &non_null_variant_name, unique_type_id, &[sole_struct_member_description], self.containing_scope, @@ -2373,7 +2373,7 @@ fn describe_enum_variant<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, // Could do some consistency checks here: size, align, field count, discr type let variant_name = token::get_name(variant_info.name); - let variant_name = &variant_name[]; + let variant_name = &variant_name; let unique_type_id = debug_context(cx).type_map .borrow_mut() .get_unique_type_id_of_enum_variant( @@ -3847,7 +3847,7 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let mut path_element_count = 0; for path_element in path { let name = token::get_name(path_element.name()); - output.push_str(&name[]); + output.push_str(&name); output.push_str("::"); path_element_count += 1; } @@ -3862,7 +3862,7 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let name = token::get_name(path.last() .expect("debuginfo: Empty item path?") .name()); - output.push_str(&name[]); + output.push_str(&name); } }); } @@ -3913,7 +3913,7 @@ impl NamespaceTreeNode { } let string = token::get_name(node.name); output.push_str(&format!("{}", string.len())[]); - output.push_str(&string[]); + output.push_str(&string); } let mut name = String::from_str("_ZN"); diff --git a/src/librustc_trans/trans/foreign.rs b/src/librustc_trans/trans/foreign.rs index a2fe5fa3f17..80b27a8b985 100644 --- a/src/librustc_trans/trans/foreign.rs +++ b/src/librustc_trans/trans/foreign.rs @@ -118,7 +118,7 @@ pub fn register_static(ccx: &CrateContext, // static and call it a day. Some linkages (like weak) will make it such // that the static actually has a null value. Some(name) => { - let linkage = match llvm_linkage_by_name(&name[]) { + let linkage = match llvm_linkage_by_name(&name) { Some(linkage) => linkage, None => { ccx.sess().span_fatal(foreign_item.span, @@ -146,7 +146,7 @@ pub fn register_static(ccx: &CrateContext, // `extern_with_linkage_foo` will instead be initialized to // zero. let mut real_name = "_rust_extern_with_linkage_".to_string(); - real_name.push_str(&ident[]); + real_name.push_str(&ident); let real_name = CString::from_vec(real_name.into_bytes()); let g2 = llvm::LLVMAddGlobal(ccx.llmod(), llty.to_ref(), real_name.as_ptr()); @@ -468,7 +468,7 @@ pub fn trans_foreign_mod(ccx: &CrateContext, foreign_mod: &ast::ForeignMod) { } register_foreign_item_fn(ccx, abi, ty, - &lname[]); + &lname); // Unlike for other items, we shouldn't call // `base::update_linkage` here. Foreign items have // special linkage requirements, which are handled diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 22393a7a291..60771d126b5 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1164,8 +1164,7 @@ pub fn ast_ty_to_ty<'tcx>( path.segments .last() .unwrap() - .identifier) - []); + .identifier)); this.tcx().types.err } def::DefAssociatedPath(provenance, assoc_ident) => { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 5b89954c586..9c0d6f7dae3 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -805,7 +805,7 @@ fn check_trait_on_unimplemented<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, a.check_name("rustc_on_unimplemented") }) { if let Some(ref istring) = attr.value_str() { - let parser = Parser::new(&istring[]); + let parser = Parser::new(&istring); let types = &*generics.ty_params; for token in parser { match token { @@ -3104,7 +3104,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, tcx : &ty::ctxt<'tcx>, skip : Vec<&str>) { let ident = token::get_ident(field.node); - let name = &ident[]; + let name = &ident; // only find fits with at least one matching letter let mut best_dist = name.len(); let fields = ty::lookup_struct_fields(tcx, id); @@ -3286,7 +3286,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, let (_, seen) = class_field_map[name]; if !seen { missing_fields.push( - format!("`{}`", &token::get_name(name)[])) + format!("`{}`", &token::get_name(name))) } } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 7849b7548c4..7e1bf7a2230 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -118,7 +118,7 @@ impl fmt::Debug for Name { impl fmt::Display for Name { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Display::fmt(&token::get_name(*self)[], f) + fmt::Display::fmt(&token::get_name(*self), f) } } @@ -174,7 +174,7 @@ impl Name { pub fn as_str<'a>(&'a self) -> &'a str { unsafe { // FIXME #12938: can't use copy_lifetime since &str isn't a &T - ::std::mem::transmute::<&str,&str>(&token::get_name(*self)[]) + ::std::mem::transmute::<&str,&str>(&token::get_name(*self)) } } @@ -193,7 +193,7 @@ pub type Mrk = u32; impl Encodable for Ident { fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_str(&token::get_ident(*self)[]) + s.emit_str(&token::get_ident(*self)) } } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index cd82d7c9b14..a3afe5780d0 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -142,7 +142,7 @@ impl AttributeMethods for Attribute { let meta = mk_name_value_item_str( InternedString::new("doc"), token::intern_and_get_ident(&strip_doc_comment_decoration( - &comment[])[])); + &comment)[])); if self.node.style == ast::AttrOuter { f(&mk_attr_outer(self.node.id, meta)) } else { @@ -209,7 +209,7 @@ pub fn mk_attr_outer(id: AttrId, item: P<MetaItem>) -> Attribute { pub fn mk_sugared_doc_attr(id: AttrId, text: InternedString, lo: BytePos, hi: BytePos) -> Attribute { - let style = doc_comment_style(&text[]); + let style = doc_comment_style(&text); let lit = spanned(lo, hi, ast::LitStr(text, ast::CookedStr)); let attr = Attribute_ { id: id, @@ -525,7 +525,7 @@ pub fn find_repr_attrs(diagnostic: &SpanHandler, attr: &Attribute) -> Vec<ReprAt // Can't use "extern" because it's not a lexical identifier. "C" => Some(ReprExtern), "packed" => Some(ReprPacked), - _ => match int_type_of_word(&word[]) { + _ => match int_type_of_word(&word) { Some(ity) => Some(ReprInt(item.span, ity)), None => { // Not a word we recognize diff --git a/src/libsyntax/diagnostics/plugin.rs b/src/libsyntax/diagnostics/plugin.rs index 4a3c1f48252..833a6d52acb 100644 --- a/src/libsyntax/diagnostics/plugin.rs +++ b/src/libsyntax/diagnostics/plugin.rs @@ -58,7 +58,7 @@ pub fn expand_diagnostic_used<'cx>(ecx: &'cx mut ExtCtxt, match diagnostics.insert(code.name, span) { Some(previous_span) => { ecx.span_warn(span, &format!( - "diagnostic code {} already used", &token::get_ident(code)[] + "diagnostic code {} already used", &token::get_ident(code) )[]); ecx.span_note(previous_span, "previous invocation"); }, @@ -69,7 +69,7 @@ pub fn expand_diagnostic_used<'cx>(ecx: &'cx mut ExtCtxt, with_registered_diagnostics(|diagnostics| { if !diagnostics.contains_key(&code.name) { ecx.span_err(span, &format!( - "used diagnostic code {} not registered", &token::get_ident(code)[] + "used diagnostic code {} not registered", &token::get_ident(code) )[]); } }); @@ -94,12 +94,12 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt, with_registered_diagnostics(|diagnostics| { if diagnostics.insert(code.name, description).is_some() { ecx.span_err(span, &format!( - "diagnostic code {} already registered", &token::get_ident(*code)[] + "diagnostic code {} already registered", &token::get_ident(*code) )[]); } }); let sym = Ident::new(token::gensym(&( - "__register_diagnostic_".to_string() + &token::get_ident(*code)[] + "__register_diagnostic_".to_string() + &token::get_ident(*code) )[])); MacItems::new(vec![quote_item!(ecx, mod $sym {}).unwrap()].into_iter()) } diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index 8c710545cb0..1ceda2e08dd 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -213,7 +213,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) MacExpr::new(P(ast::Expr { id: ast::DUMMY_NODE_ID, node: ast::ExprInlineAsm(ast::InlineAsm { - asm: token::intern_and_get_ident(&asm[]), + asm: token::intern_and_get_ident(&asm), asm_str_style: asm_str_style.unwrap(), outputs: outputs, inputs: inputs, diff --git a/src/libsyntax/ext/concat.rs b/src/libsyntax/ext/concat.rs index 849d8bff365..80d128959ea 100644 --- a/src/libsyntax/ext/concat.rs +++ b/src/libsyntax/ext/concat.rs @@ -32,7 +32,7 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt, ast::LitStr(ref s, _) | ast::LitFloat(ref s, _) | ast::LitFloatUnsuffixed(ref s) => { - accumulator.push_str(&s[]); + accumulator.push_str(&s); } ast::LitChar(c) => { accumulator.push(c); diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs index 14de5803604..364cacd735c 100644 --- a/src/libsyntax/ext/concat_idents.rs +++ b/src/libsyntax/ext/concat_idents.rs @@ -31,7 +31,7 @@ pub fn expand_syntax_ext<'cx>(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree] } else { match *e { ast::TtToken(_, token::Ident(ident, _)) => { - res_str.push_str(&token::get_ident(ident)[]) + res_str.push_str(&token::get_ident(ident)) }, _ => { cx.span_err(sp, "concat_idents! requires ident args."); diff --git a/src/libsyntax/ext/deriving/show.rs b/src/libsyntax/ext/deriving/show.rs index 49f766eb957..821fdeaa86a 100644 --- a/src/libsyntax/ext/deriving/show.rs +++ b/src/libsyntax/ext/deriving/show.rs @@ -72,7 +72,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span, } }; - let mut format_string = String::from_str(&token::get_ident(name)[]); + let mut format_string = String::from_str(&token::get_ident(name)); // the internal fields we're actually formatting let mut exprs = Vec::new(); @@ -107,7 +107,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span, let name = token::get_ident(field.name.unwrap()); format_string.push_str(" "); - format_string.push_str(&name[]); + format_string.push_str(&name); format_string.push_str(": {:?}"); exprs.push(field.self_.clone()); diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index 2298686e8c1..8f3c9177b9c 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -102,12 +102,12 @@ pub fn expand_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) } } - let e = match os::getenv(&var[]) { + let e = match os::getenv(&var) { None => { - cx.span_err(sp, &msg[]); + cx.span_err(sp, &msg); cx.expr_usize(sp, 0) } - Some(s) => cx.expr_str(sp, token::intern_and_get_ident(&s[])) + Some(s) => cx.expr_str(sp, token::intern_and_get_ident(&s)) }; MacExpr::new(e) } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index e43ca9db8b1..61aae4e98b4 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -375,7 +375,7 @@ fn expand_mac_invoc<T, F, G>(mac: ast::Mac, span: codemap::Span, fld.cx.span_err( pth.span, &format!("macro undefined: '{}!'", - &extnamestr[])[]); + &extnamestr)[]); // let compilation continue None @@ -422,7 +422,7 @@ fn expand_mac_invoc<T, F, G>(mac: ast::Mac, span: codemap::Span, fld.cx.span_err( pth.span, &format!("'{}' is not a tt-style macro", - &extnamestr[])[]); + &extnamestr)[]); None } } @@ -506,7 +506,7 @@ fn expand_item_modifiers(mut it: P<ast::Item>, fld: &mut MacroExpander) for attr in &modifiers { let mname = attr.name(); - match fld.cx.syntax_env.find(&intern(&mname[])) { + match fld.cx.syntax_env.find(&intern(&mname)) { Some(rc) => match *rc { Modifier(ref mac) => { attr::mark_used(attr); @@ -626,7 +626,7 @@ pub fn expand_item_mac(it: P<ast::Item>, if it.ident.name == parse::token::special_idents::invalid.name { fld.cx.span_err(path_span, &format!("macro {}! expects an ident argument", - &extnamestr[])[]); + &extnamestr)[]); return SmallVector::zero(); } fld.cx.bt_push(ExpnInfo { @@ -677,7 +677,7 @@ pub fn expand_item_mac(it: P<ast::Item>, _ => { fld.cx.span_err(it.span, &format!("{}! is not legal in item position", - &extnamestr[])[]); + &extnamestr)[]); return SmallVector::zero(); } } @@ -696,7 +696,7 @@ pub fn expand_item_mac(it: P<ast::Item>, None => { fld.cx.span_err(path_span, &format!("non-item macro in item position: {}", - &extnamestr[])[]); + &extnamestr)[]); return SmallVector::zero(); } }; @@ -968,7 +968,7 @@ fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> { pth.span, &format!( "non-pattern macro in pattern position: {}", - &extnamestr[] + &extnamestr )[] ); return DummyResult::raw_pat(span); @@ -981,7 +981,7 @@ fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> { _ => { fld.cx.span_err(span, &format!("{}! is not legal in pattern position", - &extnamestr[])[]); + &extnamestr)[]); return DummyResult::raw_pat(span); } } @@ -1065,7 +1065,7 @@ fn expand_annotatable(a: Annotatable, for attr in a.attrs() { let mname = attr.name(); - match fld.cx.syntax_env.find(&intern(&mname[])) { + match fld.cx.syntax_env.find(&intern(&mname)) { Some(rc) => match *rc { Decorator(ref dec) => { let it = match a { @@ -1180,7 +1180,7 @@ fn modifiers(attrs: &Vec<ast::Attribute>, fld: &MacroExpander) -> (Vec<ast::Attribute>, Vec<ast::Attribute>) { attrs.iter().cloned().partition(|attr| { - match fld.cx.syntax_env.find(&intern(&attr.name()[])) { + match fld.cx.syntax_env.find(&intern(&attr.name())) { Some(rc) => match *rc { Modifier(_) => true, _ => false @@ -1195,7 +1195,7 @@ fn multi_modifiers(attrs: &[ast::Attribute], fld: &MacroExpander) -> (Vec<ast::Attribute>, Vec<ast::Attribute>) { attrs.iter().cloned().partition(|attr| { - match fld.cx.syntax_env.find(&intern(&attr.name()[])) { + match fld.cx.syntax_env.find(&intern(&attr.name())) { Some(rc) => match *rc { MultiModifier(_) => true, _ => false @@ -1220,7 +1220,7 @@ fn expand_item_multi_modifier(mut it: Annotatable, for attr in &modifiers { let mname = attr.name(); - match fld.cx.syntax_env.find(&intern(&mname[])) { + match fld.cx.syntax_env.find(&intern(&mname)) { Some(rc) => match *rc { MultiModifier(ref mac) => { attr::mark_used(attr); diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index af357e45a7c..96055e3635a 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -673,7 +673,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, sp: Span, None => return DummyResult::raw_expr(sp) }; - let mut parser = parse::Parser::new(&fmt[]); + let mut parser = parse::Parser::new(&fmt); loop { match parser.next() { diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 21c65d7fbf6..d752e34c112 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -229,7 +229,7 @@ pub fn nameize(p_s: &ParseSess, ms: &[TokenTree], res: &[Rc<NamedMatch>]) p_s.span_diagnostic .span_fatal(sp, &format!("duplicated bind name: {}", - &string[])[]) + &string)[]) } } } @@ -487,7 +487,7 @@ pub fn parse(sess: &ParseSess, let name_string = token::get_ident(name); let match_cur = ei.match_cur; (&mut ei.matches[match_cur]).push(Rc::new(MatchedNonterminal( - parse_nt(&mut rust_parser, span, &name_string[])))); + parse_nt(&mut rust_parser, span, &name_string)))); ei.idx += 1us; ei.match_cur += 1; } diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 45f4f044ea4..39bc7f6f5af 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -639,7 +639,7 @@ impl BytesContainer for InternedString { // of `BytesContainer`, which is itself a workaround for the lack of // DST. unsafe { - let this = &self[]; + let this = &self; mem::transmute::<&[u8],&[u8]>(this.container_as_bytes()) } } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index a244c9de62b..c177cd1fafa 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1313,7 +1313,7 @@ impl<'a> State<'a> { try!(self.hardbreak_if_not_bol()); try!(self.maybe_print_comment(attr.span.lo)); if attr.node.is_sugared_doc { - word(&mut self.s, &attr.value_str().unwrap()[]) + word(&mut self.s, &attr.value_str().unwrap()) } else { match attr.node.style { ast::AttrInner => try!(word(&mut self.s, "#![")), @@ -1847,7 +1847,7 @@ impl<'a> State<'a> { ast::ExprInlineAsm(ref a) => { try!(word(&mut self.s, "asm!")); try!(self.popen()); - try!(self.print_string(&a.asm[], a.asm_str_style)); + try!(self.print_string(&a.asm, a.asm_str_style)); try!(self.word_space(":")); try!(self.commasep(Inconsistent, &a.outputs[], @@ -1857,7 +1857,7 @@ impl<'a> State<'a> { try!(s.print_string(&format!("+{}", operand)[], ast::CookedStr)) } - _ => try!(s.print_string(&co[], ast::CookedStr)) + _ => try!(s.print_string(&co, ast::CookedStr)) } try!(s.popen()); try!(s.print_expr(&**o)); @@ -1869,7 +1869,7 @@ impl<'a> State<'a> { try!(self.commasep(Inconsistent, &a.inputs[], |s, &(ref co, ref o)| { - try!(s.print_string(&co[], ast::CookedStr)); + try!(s.print_string(&co, ast::CookedStr)); try!(s.popen()); try!(s.print_expr(&**o)); try!(s.pclose()); @@ -1880,7 +1880,7 @@ impl<'a> State<'a> { try!(self.commasep(Inconsistent, &a.clobbers[], |s, co| { - try!(s.print_string(&co[], ast::CookedStr)); + try!(s.print_string(&co, ast::CookedStr)); Ok(()) })); @@ -1954,7 +1954,7 @@ impl<'a> State<'a> { let encoded = ident.encode_with_hygiene(); try!(word(&mut self.s, &encoded[])) } else { - try!(word(&mut self.s, &token::get_ident(ident)[])) + try!(word(&mut self.s, &token::get_ident(ident))) } self.ann.post(self, NodeIdent(&ident)) } @@ -1964,7 +1964,7 @@ impl<'a> State<'a> { } pub fn print_name(&mut self, name: ast::Name) -> IoResult<()> { - try!(word(&mut self.s, &token::get_name(name)[])); + try!(word(&mut self.s, &token::get_name(name))); self.ann.post(self, NodeName(&name)) } @@ -2532,7 +2532,7 @@ impl<'a> State<'a> { try!(self.ibox(indent_unit)); match item.node { ast::MetaWord(ref name) => { - try!(word(&mut self.s, &name[])); + try!(word(&mut self.s, &name)); } ast::MetaNameValue(ref name, ref value) => { try!(self.word_space(&name[])); @@ -2540,7 +2540,7 @@ impl<'a> State<'a> { try!(self.print_literal(value)); } ast::MetaList(ref name, ref items) => { - try!(word(&mut self.s, &name[])); + try!(word(&mut self.s, &name)); try!(self.popen()); try!(self.commasep(Consistent, &items[], @@ -2731,7 +2731,7 @@ impl<'a> State<'a> { _ => () } match lit.node { - ast::LitStr(ref st, style) => self.print_string(&st[], style), + ast::LitStr(ref st, style) => self.print_string(&st, style), ast::LitByte(byte) => { let mut res = String::from_str("b'"); ascii::escape_default(byte, |c| res.push(c as char)); @@ -2772,7 +2772,7 @@ impl<'a> State<'a> { word(&mut self.s, &format!( "{}{}", - &f[], + &f, &ast_util::float_ty_to_string(t)[])[]) } ast::LitFloatUnsuffixed(ref f) => word(&mut self.s, &f[]), diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index ddebf07ece5..1a8cb2b376a 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -512,7 +512,7 @@ fn mk_test_module(cx: &mut TestCtxt) -> (P<ast::Item>, Option<P<ast::Item>>) { }); let reexport = cx.reexport_test_harness_main.as_ref().map(|s| { // building `use <ident> = __test::main` - let reexport_ident = token::str_to_ident(&s[]); + let reexport_ident = token::str_to_ident(&s); let use_path = nospan(ast::ViewPathSimple(reexport_ident, |
