Skip to content

Remove remaining uses of &foo[] from our code base #22592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libgetopts/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {

// FIXME: #5516 should be graphemes not codepoints
// wrapped description
row.push_str(&desc_rows.connect(&desc_sep[..])[]);
row.push_str(&desc_rows.connect(&desc_sep[..]));

row
});
Expand Down
26 changes: 13 additions & 13 deletions src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,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, "automatically_derived") {
return
}
let did = match item.node {
Expand Down Expand Up @@ -652,7 +652,7 @@ impl LintPass for UnusedAttributes {

if !attr::is_used(attr) {
cx.span_lint(UNUSED_ATTRIBUTES, attr.span, "unused attribute");
if KNOWN_ATTRIBUTES.contains(&(&attr.name()[], AttributeType::CrateLevel)) {
if KNOWN_ATTRIBUTES.contains(&(&attr.name(), AttributeType::CrateLevel)) {
let msg = match attr.node.style {
ast::AttrOuter => "crate-level attribute should be an inner \
attribute: add an exclamation mark: #![foo]",
Expand Down Expand Up @@ -732,7 +732,7 @@ 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, s.span);
}
} else {
let attrs = csearch::get_item_attrs(&cx.sess().cstore, did);
Expand Down Expand Up @@ -1093,7 +1093,7 @@ impl UnusedParens {
if !necessary {
cx.span_lint(UNUSED_PARENS, value.span,
&format!("unnecessary parentheses around {}",
msg)[])
msg))
}
}

Expand Down Expand Up @@ -1235,7 +1235,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()))
}
}
}
Expand Down Expand Up @@ -1339,7 +1339,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 {
self.check_unused_mut_pat(cx, &a.pats[])
self.check_unused_mut_pat(cx, &a.pats)
}
}
}
Expand Down Expand Up @@ -1460,7 +1460,7 @@ impl MissingDoc {
});
if !has_doc {
cx.span_lint(MISSING_DOCS, sp,
&format!("missing documentation for {}", desc)[]);
&format!("missing documentation for {}", desc));
}
}
}
Expand Down Expand Up @@ -1496,7 +1496,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,
krate.span, "crate");
}

Expand All @@ -1510,7 +1510,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,
it.span, desc);
}

Expand All @@ -1523,13 +1523,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,
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,
tm.span, "a type method");
}

Expand All @@ -1539,14 +1539,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, 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,
v.span, "a variant");
assert!(!self.in_variant);
self.in_variant = true;
Expand Down
20 changes: 10 additions & 10 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl LintStore {
}

pub fn get_lints<'t>(&'t self) -> &'t [(&'static Lint, bool)] {
&self.lints[]
&self.lints
}

pub fn get_lint_groups<'t>(&'t self) -> Vec<(&'static str, Vec<LintId>, bool)> {
Expand Down Expand Up @@ -276,7 +276,7 @@ impl LintStore {
.collect::<Vec<()>>();
}
None => sess.err(&format!("unknown {} flag: {}",
level.as_str(), lint_name)[]),
level.as_str(), lint_name)),
}
}
}
Expand Down Expand Up @@ -527,7 +527,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));
} else if now != level {
let src = self.lints.get_level_source(lint_id).1;
self.level_stack.push((lint_id, (now, src)));
Expand Down Expand Up @@ -562,15 +562,15 @@ 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, |cx| {
run_lints!(cx, check_item, it);
cx.visit_ids(|v| v.visit_item(it));
visit::walk_item(cx, it);
})
}

