Skip to content

Commit 7b973ba

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

File tree

36 files changed

+114
-115
lines changed

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
}

0 commit comments

Comments
 (0)