diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2015-02-01 21:53:25 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2015-02-05 13:45:01 -0500 |
| commit | 17bc7d8d5be3be9674d702ccad2fa88c487d23b0 (patch) | |
| tree | 325defba0f55b48273cd3f0814fe6c083dee5d41 /src/librustc | |
| parent | 2c05354211b04a52cc66a0b8ad8b2225eaf9e972 (diff) | |
| download | rust-17bc7d8d5be3be9674d702ccad2fa88c487d23b0.tar.gz rust-17bc7d8d5be3be9674d702ccad2fa88c487d23b0.zip | |
cleanup: replace `as[_mut]_slice()` calls with deref coercions
Diffstat (limited to 'src/librustc')
36 files changed, 128 insertions, 133 deletions
diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index c2de380d094..34565383c5a 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -1082,12 +1082,12 @@ impl NonUpperCaseGlobals { .map(|c| c.to_uppercase()).collect(); if uc != s.get() { cx.span_lint(NON_UPPER_CASE_GLOBALS, span, - format!("{} `{}` should have an upper case name such as `{}`", - sort, s, uc).as_slice()); + &format!("{} `{}` should have an upper case name such as `{}`", + sort, s, uc)); } else { cx.span_lint(NON_UPPER_CASE_GLOBALS, span, - format!("{} `{}` should have an upper case name", - sort, s).as_slice()); + &format!("{} `{}` should have an upper case name", + sort, s)); } } } @@ -2084,11 +2084,11 @@ impl LintPass for PrivateNoMangleFns { fn check_item(&mut self, cx: &Context, it: &ast::Item) { match it.node { ast::ItemFn(..) => { - if attr::contains_name(it.attrs.as_slice(), "no_mangle") && + if attr::contains_name(&it.attrs, "no_mangle") && !cx.exported_items.contains(&it.id) { let msg = format!("function {} is marked #[no_mangle], but not exported", it.ident); - cx.span_lint(PRIVATE_NO_MANGLE_FNS, it.span, msg.as_slice()); + cx.span_lint(PRIVATE_NO_MANGLE_FNS, it.span, &msg); } }, _ => {}, diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 91dba90b0d2..844ad2be264 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -509,8 +509,8 @@ impl<'a, 'tcx> Context<'a, 'tcx> { .collect(), None => { self.span_lint(builtin::UNKNOWN_LINTS, span, - format!("unknown `{}` attribute: `{}`", - level.as_str(), lint_name).as_slice()); + &format!("unknown `{}` attribute: `{}`", + level.as_str(), lint_name)); continue; } } @@ -797,8 +797,8 @@ pub fn check_crate(tcx: &ty::ctxt, for (id, v) in &*tcx.sess.lints.borrow() { for &(lint, span, ref msg) in v { tcx.sess.span_bug(span, - format!("unprocessed lint {} at {}: {}", - lint.as_str(), tcx.map.node_to_string(*id), *msg).as_slice()) + &format!("unprocessed lint {} at {}: {}", + lint.as_str(), tcx.map.node_to_string(*id), *msg)) } } diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index 9eab0af5583..070ab248f24 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -93,7 +93,7 @@ pub fn get_item_path(tcx: &ty::ctxt, def: ast::DefId) -> Vec<ast_map::PathElem> // FIXME #1920: This path is not always correct if the crate is not linked // into the root namespace. let mut r = vec![ast_map::PathMod(token::intern(&cdata.name[]))]; - r.push_all(path.as_slice()); + r.push_all(&path); r } diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index df5732e2f65..5fb047ea93b 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -1044,7 +1044,7 @@ fn encode_info_for_item(ecx: &EncodeContext, encode_bounds_and_type(rbml_w, ecx, &lookup_item_type(tcx, def_id)); encode_name(rbml_w, item.ident.name); encode_path(rbml_w, path); - encode_attributes(rbml_w, item.attrs.as_slice()); + encode_attributes(rbml_w, &item.attrs); encode_inlined_item(ecx, rbml_w, IIItemRef(item)); encode_visibility(rbml_w, vis); encode_stability(rbml_w, stab); @@ -1307,7 +1307,7 @@ fn encode_info_for_item(ecx: &EncodeContext, let trait_def = ty::lookup_trait_def(tcx, def_id); encode_unsafety(rbml_w, trait_def.unsafety); encode_paren_sugar(rbml_w, trait_def.paren_sugar); - encode_associated_type_names(rbml_w, trait_def.associated_type_names.as_slice()); + encode_associated_type_names(rbml_w, &trait_def.associated_type_names); encode_generics(rbml_w, ecx, &trait_def.generics, tag_item_generics); encode_trait_ref(rbml_w, ecx, &*trait_def.trait_ref, tag_item_trait_ref); encode_name(rbml_w, item.ident.name); diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs index 2fb5a6b64a6..d30df131d4d 100644 --- a/src/librustc/metadata/loader.rs +++ b/src/librustc/metadata/loader.rs @@ -394,8 +394,8 @@ impl<'a> Context<'a> { file.ends_with(".rlib") { (&file[(rlib_prefix.len()) .. (file.len() - ".rlib".len())], true) - } else if file.starts_with(dylib_prefix.as_slice()) && - file.ends_with(dypair.1.as_slice()) { + } else if file.starts_with(&dylib_prefix) && + file.ends_with(&dypair.1) { (&file[(dylib_prefix.len()) .. (file.len() - dypair.1.len())], false) } else { diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index 4c0aefaf83d..7cc7e49b6d2 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -555,7 +555,7 @@ fn parse_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> Ty<'tcx> w 'P' => { assert_eq!(next(st), '['); let trait_ref = parse_trait_ref_(st, conv); - let name = token::intern(parse_str(st, ']').as_slice()); + let name = token::intern(&parse_str(st, ']')); return ty::mk_projection(tcx, trait_ref, name); } 'e' => { @@ -781,7 +781,7 @@ fn parse_projection_predicate_<'a,'tcx, F>( ty::ProjectionPredicate { projection_ty: ty::ProjectionTy { trait_ref: parse_trait_ref_(st, conv), - item_name: token::str_to_ident(parse_str(st, '|').as_slice()).name, + item_name: token::str_to_ident(&parse_str(st, '|')).name, }, ty: parse_ty_(st, conv), } diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 4130195ae40..b0fe743b683 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -1185,7 +1185,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext, rbml_w.tag(c::tag_table_freevars, |rbml_w| { rbml_w.id(id); rbml_w.tag(c::tag_table_val, |rbml_w| { - rbml_w.emit_from_vec(fv.as_slice(), |rbml_w, fv_entry| { + rbml_w.emit_from_vec(fv, |rbml_w, fv_entry| { Ok(encode_freevar_entry(rbml_w, fv_entry)) }); }) diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index 8f5906db589..7ba83c62496 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -310,7 +310,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { Entry => on_entry, Exit => { let mut t = on_entry.to_vec(); - self.apply_gen_kill(cfgidx, t.as_mut_slice()); + self.apply_gen_kill(cfgidx, &mut t); temp_bits = t; &temp_bits[] } @@ -405,7 +405,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { Some(cfg_idx) => { let (start, end) = self.compute_id_range(cfg_idx); let kills = &self.kills[start.. end]; - if bitwise(orig_kills.as_mut_slice(), kills, &Union) { + if bitwise(&mut orig_kills, kills, &Union) { changed = true; } } @@ -450,8 +450,8 @@ impl<'a, 'tcx, O:DataFlowOperator+Clone+'static> DataFlowContext<'a, 'tcx, O> { let mut temp: Vec<_> = repeat(0).take(words_per_id).collect(); while propcx.changed { propcx.changed = false; - propcx.reset(temp.as_mut_slice()); - propcx.walk_cfg(cfg, temp.as_mut_slice()); + propcx.reset(&mut temp); + propcx.walk_cfg(cfg, &mut temp); } } diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 4478e327087..90d26f0f6bf 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -287,7 +287,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> { let def_map = &self.tcx.def_map; match pat.node { ast::PatStruct(_, ref fields, _) => { - self.handle_field_pattern_match(pat, fields.as_slice()); + self.handle_field_pattern_match(pat, fields); } _ if pat_util::pat_is_const(def_map, pat) => { // it might be the only use of a const @@ -313,7 +313,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> { } fn has_allow_dead_code_or_lang_attr(attrs: &[ast::Attribute]) -> bool { - if attr::contains_name(attrs.as_slice(), "lang") { + if attr::contains_name(attrs, "lang") { return true; } @@ -347,7 +347,7 @@ struct LifeSeeder { impl<'v> Visitor<'v> for LifeSeeder { fn visit_item(&mut self, item: &ast::Item) { - let allow_dead_code = has_allow_dead_code_or_lang_attr(item.attrs.as_slice()); + let allow_dead_code = has_allow_dead_code_or_lang_attr(&item.attrs); if allow_dead_code { self.worklist.push(item.id); } @@ -376,7 +376,7 @@ impl<'v> Visitor<'v> for LifeSeeder { // Check for method here because methods are not ast::Item match fk { visit::FkMethod(_, _, method) => { - if has_allow_dead_code_or_lang_attr(method.attrs.as_slice()) { + if has_allow_dead_code_or_lang_attr(&method.attrs) { self.worklist.push(id); } } @@ -467,12 +467,12 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> { is_named && !self.symbol_is_live(node.id, None) && !is_marker_field - && !has_allow_dead_code_or_lang_attr(node.attrs.as_slice()) + && !has_allow_dead_code_or_lang_attr(&node.attrs) } fn should_warn_about_variant(&mut self, variant: &ast::Variant_) -> bool { !self.symbol_is_live(variant.id, None) - && !has_allow_dead_code_or_lang_attr(variant.attrs.as_slice()) + && !has_allow_dead_code_or_lang_attr(&variant.attrs) } // id := node id of an item's definition. diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index 24073848edf..0ce9db1c80f 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -56,7 +56,7 @@ pub fn find_entry_point(session: &Session, ast_map: &ast_map::Map) { } // If the user wants no main function at all, then stop here. - if attr::contains_name(ast_map.krate().attrs.as_slice(), "no_main") { + if attr::contains_name(&ast_map.krate().attrs, "no_main") { session.entry_type.set(Some(config::EntryNone)); return } @@ -96,7 +96,7 @@ fn find_item(item: &Item, ctxt: &mut EntryContext) { }); } - if attr::contains_name(item.attrs.as_slice(), "main") { + if attr::contains_name(&item.attrs, "main") { if ctxt.attr_main_fn.is_none() { ctxt.attr_main_fn = Some((item.id, item.span)); } else { @@ -105,7 +105,7 @@ fn find_item(item: &Item, ctxt: &mut EntryContext) { } } - if attr::contains_name(item.attrs.as_slice(), "start") { + if attr::contains_name(&item.attrs, "start") { if ctxt.start_fn.is_none() { ctxt.start_fn = Some((item.id, item.span)); } else { diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 44a816eb2f8..5cc7502b512 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -639,8 +639,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { None => { self.tcx().sess.span_bug( callee.span, - format!("unexpected callee type {}", - callee_ty.repr(self.tcx())).as_slice()) + &format!("unexpected callee type {}", callee_ty.repr(self.tcx()))) } }; match overloaded_call_type { @@ -1150,7 +1149,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { let msg = format!("Pattern has unexpected type: {:?} and type {}", def, cmt_pat.ty.repr(tcx)); - tcx.sess.span_bug(pat.span, msg.as_slice()) + tcx.sess.span_bug(pat.span, &msg) } } diff --git a/src/librustc/middle/graph.rs b/src/librustc/middle/graph.rs index aca4b3df453..989efdd235d 100644 --- a/src/librustc/middle/graph.rs +++ b/src/librustc/middle/graph.rs @@ -112,14 +112,12 @@ impl<N,E> Graph<N,E> { #[inline] pub fn all_nodes<'a>(&'a self) -> &'a [Node<N>] { - let nodes: &'a [Node<N>] = self.nodes.as_slice(); - nodes + &self.nodes } #[inline] pub fn all_edges<'a>(&'a self) -> &'a [Edge<E>] { - let edges: &'a [Edge<E>] = self.edges.as_slice(); - edges + &self.edges } /////////////////////////////////////////////////////////////////////////// diff --git a/src/librustc/middle/infer/combine.rs b/src/librustc/middle/infer/combine.rs index 8cb2774f7df..daa820f43b5 100644 --- a/src/librustc/middle/infer/combine.rs +++ b/src/librustc/middle/infer/combine.rs @@ -208,8 +208,8 @@ pub trait Combine<'tcx> : Sized { } let inputs = try!(argvecs(self, - a.inputs.as_slice(), - b.inputs.as_slice())); + &a.inputs, + &b.inputs)); let output = try!(match (a.output, b.output) { (ty::FnConverging(a_ty), ty::FnConverging(b_ty)) => diff --git a/src/librustc/middle/infer/error_reporting.rs b/src/librustc/middle/infer/error_reporting.rs index 17b62e463da..05f0c247a75 100644 --- a/src/librustc/middle/infer/error_reporting.rs +++ b/src/librustc/middle/infer/error_reporting.rs @@ -1707,7 +1707,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt, Some(node) => match node { ast_map::NodeItem(item) => match item.node { ast::ItemImpl(_, _, ref gen, _, _, _) => { - taken.push_all(gen.lifetimes.as_slice()); + taken.push_all(&gen.lifetimes); } _ => () }, diff --git a/src/librustc/middle/infer/freshen.rs b/src/librustc/middle/infer/freshen.rs index 8e9911aaefa..1b7e6c33c05 100644 --- a/src/librustc/middle/infer/freshen.rs +++ b/src/librustc/middle/infer/freshen.rs @@ -127,10 +127,10 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> { ty::ty_infer(ty::FreshIntTy(c)) => { if c >= self.freshen_count { self.tcx().sess.bug( - format!("Encountered a freshend type with id {} \ - but our counter is only at {}", - c, - self.freshen_count).as_slice()); + &format!("Encountered a freshend type with id {} \ + but our counter is only at {}", + c, + self.freshen_count)); } t } diff --git a/src/librustc/middle/infer/higher_ranked/mod.rs b/src/librustc/middle/infer/higher_ranked/mod.rs index e4eecd919c8..4469e27a5b0 100644 --- a/src/librustc/middle/infer/higher_ranked/mod.rs +++ b/src/librustc/middle/infer/higher_ranked/mod.rs @@ -133,7 +133,7 @@ impl<'tcx,C> HigherRankedRelations<'tcx> for C self.tcx(), &result0, |r, debruijn| generalize_region(self.infcx(), span, snapshot, debruijn, - new_vars.as_slice(), &a_map, r)); + &new_vars, &a_map, r)); debug!("lub({},{}) = {}", a.repr(self.tcx()), @@ -227,8 +227,8 @@ impl<'tcx,C> HigherRankedRelations<'tcx> for C self.tcx(), &result0, |r, debruijn| generalize_region(self.infcx(), span, snapshot, debruijn, - new_vars.as_slice(), - &a_map, a_vars.as_slice(), b_vars.as_slice(), + &new_vars, + &a_map, &a_vars, &b_vars, r)); debug!("glb({},{}) = {}", diff --git a/src/librustc/middle/infer/region_inference/graphviz.rs b/src/librustc/middle/infer/region_inference/graphviz.rs index 64fdd45e363..6a75b1b0d3d 100644 --- a/src/librustc/middle/infer/region_inference/graphviz.rs +++ b/src/librustc/middle/infer/region_inference/graphviz.rs @@ -71,7 +71,7 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a, let output_path = { let output_template = match requested_output { - Some(ref s) if s.as_slice() == "help" => { + Some(ref s) if &**s == "help" => { static PRINTED_YET: AtomicBool = ATOMIC_BOOL_INIT; if !PRINTED_YET.load(Ordering::SeqCst) { print_help_message(); @@ -92,7 +92,7 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a, let mut new_str = String::new(); for c in output_template.chars() { if c == '%' { - new_str.push_str(subject_node.to_string().as_slice()); + new_str.push_str(&subject_node.to_string()); } else { new_str.push(c); } @@ -104,11 +104,11 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a, }; let constraints = &*region_vars.constraints.borrow(); - match dump_region_constraints_to(tcx, constraints, output_path.as_slice()) { + match dump_region_constraints_to(tcx, constraints, &output_path) { Ok(()) => {} Err(e) => { let msg = format!("io error dumping region constraints: {}", e); - region_vars.tcx.sess.err(msg.as_slice()) + region_vars.tcx.sess.err(&msg) } } } @@ -157,7 +157,7 @@ impl<'a, 'tcx> ConstraintGraph<'a, 'tcx> { impl<'a, 'tcx> dot::Labeller<'a, Node, Edge> for ConstraintGraph<'a, 'tcx> { fn graph_id(&self) -> dot::Id { - dot::Id::new(self.graph_name.as_slice()).ok().unwrap() + dot::Id::new(&*self.graph_name).ok().unwrap() } fn node_id(&self, n: &Node) -> dot::Id { dot::Id::new(format!("node_{}", self.node_ids.get(n).unwrap())).ok().unwrap() diff --git a/src/librustc/middle/infer/region_inference/mod.rs b/src/librustc/middle/infer/region_inference/mod.rs index 919ea0a2520..a5c40cac9e5 100644 --- a/src/librustc/middle/infer/region_inference/mod.rs +++ b/src/librustc/middle/infer/region_inference/mod.rs @@ -973,8 +973,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { debug!("----() End constraint listing {:?}---", self.dump_constraints()); graphviz::maybe_print_constraints_for(self, subject); - self.expansion(var_data.as_mut_slice()); - self.contraction(var_data.as_mut_slice()); + self.expansion(&mut var_data); + self.contraction(&mut var_data); let values = self.extract_values_and_collect_conflicts(&var_data[], errors); @@ -1303,12 +1303,12 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { match var_data[idx].classification { Expanding => { self.collect_error_for_expanding_node( - graph, var_data, dup_vec.as_mut_slice(), + graph, var_data, &mut dup_vec, node_vid, errors); } Contracting => { self.collect_error_for_contracting_node( - graph, var_data, dup_vec.as_mut_slice(), + graph, var_data, &mut dup_vec, node_vid, errors); } } diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index d9b90c1935a..8a293a67727 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -147,7 +147,7 @@ struct LanguageItemCollector<'a> { impl<'a, 'v> Visitor<'v> for LanguageItemCollector<'a> { fn visit_item(&mut self, item: &ast::Item) { - match extract(item.attrs.as_slice()) { + match extract(&item.attrs) { Some(value) => { let item_index = self.item_refs.get(value.get()).map(|x| *x); diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 365355c4a2a..5e27023e026 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -456,13 +456,13 @@ impl<'a> LifetimeContext<'a> { if let Some((_, lifetime_def)) = search_lifetimes(lifetimes, lifetime) { self.sess.span_warn( lifetime.span, - format!("lifetime name `{}` shadows another \ - lifetime name that is already in scope", - token::get_name(lifetime.name)).as_slice()); + &format!("lifetime name `{}` shadows another \ + lifetime name that is already in scope", + token::get_name(lifetime.name))); self.sess.span_note( lifetime_def.span, - format!("shadowed lifetime `{}` declared here", - token::get_name(lifetime.name)).as_slice()); + &format!("shadowed lifetime `{}` declared here", + token::get_name(lifetime.name))); self.sess.span_note( lifetime.span, "shadowed lifetimes are deprecated \ diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 3304bd4ae29..dfbd11957da 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -57,7 +57,7 @@ impl<'a> Annotator<'a> { attrs: &Vec<Attribute>, item_sp: Span, f: F, required: bool) where F: FnOnce(&mut Annotator), { - match attr::find_stability(self.sess.diagnostic(), attrs.as_slice(), item_sp) { + match attr::find_stability(self.sess.diagnostic(), attrs, item_sp) { Some(stab) => { self.index.local.insert(id, stab.clone()); diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index eb6bc4c3835..8cb0447e732 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -406,7 +406,7 @@ impl<T> VecPerParamSpace<T> { } pub fn as_slice(&self) -> &[T] { - self.content.as_slice() + &self.content } pub fn into_vec(self) -> Vec<T> { diff --git a/src/librustc/middle/traits/doc.rs b/src/librustc/middle/traits/doc.rs index 8ce4e38896e..d69f340ca17 100644 --- a/src/librustc/middle/traits/doc.rs +++ b/src/librustc/middle/traits/doc.rs @@ -24,7 +24,7 @@ reference to a trait. So, for example, if there is a generic function like: and then a call to that function: - let v: Vec<int> = clone_slice([1, 2, 3].as_slice()) + let v: Vec<int> = clone_slice([1, 2, 3]) it is the job of trait resolution to figure out (in which case) whether there exists an impl of `int : Clone` diff --git a/src/librustc/middle/traits/error_reporting.rs b/src/librustc/middle/traits/error_reporting.rs index b8886fa65ba..a1f3737cbb2 100644 --- a/src/librustc/middle/traits/error_reporting.rs +++ b/src/librustc/middle/traits/error_reporting.rs @@ -93,7 +93,7 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, Piece::String(s) => Some(s), Piece::NextArgument(a) => match a.position { Position::ArgumentNamed(s) => match generic_map.get(s) { - Some(val) => Some(val.as_slice()), + Some(val) => Some(val), None => { span_err!(infcx.tcx.sess, err_sp, E0272, "the #[rustc_on_unimplemented] \ @@ -181,7 +181,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, obligation.cause.span); if let Some(s) = custom_note { infcx.tcx.sess.span_note(obligation.cause.span, - s.as_slice()); + &s); } } } @@ -289,12 +289,12 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, // Ambiguity. Coherence should have reported an error. infcx.tcx.sess.span_bug( obligation.cause.span, - format!( + &format!( "coherence failed to report ambiguity: \ cannot locate the impl of the trait `{}` for \ the type `{}`", trait_ref.user_string(infcx.tcx), - self_ty.user_string(infcx.tcx)).as_slice()); + self_ty.user_string(infcx.tcx))); } } @@ -330,14 +330,14 @@ fn note_obligation_cause_code<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, let item_name = ty::item_path_str(tcx, item_def_id); tcx.sess.span_note( cause_span, - format!("required by `{}`", item_name).as_slice()); + &format!("required by `{}`", item_name)); } ObligationCauseCode::ObjectCastObligation(object_ty) => { tcx.sess.span_note( cause_span, - format!( + &format!( "required for the cast to the object type `{}`", - infcx.ty_to_string(object_ty)).as_slice()); + infcx.ty_to_string(object_ty))); } ObligationCauseCode::RepeatVec => { tcx.sess.span_note( diff --git a/src/librustc/middle/traits/fulfill.rs b/src/librustc/middle/traits/fulfill.rs index 8adcd256cce..07c7453783d 100644 --- a/src/librustc/middle/traits/fulfill.rs +++ b/src/librustc/middle/traits/fulfill.rs @@ -180,7 +180,7 @@ impl<'tcx> FulfillmentContext<'tcx> { { match self.region_obligations.get(&body_id) { None => Default::default(), - Some(vec) => vec.as_slice(), + Some(vec) => vec, } } diff --git a/src/librustc/middle/traits/project.rs b/src/librustc/middle/traits/project.rs index c2a451b405b..9d3ad28e613 100644 --- a/src/librustc/middle/traits/project.rs +++ b/src/librustc/middle/traits/project.rs @@ -605,8 +605,8 @@ fn assemble_candidates_from_object_type<'cx,'tcx>( _ => { selcx.tcx().sess.span_bug( obligation.cause.span, - format!("assemble_candidates_from_object_type called with non-object: {}", - object_ty.repr(selcx.tcx())).as_slice()); + &format!("assemble_candidates_from_object_type called with non-object: {}", + object_ty.repr(selcx.tcx()))); } }; let projection_bounds = data.projection_bounds_with_self_ty(selcx.tcx(), object_ty); @@ -693,8 +693,8 @@ fn assemble_candidates_from_impls<'cx,'tcx>( // These traits have no associated types. selcx.tcx().sess.span_bug( obligation.cause.span, - format!("Cannot project an associated type from `{}`", - vtable.repr(selcx.tcx())).as_slice()); + &format!("Cannot project an associated type from `{}`", + vtable.repr(selcx.tcx()))); } } @@ -813,10 +813,10 @@ fn confirm_param_env_candidate<'cx,'tcx>( Err(e) => { selcx.tcx().sess.span_bug( obligation.cause.span, - format!("Failed to unify `{}` and `{}` in projection: {}", - obligation.repr(selcx.tcx()), - projection.repr(selcx.tcx()), - ty::type_err_to_str(selcx.tcx(), &e)).as_slice()); + &format!("Failed to unify `{}` and `{}` in projection: {}", + obligation.repr(selcx.tcx()), + projection.repr(selcx.tcx()), + ty::type_err_to_str(selcx.tcx(), &e))); } } diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index b8af91add9e..2ea16d55343 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -933,9 +933,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { _ => { self.tcx().sess.span_bug( obligation.cause.span, - format!("match_projection_obligation_against_bounds_from_trait() called \ - but self-ty not a projection: {}", - skol_trait_predicate.trait_ref.self_ty().repr(self.tcx())).as_slice()); + &format!("match_projection_obligation_against_bounds_from_trait() called \ + but self-ty not a projection: {}", + skol_trait_predicate.trait_ref.self_ty().repr(self.tcx()))); } }; debug!("match_projection_obligation_against_bounds_from_trait: \ @@ -1787,9 +1787,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { Ok(obligations) => obligations, Err(()) => { self.tcx().sess.bug( - format!("Where clause `{}` was applicable to `{}` but now is not", - param.repr(self.tcx()), - obligation.repr(self.tcx())).as_slice()); + &format!("Where clause `{}` was applicable to `{}` but now is not", + param.repr(self.tcx()), + obligation.repr(self.tcx()))); } } } @@ -1953,9 +1953,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { Some(r) => r, None => { self.tcx().sess.span_bug(obligation.cause.span, - format!("unable to upcast from {} to {}", - poly_trait_ref.repr(self.tcx()), - obligation_def_id.repr(self.tcx())).as_slice()); + &format!("unable to upcast from {} to {}", + poly_trait_ref.repr(self.tcx()), + obligation_def_id.repr(self.tcx()))); } }; diff --git a/src/librustc/middle/traits/util.rs b/src/librustc/middle/traits/util.rs index 45ce692bb07..5180b8379ea 100644 --- a/src/librustc/middle/traits/util.rs +++ b/src/librustc/middle/traits/util.rs @@ -279,7 +279,7 @@ pub fn trait_ref_for_builtin_bound<'tcx>( })) } Err(e) => { - tcx.sess.err(e.as_slice()); + tcx.sess.err(&e); Err(ErrorReported) } } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 5f4880fb266..6964a0b9db8 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -2793,7 +2793,7 @@ pub fn mk_trait<'tcx>(cx: &ctxt<'tcx>, bounds: ExistentialBounds<'tcx>) -> Ty<'tcx> { - assert!(bound_list_is_sorted(bounds.projection_bounds.as_slice())); + assert!(bound_list_is_sorted(&bounds.projection_bounds)); let inner = box TyTrait { principal: principal, @@ -3406,8 +3406,8 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents { // FIXME(#14449): `borrowed_contents` below assumes `&mut` closure. let param_env = ty::empty_parameter_environment(cx); let upvars = closure_upvars(¶m_env, did, substs).unwrap(); - TypeContents::union(upvars.as_slice(), - |f| tc_ty(cx, f.ty, cache)) + TypeContents::union(&upvars, + |f| tc_ty(cx, &f.ty, cache)) | borrowed_contents(*r, MutMutable) } @@ -3672,8 +3672,7 @@ pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool { ty_closure(..) => { // this check is run on type definitions, so we don't expect to see // inference by-products or closure types - cx.sess.bug(format!("requires check invoked on inapplicable type: {:?}", - ty).as_slice()) + cx.sess.bug(&format!("requires check invoked on inapplicable type: {:?}", ty)) } ty_tup(ref ts) => { @@ -3766,8 +3765,7 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>) ty_closure(..) => { // this check is run on type definitions, so we don't expect // to see closure types - cx.sess.bug(format!("requires check invoked on inapplicable type: {:?}", - ty).as_slice()) + cx.sess.bug(&format!("requires check invoked on inapplicable type: {:?}", ty)) } _ => Representable, } @@ -6365,9 +6363,9 @@ pub fn construct_parameter_environment<'a,'tcx>( _ => { // All named regions are instantiated with free regions. tcx.sess.bug( - format!("record_region_bounds: non free region: {} / {}", - r_a.repr(tcx), - r_b.repr(tcx)).as_slice()); + &format!("record_region_bounds: non free region: {} / {}", + r_a.repr(tcx), + r_b.repr(tcx))); } } } diff --git a/src/librustc/middle/ty_walk.rs b/src/librustc/middle/ty_walk.rs index a9121951460..40dfd479364 100644 --- a/src/librustc/middle/ty_walk.rs +++ b/src/librustc/middle/ty_walk.rs @@ -39,9 +39,9 @@ impl<'tcx> TypeWalker<'tcx> { } ty::ty_trait(box ty::TyTrait { ref principal, ref bounds }) => { self.push_reversed(principal.substs().types.as_slice()); - self.push_reversed(bounds.projection_bounds.iter().map(|pred| { + self.push_reversed(&bounds.projection_bounds.iter().map(|pred| { pred.0.ty - }).collect::<Vec<_>>().as_slice()); + }).collect::<Vec<_>>()); } ty::ty_enum(_, ref substs) | ty::ty_struct(_, ref substs) | @@ -49,7 +49,7 @@ impl<'tcx> TypeWalker<'tcx> { self.push_reversed(substs.types.as_slice()); } ty::ty_tup(ref ts) => { - self.push_reversed(ts.as_slice()); + self.push_reversed(ts); } ty::ty_bare_fn(_, ref ft) => { self.push_sig_subtypes(&ft.sig); @@ -62,7 +62,7 @@ impl<'tcx> TypeWalker<'tcx> { ty::FnConverging(output) => { self.stack.push(output); } ty::FnDiverging => { } } - self.push_reversed(sig.0.inputs.as_slice()); + self.push_reversed(&sig.0.inputs); } fn push_reversed(&mut self, tys: &[Ty<'tcx>]) { diff --git a/src/librustc/middle/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs index 425c9a4c9f7..b23d05ca64c 100644 --- a/src/librustc/middle/weak_lang_items.rs +++ b/src/librustc/middle/weak_lang_items.rs @@ -85,8 +85,8 @@ fn verify(sess: &Session, items: &lang_items::LanguageItems) { $( if missing.contains(&lang_items::$item) && items.$name().is_none() { - sess.err(format!("language item required, but not found: `{}`", - stringify!($name)).as_slice()); + sess.err(&format!("language item required, but not found: `{}`", + stringify!($name))); } )* @@ -108,7 +108,7 @@ impl<'a> Context<'a> { impl<'a, 'v> Visitor<'v> for Context<'a> { fn visit_foreign_item(&mut self, i: &ast::ForeignItem) { - match lang_items::extract(i.attrs.as_slice()) { + match lang_items::extract(&i.attrs) { None => {} Some(lang_item) => self.register(lang_item.get(), i.span), } diff --git a/src/librustc/plugin/build.rs b/src/librustc/plugin/build.rs index 110e672b70f..818af33c34d 100644 --- a/src/librustc/plugin/build.rs +++ b/src/librustc/plugin/build.rs @@ -24,7 +24,7 @@ struct RegistrarFinder { impl<'v> Visitor<'v> for RegistrarFinder { fn visit_item(&mut self, item: &ast::Item) { if let ast::ItemFn(..) = item.node { - if attr::contains_name(item.attrs.as_slice(), + if attr::contains_name(&item.attrs, "plugin_registrar") { self.registrars.push((item.id, item.span)); } diff --git a/src/librustc/plugin/load.rs b/src/librustc/plugin/load.rs index dd0b0a63ced..a7592226fd6 100644 --- a/src/librustc/plugin/load.rs +++ b/src/librustc/plugin/load.rs @@ -82,8 +82,8 @@ pub fn load_plugins(sess: &Session, krate: &ast::Crate, visit::walk_crate(&mut loader, krate); if let Some(plugins) = addl_plugins { - for plugin in &plugins { - loader.load_plugin(CrateOrString::Str(plugin.as_slice()), + for plugin in plugins { + loader.load_plugin(CrateOrString::Str(&plugin), None, None, None) } } diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 8faf81a1564..5dfb16528e0 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -638,7 +638,7 @@ pub fn build_target_config(opts: &Options, sp: &SpanHandler) -> Config { let target = match Target::search(&opts.target_triple[]) { Ok(t) => t, Err(e) => { - sp.handler().fatal((format!("Error loading target specification: {}", e)).as_slice()); + sp.handler().fatal(&format!("Error loading target specification: {}", e)); } }; @@ -856,7 +856,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { let unparsed_output_types = matches.opt_strs("emit"); for unparsed_output_type in &unparsed_output_types { for part in unparsed_output_type.split(',') { - let output_type = match part.as_slice() { + let output_type = match part { "asm" => OutputTypeAssembly, "llvm-ir" => OutputTypeLlvmAssembly, "llvm-bc" => OutputTypeBitcode, @@ -897,9 +897,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { Some(2) => Default, Some(3) => Aggressive, Some(arg) => { - early_error(format!("optimization level needs to be \ - between 0-3 (instead was `{}`)", - arg).as_slice()); + early_error(&format!("optimization level needs to be \ + between 0-3 (instead was `{}`)", + arg)); } } } @@ -916,9 +916,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { Some(1) => LimitedDebugInfo, Some(2) => FullDebugInfo, Some(arg) => { - early_error(format!("debug info level needs to be between \ - 0-2 (instead was `{}`)", - arg).as_slice()); + early_error(&format!("debug info level needs to be between \ + 0-2 (instead was `{}`)", + arg)); } } }; @@ -937,9 +937,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { "framework" => cstore::NativeFramework, "static" => cstore::NativeStatic, s => { - early_error(format!("unknown library kind `{}`, expected \ - one of dylib, framework, or static", - s).as_slice()); + early_error(&format!("unknown library kind `{}`, expected \ + one of dylib, framework, or static", + s)); } }; return (name.to_string(), kind) @@ -968,12 +968,12 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { let write_dependency_info = (output_types.contains(&OutputTypeDepInfo), None); let prints = matches.opt_strs("print").into_iter().map(|s| { - match s.as_slice() { + match &*s { "crate-name" => PrintRequest::CrateName, "file-names" => PrintRequest::FileNames, "sysroot" => PrintRequest::Sysroot, req => { - early_error(format!("unknown print request `{}`", req).as_slice()) + early_error(&format!("unknown print request `{}`", req)) } } }).collect::<Vec<_>>(); diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 07fbecbdebc..bd44dbe78f5 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -332,7 +332,7 @@ pub fn build_session_(sopts: config::Options, Ok(t) => t, Err(e) => { span_diagnostic.handler() - .fatal((format!("Error loading host specification: {}", e)).as_slice()); + .fatal(&format!("Error loading host specification: {}", e)); } }; let target_cfg = config::build_target_config(&sopts, &span_diagnostic); diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index ff80bc550cb..d39e1b8977a 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -116,7 +116,7 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region) region::CodeExtent::Remainder(r) => { new_string = format!("block suffix following statement {}", r.first_statement_index); - new_string.as_slice() + &*new_string } }; explain_span(cx, scope_decorated_tag, span) @@ -263,7 +263,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String { match unsafety { ast::Unsafety::Normal => {} ast::Unsafety::Unsafe => { - s.push_str(unsafety.to_string().as_slice()); + s.push_str(&unsafety.to_string()); s.push(' '); } }; @@ -315,7 +315,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String { .iter() .map(|a| ty_to_string(cx, *a)) .collect::<Vec<_>>(); - s.push_str(strs.connect(", ").as_slice()); + s.push_str(&strs.connect(", ")); if sig.0.variadic { s.push_str(", ..."); } @@ -392,7 +392,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String { ty_enum(did, substs) | ty_struct(did, substs) => { let base = ty::item_path_str(cx, did); let generics = ty::lookup_item_type(cx, did).generics; - parameterized(cx, base.as_slice(), substs, &generics, did, &[]) + parameterized(cx, &base, substs, &generics, did, &[]) } ty_trait(ref data) => { data.user_string(cx) @@ -643,7 +643,7 @@ impl<'tcx> UserString<'tcx> for TraitAndProjections<'tcx> { let base = ty::item_path_str(tcx, trait_ref.def_id); let trait_def = ty::lookup_trait_def(tcx, trait_ref.def_id); parameterized(tcx, - base.as_slice(), + &base, trait_ref.substs, &trait_def.generics, trait_ref.def_id, @@ -780,7 +780,7 @@ impl<'tcx> Repr<'tcx> for ty::TraitRef<'tcx> { let trait_def = ty::lookup_trait_def(tcx, self.def_id); format!("TraitRef({}, {})", self.substs.self_ty().repr(tcx), - parameterized(tcx, base.as_slice(), self.substs, + parameterized(tcx, &base, self.substs, &trait_def.generics, self.def_id, &[])) } } @@ -1235,7 +1235,7 @@ impl<'tcx> UserString<'tcx> for ty::TraitRef<'tcx> { fn user_string(&self, tcx: &ctxt<'tcx>) -> String { let path_str = ty::item_path_str(tcx, self.def_id); let trait_def = ty::lookup_trait_def(tcx, self.def_id); - parameterized(tcx, path_str.as_slice(), self.substs, + parameterized(tcx, &path_str, self.substs, &trait_def.generics, self.def_id, &[]) } } |