fn visit_foreign_item(&mut self, it: &ast::ForeignItem) {
self.with_lint_attrs(&it.attrs[], |cx| {
self.with_lint_attrs(&it.attrs, |cx| {
run_lints!(cx, check_foreign_item, it);
visit::walk_foreign_item(cx, it);
})
Expand All @@ -595,7 +595,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, |cx| {
run_lints!(cx, check_fn, fk, decl, body, span, id);
cx.visit_ids(|v| {
v.visit_fn(fk, decl, body, span, id);
Expand All @@ -611,7 +611,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, |cx| {
run_lints!(cx, check_ty_method, t);
visit::walk_ty_method(cx, t);
})
Expand All @@ -628,14 +628,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, |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, |cx| {
run_lints!(cx, check_variant, v, g);
visit::walk_variant(cx, v, g);
run_lints!(cx, check_variant_post, v, g);
Expand Down Expand Up @@ -779,7 +779,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, |cx| {
cx.visit_id(ast::CRATE_NODE_ID);
cx.visit_ids(|v| {
v.visited_outermost = true;
Expand Down
22 changes: 11 additions & 11 deletions src/librustc/metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn dump_crates(cstore: &CStore) {
}

fn should_link(i: &ast::Item) -> bool {
!attr::contains_name(&i.attrs[], "no_link")
!attr::contains_name(&i.attrs, "no_link")
}

struct CrateInfo {
Expand All @@ -85,7 +85,7 @@ pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option<Span>) {
for c in s.chars() {
if c.is_alphanumeric() { continue }
if c == '_' || c == '-' { continue }
err(&format!("invalid character `{}` in crate name: `{}`", c, s)[]);
err(&format!("invalid character `{}` in crate name: `{}`", c, s));
}
match sess {
Some(sess) => sess.abort_if_errors(),
Expand Down Expand Up @@ -210,8 +210,8 @@ impl<'a> CrateReader<'a> {
match self.extract_crate_info(i) {
Some(info) => {
let (cnum, _, _) = self.resolve_crate(&None,
&info.ident[],
&info.name[],
&info.ident,
&info.name,
None,
i.span,
PathKind::Crate);
Expand Down Expand Up @@ -268,7 +268,7 @@ impl<'a> CrateReader<'a> {
} else {
self.sess.span_err(m.span,
&format!("unknown kind: `{}`",
k)[]);
k));
cstore::NativeUnknown
}
}
Expand Down Expand Up @@ -413,7 +413,7 @@ impl<'a> CrateReader<'a> {
hash: hash.map(|a| &*a),
filesearch: self.sess.target_filesearch(kind),
target: &self.sess.target.target,
triple: &self.sess.opts.target_triple[],
triple: &self.sess.opts.target_triple,
root: root,
rejected_via_hash: vec!(),
rejected_via_triple: vec!(),
Expand All @@ -440,8 +440,8 @@ impl<'a> CrateReader<'a> {
decoder::get_crate_deps(cdata).iter().map(|dep| {
debug!("resolving dep crate {} hash: `{}`", dep.name, dep.hash);
let (local_cnum, _, _) = self.resolve_crate(root,
&dep.name[],
&dep.name[],
&dep.name,
&dep.name,
Some(&dep.hash),
span,
PathKind::Dependency);
Expand All @@ -450,7 +450,7 @@ impl<'a> CrateReader<'a> {
}

fn read_extension_crate(&mut self, span: Span, info: &CrateInfo) -> ExtensionCrate {
let target_triple = &self.sess.opts.target_triple[];
let target_triple = &self.sess.opts.target_triple[..];
let is_cross = target_triple != config::host_triple();
let mut should_link = info.should_link && !is_cross;
let mut target_only = false;
Expand Down Expand Up @@ -493,8 +493,8 @@ impl<'a> CrateReader<'a> {
PathKind::Crate).is_none();
let metadata = if register {
// Register crate now to avoid double-reading metadata
let (_, cmd, _) = self.register_crate(&None, &info.ident[],
&info.name[], span, library);
let (_, cmd, _) = self.register_crate(&None, &info.ident,
&info.name, span, library);
PMDSource::Registered(cmd)
} else {
// Not registering the crate; just hold on to the metadata
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/metadata/csearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,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[]))];
let mut r = vec![ast_map::PathMod(token::intern(&cdata.name))];
r.push_all(&path);
r
}
Expand Down Expand Up @@ -391,7 +391,7 @@ pub fn is_staged_api(cstore: &cstore::CStore, def: ast::DefId) -> bool {
let cdata = cstore.get_crate_data(def.krate);
let attrs = decoder::get_crate_attributes(cdata.data());
for attr in &attrs {
if &attr.name()[] == "staged_api" {
if &attr.name()[..] == "staged_api" {
match attr.node.value.node { ast::MetaWord(_) => return true, _ => (/*pass*/) }
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ pub fn get_crate_deps(data: &[u8]) -> Vec<CrateDep> {
}
reader::tagged_docs(depsdoc, tag_crate_dep, |depdoc| {
let name = docstr(depdoc, tag_crate_dep_crate_name);
let hash = Svh::new(&docstr(depdoc, tag_crate_dep_hash)[]);
let hash = Svh::new(&docstr(depdoc, tag_crate_dep_hash));
deps.push(CrateDep {
cnum: crate_num,
name: name,
Expand Down
Loading