diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2015-02-20 14:08:14 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2015-02-20 14:08:14 -0500 |
| commit | 68e5bb3f2caa34753edb7f921c0bcf1efd63cf88 (patch) | |
| tree | d895a5d4acf70d2c9ed4104bdaf1631b2daa351f /src/libsyntax/parse | |
| parent | 42e155e13bf16b19251903ae51b2571925345771 (diff) | |
| download | rust-68e5bb3f2caa34753edb7f921c0bcf1efd63cf88.tar.gz rust-68e5bb3f2caa34753edb7f921c0bcf1efd63cf88.zip | |
Remove remaining uses of `[]`. This time I tried to use deref coercions where possible.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/attr.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/parse/obsolete.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/token.rs | 16 |
6 files changed, 20 insertions, 20 deletions
diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index 06e8728d236..a0e2b4dbf5a 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -94,7 +94,7 @@ impl<'a> ParserAttr for Parser<'a> { } _ => { let token_str = self.this_token_to_string(); - self.fatal(&format!("expected `#`, found `{}`", token_str)[]); + self.fatal(&format!("expected `#`, found `{}`", token_str)); } }; diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index fd08cbd161b..83d2bb0cc70 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1109,7 +1109,7 @@ impl<'a> StringReader<'a> { // expansion purposes. See #12512 for the gory details of why // this is necessary. let ident = self.with_str_from(start, |lifetime_name| { - str_to_ident(&format!("'{}", lifetime_name)[]) + str_to_ident(&format!("'{}", lifetime_name)) }); // Conjure up a "keyword checking ident" to make sure that diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 7ed48bdbb92..f826e43528b 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -254,7 +254,7 @@ pub fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>) Ok(bytes) => bytes, Err(e) => { err(&format!("couldn't read {:?}: {}", - path.display(), e)[]); + path.display(), e)); unreachable!() } }; @@ -264,7 +264,7 @@ pub fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>) path.as_str().unwrap().to_string()) } None => { - err(&format!("{:?} is not UTF-8 encoded", path.display())[]) + err(&format!("{:?} is not UTF-8 encoded", path.display())) } } unreachable!() @@ -827,19 +827,19 @@ mod test { ast::TtDelimited(_, ref macro_delimed)] if name_macro_rules.as_str() == "macro_rules" && name_zip.as_str() == "zip" => { - match ¯o_delimed.tts[] { + match ¯o_delimed.tts { [ast::TtDelimited(_, ref first_delimed), ast::TtToken(_, token::FatArrow), ast::TtDelimited(_, ref second_delimed)] if macro_delimed.delim == token::Paren => { - match &first_delimed.tts[] { + match &first_delimed.tts { [ast::TtToken(_, token::Dollar), ast::TtToken(_, token::Ident(name, token::Plain))] if first_delimed.delim == token::Paren && name.as_str() == "a" => {}, _ => panic!("value 3: {:?}", **first_delimed), } - match &second_delimed.tts[] { + match &second_delimed.tts { [ast::TtToken(_, token::Dollar), ast::TtToken(_, token::Ident(name, token::Plain))] if second_delimed.delim == token::Paren @@ -1207,7 +1207,7 @@ mod test { let source = "/// doc comment\r\n/// line 2\r\nfn foo() {}".to_string(); let item = parse_item_from_source_str(name.clone(), source, Vec::new(), &sess).unwrap(); - let docs = item.attrs.iter().filter(|a| &a.name()[] == "doc") + let docs = item.attrs.iter().filter(|a| &a.name() == "doc") .map(|a| a.value_str().unwrap().to_string()).collect::<Vec<_>>(); let b: &[_] = &["/// doc comment".to_string(), "/// line 2".to_string()]; assert_eq!(&docs[..], b); diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 8480772ce6c..e6bcb8ac745 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -106,16 +106,16 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> { desc: &str, error: bool) { if error { - self.span_err(sp, &format!("obsolete syntax: {}", kind_str)[]); + self.span_err(sp, &format!("obsolete syntax: {}", kind_str)); } else { - self.span_warn(sp, &format!("obsolete syntax: {}", kind_str)[]); + self.span_warn(sp, &format!("obsolete syntax: {}", kind_str)); } if !self.obsolete_set.contains(&kind) { self.sess .span_diagnostic .handler() - .note(&format!("{}", desc)[]); + .note(&format!("{}", desc)); self.obsolete_set.insert(kind); } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 1805543d787..88c34937159 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5191,7 +5191,7 @@ impl<'a> Parser<'a> { -> (ast::Item_, Vec<ast::Attribute> ) { let mut prefix = Path::new(self.sess.span_diagnostic.cm.span_to_filename(self.span)); prefix.pop(); - let mod_path = Path::new(".").join_many(&self.mod_path_stack[]); + let mod_path = Path::new(".").join_many(&self.mod_path_stack); let dir_path = prefix.join(&mod_path); let mod_string = token::get_ident(id); let (file_path, owns_directory) = match ::attr::first_attr_value_str_by_name( diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 433c013591c..2797ef084d9 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -652,47 +652,47 @@ impl BytesContainer for InternedString { impl fmt::Debug for InternedString { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Debug::fmt(&self.string[], f) + fmt::Debug::fmt(&self.string, f) } } impl fmt::Display for InternedString { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Display::fmt(&self.string[], f) + fmt::Display::fmt(&self.string, f) } } impl<'a> PartialEq<&'a str> for InternedString { #[inline(always)] fn eq(&self, other: & &'a str) -> bool { - PartialEq::eq(&self.string[], *other) + PartialEq::eq(&self.string[..], *other) } #[inline(always)] fn ne(&self, other: & &'a str) -> bool { - PartialEq::ne(&self.string[], *other) + PartialEq::ne(&self.string[..], *other) } } impl<'a> PartialEq<InternedString > for &'a str { #[inline(always)] fn eq(&self, other: &InternedString) -> bool { - PartialEq::eq(*self, &other.string[]) + PartialEq::eq(*self, &other.string[..]) } #[inline(always)] fn ne(&self, other: &InternedString) -> bool { - PartialEq::ne(*self, &other.string[]) + PartialEq::ne(*self, &other.string[..]) } } impl Decodable for InternedString { fn decode<D: Decoder>(d: &mut D) -> Result<InternedString, D::Error> { - Ok(get_name(get_ident_interner().intern(&try!(d.read_str())[]))) + Ok(get_name(get_ident_interner().intern(&try!(d.read_str())[..]))) } } impl Encodable for InternedString { fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_str(&self.string[]) + s.emit_str(&self.string) } } |
