let mut buf = String::new();
if s.is_empty() { continue; }
for ch in s.chars() {
- if !buf.is_empty() && buf.as_slice() != "'"
+ if !buf.is_empty() && buf != "'"
&& ch.is_uppercase()
&& !last_upper {
words.push(buf);
fn register_native_lib(sess: &Session, span: Option<Span>, name: String,
kind: cstore::NativeLibaryKind) {
- if name.as_slice().is_empty() {
+ if name.is_empty() {
match span {
Some(span) => {
sess.span_err(span, "#[link(name = \"\")] given with \
hash: Option<&Svh>) -> Option<ast::CrateNum> {
let mut ret = None;
e.sess.cstore.iter_crate_data(|cnum, data| {
- if data.name.as_slice() != name { return }
+ if data.name != name { return }
match hash {
Some(hash) if *hash == data.hash() => { ret = Some(cnum); return }
let mut ordering = Vec::new();
fn visit(cstore: &CStore, cnum: ast::CrateNum,
ordering: &mut Vec<ast::CrateNum>) {
- if ordering.as_slice().contains(&cnum) { return }
+ if ordering.contains(&cnum) { return }
let meta = cstore.get_crate_data(cnum);
for (_, &dep) in meta.cnum_map.iter() {
visit(cstore, dep, ordering);
visit(self, num, &mut ordering);
}
ordering.as_mut_slice().reverse();
- let ordering = ordering.as_slice();
let mut libs = self.used_crate_sources.borrow()
.iter()
.map(|src| (src.cnum, match prefer {
// encoded metadata for static methods relative to Bar,
// but not yet for Foo.
//
- if path_differs || original_name.get() != exp.name.as_slice() {
+ if path_differs || original_name.get() != exp.name {
if !encode_reexported_static_base_methods(ecx, rbml_w, exp) {
if encode_reexported_static_trait_methods(ecx, rbml_w, exp) {
debug!("(encode reexported static methods) {} [trait]",
let mut env_rust_path: Vec<Path> = match get_rust_path() {
Some(env_path) => {
let env_path_components =
- env_path.as_slice().split_str(PATH_ENTRY_SEPARATOR);
+ env_path.split_str(PATH_ENTRY_SEPARATOR);
env_path_components.map(|s| Path::new(s)).collect()
}
None => Vec::new()
fn crate_matches(&mut self, crate_data: &[u8], libpath: &Path) -> bool {
if self.should_match_name {
match decoder::maybe_get_crate_name(crate_data) {
- Some(ref name) if self.crate_name == name.as_slice() => {}
+ Some(ref name) if self.crate_name == *name => {}
_ => { info!("Rejecting via crate name"); return false }
}
}
None => { debug!("triple not present"); return false }
Some(t) => t,
};
- if triple.as_slice() != self.triple {
+ if triple != self.triple {
info!("Rejecting via crate triple: expected {} got {}", self.triple, triple);
self.rejected_via_triple.push(CrateMismatch {
path: libpath.clone(),
let name = String::from_raw_buf_len(name_buf as *const u8,
name_len as uint);
debug!("get_metadata_section: name {}", name);
- if read_meta_section_name(is_osx).as_slice() == name.as_slice() {
+ if read_meta_section_name(is_osx) == name {
let cbuf = llvm::LLVMGetSectionContents(si.llsi);
let csz = llvm::LLVMGetSectionSize(si.llsi) as uint;
let cvbuf: *const u8 = cbuf as *const u8;
debug!("fragments 3 assigned: {}", path_lps(assigned.as_slice()));
// Fourth, build the leftover from the moved, assigned, and parents.
- for m in moved.as_slice().iter() {
+ for m in moved.iter() {
let lp = this.path_loan_path(*m);
add_fragment_siblings(this, tcx, &mut unmoved, lp, None);
}
- for a in assigned.as_slice().iter() {
+ for a in assigned.iter() {
let lp = this.path_loan_path(*a);
add_fragment_siblings(this, tcx, &mut unmoved, lp, None);
}
- for p in parents.as_slice().iter() {
+ for p in parents.iter() {
let lp = this.path_loan_path(*p);
add_fragment_siblings(this, tcx, &mut unmoved, lp, None);
}
fn replace_newline_with_backslash_l(s: String) -> String {
// Replacing newlines with \\l causes each line to be left-aligned,
// improving presentation of (long) pretty-printed expressions.
- if s.as_slice().contains("\n") {
+ if s.contains("\n") {
let mut s = s.replace("\n", "\\l");
// Apparently left-alignment applies to the line that precedes
// \l, not the line that follows; so, add \l at end of string
// if not already present, ensuring last line gets left-aligned
// as well.
let mut last_two: Vec<_> =
- s.as_slice().chars().rev().take(2).collect();
+ s.chars().rev().take(2).collect();
last_two.reverse();
if last_two != ['\\', 'l'] {
s.push_str("\\l");
for attr in lint::gather_attrs(attrs).into_iter() {
match attr {
Ok((ref name, lint::Allow, _))
- if name.get() == dead_code.as_slice() => return true,
+ if name.get() == dead_code => return true,
_ => (),
}
}
// the same bindings, and we also consider the first pattern to be
// the "authoritative" set of ids
let arm_succ =
- self.define_bindings_in_arm_pats(arm.pats.as_slice().head().map(|p| &**p),
+ self.define_bindings_in_arm_pats(arm.pats.head().map(|p| &**p),
guard_succ);
self.merge_from_succ(ln, arm_succ, first_merge);
first_merge = false;
// only consider the first pattern; any later patterns must have
// the same bindings, and we also consider the first pattern to be
// the "authoritative" set of ids
- this.arm_pats_bindings(arm.pats.as_slice().head().map(|p| &**p), |this, ln, var, sp, id| {
+ this.arm_pats_bindings(arm.pats.head().map(|p| &**p), |this, ln, var, sp, id| {
this.warn_about_unused(sp, id, ln, var);
});
visit::walk_arm(this, arm);
let module_path = match view_path.node {
ViewPathSimple(_, ref full_path, _) => {
full_path.segments
- .as_slice().init()
+ .init()
.iter().map(|ident| ident.identifier.name)
.collect()
}
continue;
}
};
- let module_path = module_path.as_slice().init();
+ let module_path = module_path.init();
(module_path.to_vec(), name)
}
};
.codemap()
.span_to_snippet((*imports)[index].span)
.unwrap();
- if sn.as_slice().contains("::") {
+ if sn.contains("::") {
self.resolve_error((*imports)[index].span,
"unresolved import");
} else {
let err = format!("unresolved import (maybe you meant `{}::*`?)",
- sn.as_slice().slice(0, sn.len()));
+ sn.slice(0, sn.len()));
self.resolve_error((*imports)[index].span, err.as_slice());
}
}
});
if method_scope && token::get_name(self.self_name).get()
- == wrong_name.as_slice() {
+ == wrong_name {
self.resolve_error(
expr.span,
"`self` is not available \
res = res | TC::ReachesFfiUnsafe;
}
- match repr_hints.as_slice().get(0) {
+ match repr_hints.get(0) {
Some(h) => if !h.is_ffi_safe() {
res = res | TC::ReachesFfiUnsafe;
},
variant: Option<ast::DefId>) -> Option<Ty<'tcx>> {
match (&ty.sty, variant) {
- (&ty_tup(ref v), None) => v.as_slice().get(i).map(|&t| t),
+ (&ty_tup(ref v), None) => v.get(i).map(|&t| t),
(&ty_struct(def_id, ref substs), None) => lookup_struct_fields(cx, def_id)
- .as_slice().get(i)
+ .get(i)
.map(|&t|lookup_item_type(cx, t.id).ty.subst(cx, substs)),
(&ty_enum(def_id, ref substs), Some(variant_def_id)) => {
let variant_info = enum_variant_with_id(cx, def_id, variant_def_id);
- variant_info.args.as_slice().get(i).map(|t|t.subst(cx, substs))
+ variant_info.args.get(i).map(|t|t.subst(cx, substs))
}
(&ty_enum(def_id, ref substs), None) => {
assert!(enum_is_univariant(cx, def_id));
let enum_variants = enum_variants(cx, def_id);
let variant_info = &(*enum_variants)[0];
- variant_info.args.as_slice().get(i).map(|t|t.subst(cx, substs))
+ variant_info.args.get(i).map(|t|t.subst(cx, substs))
}
_ => None
{
let mut cg = basic_codegen_options();
for option in matches.opt_strs("C").into_iter() {
- let mut iter = option.as_slice().splitn(1, '=');
+ let mut iter = option.splitn(1, '=');
let key = iter.next().unwrap();
let value = iter.next();
let option_to_lookup = key.replace("-", "_");
let mut found = false;
for &(candidate, setter, opt_type_desc, _) in CG_OPTIONS.iter() {
- if option_to_lookup.as_slice() != candidate { continue }
+ if option_to_lookup != candidate { continue }
if !setter(&mut cg, value) {
match (value, opt_type_desc) {
(Some(..), None) => {
for &level in [lint::Allow, lint::Warn, lint::Deny, lint::Forbid].iter() {
for lint_name in matches.opt_strs(level.as_str()).into_iter() {
- if lint_name.as_slice() == "help" {
+ if lint_name == "help" {
describe_lints = true;
} else {
lint_opts.push((lint_name.replace("-", "_").into_string(), level));
let debug_map = debugging_opts_map();
for debug_flag in debug_flags.iter() {
let mut this_bit = 0;
- for tuple in debug_map.iter() {
- let (name, bit) = match *tuple { (ref a, _, b) => (a, b) };
- if *name == debug_flag.as_slice() {
+ for &(name, _, bit) in debug_map.iter() {
+ if name == *debug_flag {
this_bit = bit;
break;
}
if !parse_only && !no_trans {
let unparsed_output_types = matches.opt_strs("emit");
for unparsed_output_type in unparsed_output_types.iter() {
- for part in unparsed_output_type.as_slice().split(',') {
+ for part in unparsed_output_type.split(',') {
let output_type = match part.as_slice() {
"asm" => OutputTypeAssembly,
"ir" => OutputTypeLlvmAssembly,
}).collect();
let libs = matches.opt_strs("l").into_iter().map(|s| {
- let mut parts = s.as_slice().rsplitn(1, ':');
+ let mut parts = s.rsplitn(1, ':');
let kind = parts.next().unwrap();
let (name, kind) = match (parts.next(), kind) {
(None, name) |
let mut externs = HashMap::new();
for arg in matches.opt_strs("extern").iter() {
- let mut parts = arg.as_slice().splitn(1, '=');
+ let mut parts = arg.splitn(1, '=');
let name = match parts.next() {
Some(s) => s,
None => early_error("--extern value must not be empty"),
let mut crate_types: Vec<CrateType> = Vec::new();
for unparsed_crate_type in list_list.iter() {
- for part in unparsed_crate_type.as_slice().split(',') {
+ for part in unparsed_crate_type.split(',') {
let new_part = match part {
"lib" => default_lib_output(),
"rlib" => CrateTypeRlib,
let can_print_warnings = sopts.lint_opts
.iter()
- .filter(|&&(ref key, _)| key.as_slice() == "warnings")
+ .filter(|&&(ref key, _)| *key == "warnings")
.map(|&(_, ref level)| *level != lint::Allow)
.last()
.unwrap_or(true);
pub fn ty_to_short_str<'tcx>(cx: &ctxt<'tcx>, typ: Ty<'tcx>) -> String {
let mut s = typ.repr(cx).to_string();
if s.len() >= 32u {
- s = s.as_slice().slice(0u, 32u).to_string();
+ s = s.slice(0u, 32u).to_string();
}
return s;
}