Skip to content

Commit 7b973ba

Browse files
Update to last version, remove "[]" as much as possible
1 parent 93fe5c8 commit 7b973ba

36 files changed

+114
-115
lines changed

src/librustc/lint/builtin.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -801,10 +801,10 @@ impl LintPass for UnusedResults {
801801
None => {}
802802
Some(s) => {
803803
msg.push_str(": ");
804-
msg.push_str(&s[]);
804+
msg.push_str(&s);
805805
}
806806
}
807-
cx.span_lint(UNUSED_MUST_USE, sp, &msg[]);
807+
cx.span_lint(UNUSED_MUST_USE, sp, &msg);
808808
return true;
809809
}
810810
}
@@ -844,7 +844,7 @@ impl NonCamelCaseTypes {
844844
let s = token::get_ident(ident);
845845

846846
if !is_camel_case(ident) {
847-
let c = to_camel_case(&s[]);
847+
let c = to_camel_case(&s);
848848
let m = if c.is_empty() {
849849
format!("{} `{}` should have a camel case name such as `CamelCase`", sort, s)
850850
} else {
@@ -996,7 +996,7 @@ impl NonSnakeCase {
996996
let s = token::get_ident(ident);
997997

998998
if !is_snake_case(ident) {
999-
let sc = NonSnakeCase::to_snake_case(&s[]);
999+
let sc = NonSnakeCase::to_snake_case(&s);
10001000
if sc != &s[] {
10011001
cx.span_lint(NON_SNAKE_CASE, span,
10021002
&*format!("{} `{}` should have a snake case name such as `{}`",
@@ -1078,7 +1078,7 @@ impl NonUpperCaseGlobals {
10781078
let s = token::get_ident(ident);
10791079

10801080
if s.chars().any(|c| c.is_lowercase()) {
1081-
let uc: String = NonSnakeCase::to_snake_case(&s[]).chars()
1081+
let uc: String = NonSnakeCase::to_snake_case(&s).chars()
10821082
.map(|c| c.to_uppercase()).collect();
10831083
if uc != &s[] {
10841084
cx.span_lint(NON_UPPER_CASE_GLOBALS, span,
@@ -1241,7 +1241,7 @@ impl LintPass for UnusedImportBraces {
12411241
match items[0].node {
12421242
ast::PathListIdent {ref name, ..} => {
12431243
let m = format!("braces around {} is unnecessary",
1244-
&token::get_ident(*name)[]);
1244+
&token::get_ident(*name));
12451245
cx.span_lint(UNUSED_IMPORT_BRACES, item.span,
12461246
&m[]);
12471247
},

src/librustc/lint/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ pub fn gather_attrs(attrs: &[ast::Attribute])
341341
-> Vec<Result<(InternedString, Level, Span), Span>> {
342342
let mut out = vec!();
343343
for attr in attrs {
344-
let level = match Level::from_str(&attr.name()[]) {
344+
let level = match Level::from_str(&attr.name()) {
345345
None => continue,
346346
Some(lvl) => lvl,
347347
};
@@ -499,7 +499,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
499499
continue;
500500
}
501501
Ok((lint_name, level, span)) => {
502-
match self.lints.find_lint(&lint_name[], &self.tcx.sess, Some(span)) {
502+
match self.lints.find_lint(&lint_name, &self.tcx.sess, Some(span)) {
503503
Some(lint_id) => vec![(lint_id, level, span)],
504504
None => {
505505
match self.lints.lint_groups.get(&lint_name[]) {

src/librustc/metadata/creader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl<'a> CrateReader<'a> {
170170
fn process_crate(&self, c: &ast::Crate) {
171171
for a in c.attrs.iter().filter(|m| m.name() == "link_args") {
172172
match a.value_str() {
173-
Some(ref linkarg) => self.sess.cstore.add_used_link_args(&linkarg[]),
173+
Some(ref linkarg) => self.sess.cstore.add_used_link_args(&linkarg),
174174
None => { /* fallthrough */ }
175175
}
176176
}
@@ -237,7 +237,7 @@ impl<'a> CrateReader<'a> {
237237
.collect::<Vec<&ast::Attribute>>();
238238
for m in &link_args {
239239
match m.value_str() {
240-
Some(linkarg) => self.sess.cstore.add_used_link_args(&linkarg[]),
240+
Some(linkarg) => self.sess.cstore.add_used_link_args(&linkarg),
241241
None => { /* fallthrough */ }
242242
}
243243
}

src/librustc/metadata/encoder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub struct EncodeContext<'a, 'tcx: 'a> {
8686
}
8787

8888
fn encode_name(rbml_w: &mut Encoder, name: ast::Name) {
89-
rbml_w.wr_tagged_str(tag_paths_data_name, &token::get_name(name)[]);
89+
rbml_w.wr_tagged_str(tag_paths_data_name, &token::get_name(name));
9090
}
9191

9292
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) {
372372
ast_map::PathMod(_) => tag_path_elem_mod,
373373
ast_map::PathName(_) => tag_path_elem_name
374374
};
375-
rbml_w.wr_tagged_str(tag, &token::get_name(pe.name())[]);
375+
rbml_w.wr_tagged_str(tag, &token::get_name(pe.name()));
376376
}
377377
rbml_w.end_tag();
378378
}
@@ -1695,7 +1695,7 @@ fn encode_paren_sugar(rbml_w: &mut Encoder, paren_sugar: bool) {
16951695
fn encode_associated_type_names(rbml_w: &mut Encoder, names: &[ast::Name]) {
16961696
rbml_w.start_tag(tag_associated_type_names);
16971697
for &name in names {
1698-
rbml_w.wr_tagged_str(tag_associated_type_name, &token::get_name(name)[]);
1698+
rbml_w.wr_tagged_str(tag_associated_type_name, &token::get_name(name));
16991699
}
17001700
rbml_w.end_tag();
17011701
}

src/librustc/middle/check_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,11 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
249249
span_warn!(cx.tcx.sess, p.span, E0170,
250250
"pattern binding `{}` is named the same as one \
251251
of the variants of the type `{}`",
252-
&token::get_ident(ident.node)[], ty_to_string(cx.tcx, pat_ty));
252+
&token::get_ident(ident.node), ty_to_string(cx.tcx, pat_ty));
253253
span_help!(cx.tcx.sess, p.span,
254254
"if you meant to match on a variant, \
255255
consider making the path in the pattern qualified: `{}::{}`",
256-
ty_to_string(cx.tcx, pat_ty), &token::get_ident(ident.node)[]);
256+
ty_to_string(cx.tcx, pat_ty), &token::get_ident(ident.node));
257257
}
258258
}
259259
}

src/librustc/middle/infer/error_reporting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1439,7 +1439,7 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
14391439
}
14401440
infer::BoundRegionInCoherence(name) => {
14411441
format!(" for lifetime parameter `{}` in coherence check",
1442-
&token::get_name(name)[])
1442+
&token::get_name(name))
14431443
}
14441444
infer::UpvarRegion(ref upvar_id, _) => {
14451445
format!(" for capture of `{}` by closure",

src/librustc/middle/stability.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,12 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
239239
if !self.active_features.contains(feature) {
240240
let msg = match *reason {
241241
Some(ref r) => format!("use of unstable library feature '{}': {}",
242-
&feature[], &r[]),
243-
None => format!("use of unstable library feature '{}'", &feature[])
242+
&feature, &r),
243+
None => format!("use of unstable library feature '{}'", &feature)
244244
};
245245

246246
emit_feature_warn(&self.tcx.sess.parse_sess.span_diagnostic,
247-
&feature[], span, &msg[]);
247+
&feature, span, &msg);
248248
}
249249
}
250250
Some(..) => {

src/librustc/middle/traits/error_reporting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
8686
}).collect::<HashMap<String, String>>();
8787
generic_map.insert("Self".to_string(),
8888
trait_ref.self_ty().user_string(infcx.tcx));
89-
let parser = Parser::new(&istring[]);
89+
let parser = Parser::new(&istring);
9090
let mut errored = false;
9191
let err: String = parser.filter_map(|p| {
9292
match p {

src/librustc/middle/weak_lang_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
110110
fn visit_foreign_item(&mut self, i: &ast::ForeignItem) {
111111
match lang_items::extract(&i.attrs) {
112112
None => {}
113-
Some(lang_item) => self.register(&lang_item[], i.span),
113+
Some(lang_item) => self.register(&lang_item, i.span),
114114
}
115115
visit::walk_foreign_item(self, i)
116116
}

src/librustc/util/ppaux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
277277
match ident {
278278
Some(i) => {
279279
s.push(' ');
280-
s.push_str(&token::get_ident(i)[]);
280+
s.push_str(&token::get_ident(i));
281281
}
282282
_ => { }
283283
}

src/librustc_borrowck/borrowck/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
907907
match loan_path.kind {
908908
LpUpvar(ty::UpvarId{ var_id: id, closure_expr_id: _ }) |
909909
LpVar(id) => {
910-
out.push_str(&ty::local_var_name_str(self.tcx, id)[]);
910+
out.push_str(&ty::local_var_name_str(self.tcx, id));
911911
}
912912

913913
LpDowncast(ref lp_base, variant_def_id) => {
@@ -924,7 +924,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
924924
match fname {
925925
mc::NamedField(fname) => {
926926
out.push('.');
927-
out.push_str(&token::get_name(fname)[]);
927+
out.push_str(&token::get_name(fname));
928928
}
929929
mc::PositionalField(idx) => {
930930
out.push('.');

src/librustc_resolve/build_reduced_graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
10201020
self.handle_external_def(def,
10211021
def_visibility,
10221022
&*child_name_bindings,
1023-
&token::get_name(name)[],
1023+
&token::get_name(name),
10241024
name,
10251025
root);
10261026
}

src/librustc_resolve/lib.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
10931093
} else {
10941094
result.push_str("::")
10951095
}
1096-
result.push_str(&token::get_name(*name)[]);
1096+
result.push_str(&token::get_name(*name));
10971097
};
10981098
result
10991099
}
@@ -1708,7 +1708,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
17081708

17091709
debug!("(resolving glob import) writing resolution `{}` in `{}` \
17101710
to `{}`",
1711-
&token::get_name(name)[],
1711+
&token::get_name(name),
17121712
self.module_to_string(&*containing_module),
17131713
self.module_to_string(module_));
17141714

@@ -1725,7 +1725,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
17251725
let msg = format!("a {} named `{}` has already been imported \
17261726
in this module",
17271727
namespace_name,
1728-
&token::get_name(name)[]);
1728+
&token::get_name(name));
17291729
span_err!(self.session, import_directive.span, E0251, "{}", msg);
17301730
} else {
17311731
let target = Target::new(containing_module.clone(),
@@ -1757,7 +1757,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
17571757
name: Name,
17581758
namespace: Namespace) {
17591759
debug!("check_for_conflicting_import: {}; target exists: {}",
1760-
&token::get_name(name)[],
1760+
&token::get_name(name),
17611761
target.is_some());
17621762

17631763
match *target {
@@ -1768,7 +1768,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
17681768
TypeNS => "type",
17691769
ValueNS => "value",
17701770
},
1771-
&token::get_name(name)[]);
1771+
&token::get_name(name));
17721772
span_err!(self.session, import_span, E0252, "{}", &msg[]);
17731773
}
17741774
Some(_) | None => {}
@@ -1804,7 +1804,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
18041804
let msg = format!("import `{0}` conflicts with imported \
18051805
crate in this module \
18061806
(maybe you meant `use {0}::*`?)",
1807-
&token::get_name(name)[]);
1807+
&token::get_name(name));
18081808
span_err!(self.session, import_span, E0254, "{}", &msg[]);
18091809
}
18101810
Some(_) | None => {}
@@ -1826,7 +1826,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
18261826
if let Some(ref value) = *name_bindings.value_def.borrow() {
18271827
let msg = format!("import `{}` conflicts with value \
18281828
in this module",
1829-
&token::get_name(name)[]);
1829+
&token::get_name(name));
18301830
span_err!(self.session, import_span, E0255, "{}", &msg[]);
18311831
if let Some(span) = value.value_span {
18321832
self.session.span_note(span,
@@ -1844,7 +1844,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
18441844
None => {
18451845
let msg = format!("import `{}` conflicts with type in \
18461846
this module",
1847-
&token::get_name(name)[]);
1847+
&token::get_name(name));
18481848
span_err!(self.session, import_span, E0256, "{}", &msg[]);
18491849
if let Some(span) = ty.type_span {
18501850
self.session.span_note(span,
@@ -1866,7 +1866,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
18661866
_ => {
18671867
let msg = format!("import `{}` conflicts with existing \
18681868
submodule",
1869-
&token::get_name(name)[]);
1869+
&token::get_name(name));
18701870
span_err!(self.session, import_span, E0258, "{}", &msg[]);
18711871
if let Some(span) = ty.type_span {
18721872
self.session.span_note(span,
@@ -1892,7 +1892,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
18921892
span_err!(self.session, span, E0259,
18931893
"an external crate named `{}` has already \
18941894
been imported into this module",
1895-
&token::get_name(name)[]);
1895+
&token::get_name(name));
18961896
}
18971897
}
18981898

@@ -1906,7 +1906,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
19061906
"the name `{}` conflicts with an external \
19071907
crate that has been imported into this \
19081908
module",
1909-
&token::get_name(name)[]);
1909+
&token::get_name(name));
19101910
}
19111911
}
19121912

@@ -2417,7 +2417,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
24172417
allow_private_imports: bool)
24182418
-> ResolveResult<(Target, bool)> {
24192419
debug!("(resolving name in module) resolving `{}` in `{}`",
2420-
&token::get_name(name)[],
2420+
&token::get_name(name),
24212421
self.module_to_string(&*module_));
24222422

24232423
// First, check the direct children of the module.
@@ -2493,7 +2493,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
24932493

24942494
// We're out of luck.
24952495
debug!("(resolving name in module) failed to resolve `{}`",
2496-
&token::get_name(name)[]);
2496+
&token::get_name(name));
24972497
return Failed(None);
24982498
}
24992499

@@ -4372,7 +4372,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
43724372

43734373
let mut smallest = 0;
43744374
for (i, other) in maybes.iter().enumerate() {
4375-
values[i] = lev_distance(name, &other[]);
4375+
values[i] = lev_distance(name, &other);
43764376

43774377
if values[i] <= values[smallest] {
43784378
smallest = i;

src/librustc_trans/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ pub fn mangle<PI: Iterator<Item=PathElem>>(path: PI,
293293

294294
// First, connect each component with <len, name> pairs.
295295
for e in path {
296-
push(&mut n, &token::get_name(e.name())[])
296+
push(&mut n, &token::get_name(e.name()))
297297
}
298298

299299
match hash {

0 commit comments

Comments
 (0)