_ => {
let token_str = self.this_token_to_string();
self.fatal(&format!("expected `Self`, found `{}`",
- token_str)[])
+ token_str))
}
}
}
_ => {
let token_str = self.this_token_to_string();
self.fatal(&format!("expected `,` or `)`, found `{}`",
- token_str)[])
+ token_str))
}
}
}
if fields.len() == 0 {
self.fatal(&format!("unit-like struct definition should be \
written as `struct {};`",
- token::get_ident(class_name.clone()))[]);
+ token::get_ident(class_name.clone())));
}
self.bump();
let token_str = self.this_token_to_string();
self.fatal(&format!("expected `where`, or `{}` after struct \
name, found `{}`", "{",
- token_str)[]);
+ token_str));
}
fields
if fields.len() == 0 {
self.fatal(&format!("unit-like struct definition should be \
written as `struct {};`",
- token::get_ident(class_name.clone()))[]);
+ token::get_ident(class_name.clone())));
}
self.parse_where_clause(generics);
} else {
let token_str = self.this_token_to_string();
self.fatal(&format!("expected `where`, `{}`, `(`, or `;` after struct \
- name, found `{}`", "{", token_str)[]);
+ name, found `{}`", "{", token_str));
}
}
let token_str = self.this_token_to_string();
self.span_fatal_help(span,
&format!("expected `,`, or `}}`, found `{}`",
- token_str)[],
+ token_str),
"struct fields should be separated by commas")
}
}
// Parse all of the items up to closing or an attribute.
let mut attrs = first_item_attrs;
- attrs.push_all(&self.parse_outer_attributes()[]);
+ attrs.push_all(&self.parse_outer_attributes());
let mut items = vec![];
loop {
while self.token != term {
let mut attrs = mem::replace(&mut attrs, vec![]);
- attrs.push_all(&self.parse_outer_attributes()[]);
+ attrs.push_all(&self.parse_outer_attributes());
debug!("parse_mod_items: parse_item_(attrs={:?})", attrs);
match self.parse_item_(attrs, true /* macros allowed */) {
Ok(item) => items.push(item),
Err(_) => {
let token_str = self.this_token_to_string();
self.fatal(&format!("expected item, found `{}`",
- token_str)[])
+ token_str))
}
}
}
&format!("maybe move this module `{0}` \
to its own directory via \
`{0}/mod.rs`",
- this_module)[]);
+ this_module));
if default_exists || secondary_exists {
self.span_note(id_sp,
&format!("... or maybe `use` the module \
`{}` instead of possibly \
redeclaring it",
- mod_name)[]);
+ mod_name));
}
self.abort_if_errors();
}
(false, false) => {
self.span_fatal_help(id_sp,
&format!("file not found for module `{}`",
- mod_name)[],
+ mod_name),
&format!("name the file either {} or {} inside \
the directory {:?}",
default_path_str,
secondary_path_str,
- dir_path.display())[]);
+ dir_path.display()));
}
(true, true) => {
self.span_fatal_help(
and {}",
mod_name,
default_path_str,
- secondary_path_str)[],
+ secondary_path_str),
"delete or rename one of them to remove the ambiguity");
}
}
let mut err = String::from_str("circular modules: ");
let len = included_mod_stack.len();
for p in &included_mod_stack[i.. len] {
- err.push_str(&p.display().as_cow()[]);
+ err.push_str(&p.display().as_cow());
err.push_str(" -> ");
}
- err.push_str(&path.display().as_cow()[]);
+ err.push_str(&path.display().as_cow());
self.span_fatal(id_sp, &err[..]);
}
None => ()
self.span_help(span,
&format!("perhaps you meant to enclose the crate name `{}` in \
a string?",
- the_ident.as_str())[]);
+ the_ident.as_str()));
None
} else {
None
self.span_fatal(span,
&format!("expected extern crate name but \
found `{}`",
- token_str)[]);
+ token_str));
}
};
self.span_err(start_span,
&format!("unit-like struct variant should be written \
without braces, as `{},`",
- token::get_ident(ident))[]);
+ token::get_ident(ident)));
}
kind = StructVariantKind(struct_def);
} else if self.check(&token::OpenDelim(token::Paren)) {
&format!("illegal ABI: expected one of [{}], \
found `{}`",
abi::all_names().connect(", "),
- the_string)[]);
+ the_string));
None
}
}
let token_str = self.this_token_to_string();
self.span_fatal(span,
&format!("expected `{}` or `fn`, found `{}`", "{",
- token_str)[]);
+ token_str));
}
if self.eat_keyword_noexpect(keywords::Virtual) {
fn parse_foreign_items(&mut self, first_item_attrs: Vec<Attribute>)
-> Vec<P<ForeignItem>> {
let mut attrs = first_item_attrs;
- attrs.push_all(&self.parse_outer_attributes()[]);
+ attrs.push_all(&self.parse_outer_attributes());
let mut foreign_items = Vec::new();
loop {
match self.parse_foreign_item(attrs) {
try!(s.print_attribute(&fake_attr));
}
- try!(s.print_mod(&krate.module, &krate.attrs[]));
+ try!(s.print_mod(&krate.module, &krate.attrs));
try!(s.print_remaining_comments());
eof(&mut s.s)
}
item: &ast::ForeignItem) -> IoResult<()> {
try!(self.hardbreak_if_not_bol());
try!(self.maybe_print_comment(item.span.lo));
- try!(self.print_outer_attributes(&item.attrs[]));
+ try!(self.print_outer_attributes(&item.attrs));
match item.node {
ast::ForeignItemFn(ref decl, ref generics) => {
try!(self.print_fn(&**decl, None, abi::Rust, item.ident, generics,
}
ast::ForeignItemStatic(ref t, m) => {
try!(self.head(&visibility_qualified(item.vis,
- "static")[]));
+ "static")));
if m {
try!(self.word_space("mut"));
}
fn print_associated_type(&mut self, typedef: &ast::AssociatedType)
-> IoResult<()>
{
- try!(self.print_outer_attributes(&typedef.attrs[]));
+ try!(self.print_outer_attributes(&typedef.attrs));
try!(self.word_space("type"));
try!(self.print_ty_param(&typedef.ty_param));
word(&mut self.s, ";")
pub fn print_item(&mut self, item: &ast::Item) -> IoResult<()> {
try!(self.hardbreak_if_not_bol());
try!(self.maybe_print_comment(item.span.lo));
- try!(self.print_outer_attributes(&item.attrs[]));
+ try!(self.print_outer_attributes(&item.attrs));
try!(self.ann.pre(self, NodeItem(item)));
match item.node {
ast::ItemExternCrate(ref optional_path) => {
try!(self.head(&visibility_qualified(item.vis,
- "extern crate")[]));
+ "extern crate")));
if let Some((ref p, style)) = *optional_path {
try!(self.print_string(p, style));
try!(space(&mut self.s));
}
ast::ItemUse(ref vp) => {
try!(self.head(&visibility_qualified(item.vis,
- "use")[]));
+ "use")));
try!(self.print_view_path(&**vp));
try!(word(&mut self.s, ";"));
try!(self.end()); // end inner head-block
}
ast::ItemStatic(ref ty, m, ref expr) => {
try!(self.head(&visibility_qualified(item.vis,
- "static")[]));
+ "static")));
if m == ast::MutMutable {
try!(self.word_space("mut"));
}
}
ast::ItemConst(ref ty, ref expr) => {
try!(self.head(&visibility_qualified(item.vis,
- "const")[]));
+ "const")));
try!(self.print_ident(item.ident));
try!(self.word_space(":"));
try!(self.print_type(&**ty));
item.vis
));
try!(word(&mut self.s, " "));
- try!(self.print_block_with_attrs(&**body, &item.attrs[]));
+ try!(self.print_block_with_attrs(&**body, &item.attrs));
}
ast::ItemMod(ref _mod) => {
try!(self.head(&visibility_qualified(item.vis,
- "mod")[]));
+ "mod")));
try!(self.print_ident(item.ident));
try!(self.nbsp());
try!(self.bopen());
- try!(self.print_mod(_mod, &item.attrs[]));
+ try!(self.print_mod(_mod, &item.attrs));
try!(self.bclose(item.span));
}
ast::ItemForeignMod(ref nmod) => {
try!(self.head("extern"));
- try!(self.word_nbsp(&nmod.abi.to_string()[]));
+ try!(self.word_nbsp(&nmod.abi.to_string()));
try!(self.bopen());
- try!(self.print_foreign_mod(nmod, &item.attrs[]));
+ try!(self.print_foreign_mod(nmod, &item.attrs));
try!(self.bclose(item.span));
}
ast::ItemTy(ref ty, ref params) => {
try!(self.ibox(indent_unit));
try!(self.ibox(0));
- try!(self.word_nbsp(&visibility_qualified(item.vis, "type")[]));
+ try!(self.word_nbsp(&visibility_qualified(item.vis, "type")));
try!(self.print_ident(item.ident));
try!(self.print_generics(params));
try!(self.end()); // end the inner ibox
));
}
ast::ItemStruct(ref struct_def, ref generics) => {
- try!(self.head(&visibility_qualified(item.vis,"struct")[]));
+ try!(self.head(&visibility_qualified(item.vis,"struct")));
try!(self.print_struct(&**struct_def, generics, item.ident, item.span));
}
try!(space(&mut self.s));
try!(self.bopen());
- try!(self.print_inner_attributes(&item.attrs[]));
+ try!(self.print_inner_attributes(&item.attrs));
for impl_item in impl_items {
match *impl_item {
ast::MethodImplItem(ref meth) => {
generics: &ast::Generics, ident: ast::Ident,
span: codemap::Span,
visibility: ast::Visibility) -> IoResult<()> {
- try!(self.head(&visibility_qualified(visibility, "enum")[]));
+ try!(self.head(&visibility_qualified(visibility, "enum")));
try!(self.print_ident(ident));
try!(self.print_generics(generics));
try!(self.print_where_clause(generics));
try!(space(&mut self.s));
- self.print_variants(&enum_definition.variants[], span)
+ self.print_variants(&enum_definition.variants, span)
}
pub fn print_variants(&mut self,
for v in variants {
try!(self.space_if_not_bol());
try!(self.maybe_print_comment(v.span.lo));
- try!(self.print_outer_attributes(&v.node.attrs[]));
+ try!(self.print_outer_attributes(&v.node.attrs));
try!(self.ibox(indent_unit));
try!(self.print_variant(&**v));
try!(word(&mut self.s, ","));
if !struct_def.fields.is_empty() {
try!(self.popen());
try!(self.commasep(
- Inconsistent, &struct_def.fields[],
+ Inconsistent, &struct_def.fields,
|s, field| {
match field.node.kind {
ast::NamedField(..) => panic!("unexpected named field"),
ast::NamedField(ident, visibility) => {
try!(self.hardbreak_if_not_bol());
try!(self.maybe_print_comment(field.span.lo));
- try!(self.print_outer_attributes(&field.node.attrs[]));
+ try!(self.print_outer_attributes(&field.node.attrs));
try!(self.print_visibility(visibility));
try!(self.print_ident(ident));
try!(self.word_nbsp(":"));
pub fn print_tt(&mut self, tt: &ast::TokenTree) -> IoResult<()> {
match *tt {
ast::TtToken(_, ref tk) => {
- try!(word(&mut self.s, &token_to_string(tk)[]));
+ try!(word(&mut self.s, &token_to_string(tk)));
match *tk {
parse::token::DocComment(..) => {
hardbreak(&mut self.s)
}
}
ast::TtDelimited(_, ref delimed) => {
- try!(word(&mut self.s, &token_to_string(&delimed.open_token())[]));
+ try!(word(&mut self.s, &token_to_string(&delimed.open_token())));
try!(space(&mut self.s));
- try!(self.print_tts(&delimed.tts[]));
+ try!(self.print_tts(&delimed.tts));
try!(space(&mut self.s));
- word(&mut self.s, &token_to_string(&delimed.close_token())[])
+ word(&mut self.s, &token_to_string(&delimed.close_token()))
},
ast::TtSequence(_, ref seq) => {
try!(word(&mut self.s, "$("));
try!(word(&mut self.s, ")"));
match seq.separator {
Some(ref tk) => {
- try!(word(&mut self.s, &token_to_string(tk)[]));
+ try!(word(&mut self.s, &token_to_string(tk)));
}
None => {},
}
pub fn print_ty_method(&mut self, m: &ast::TypeMethod) -> IoResult<()> {
try!(self.hardbreak_if_not_bol());
try!(self.maybe_print_comment(m.span.lo));
- try!(self.print_outer_attributes(&m.attrs[]));
+ try!(self.print_outer_attributes(&m.attrs));
try!(self.print_ty_fn(m.abi,
m.unsafety,
&*m.decl,
pub fn print_method(&mut self, meth: &ast::Method) -> IoResult<()> {
try!(self.hardbreak_if_not_bol());
try!(self.maybe_print_comment(meth.span.lo));
- try!(self.print_outer_attributes(&meth.attrs[]));
+ try!(self.print_outer_attributes(&meth.attrs));
match meth.node {
ast::MethDecl(ident,
ref generics,
Some(&explicit_self.node),
vis));
try!(word(&mut self.s, " "));
- self.print_block_with_attrs(&**body, &meth.attrs[])
+ self.print_block_with_attrs(&**body, &meth.attrs)
},
ast::MethMac(codemap::Spanned { node: ast::MacInvocTT(ref pth, ref tts, _),
..}) => {
try!(self.print_string(&a.asm, a.asm_str_style));
try!(self.word_space(":"));
- try!(self.commasep(Inconsistent, &a.outputs[],
+ try!(self.commasep(Inconsistent, &a.outputs,
|s, &(ref co, ref o, is_rw)| {
match co.slice_shift_char() {
Some(('=', operand)) if is_rw => {
- try!(s.print_string(&format!("+{}", operand)[],
+ try!(s.print_string(&format!("+{}", operand),
ast::CookedStr))
}
_ => try!(s.print_string(&co, ast::CookedStr))
try!(space(&mut self.s));
try!(self.word_space(":"));
- try!(self.commasep(Inconsistent, &a.inputs[],
+ try!(self.commasep(Inconsistent, &a.inputs,
|s, &(ref co, ref o)| {
try!(s.print_string(&co, ast::CookedStr));
try!(s.popen());
try!(space(&mut self.s));
try!(self.word_space(":"));
- try!(self.commasep(Inconsistent, &a.clobbers[],
+ try!(self.commasep(Inconsistent, &a.clobbers,
|s, co| {
try!(s.print_string(&co, ast::CookedStr));
Ok(())
}
pub fn print_usize(&mut self, i: usize) -> IoResult<()> {
- word(&mut self.s, &i.to_string()[])
+ word(&mut self.s, &i.to_string())
}
pub fn print_name(&mut self, name: ast::Name) -> IoResult<()> {
}
try!(self.commasep(
Inconsistent,
- &data.types[],
+ &data.types,
|s, ty| s.print_type(&**ty)));
comma = true;
}
try!(word(&mut self.s, "("));
try!(self.commasep(
Inconsistent,
- &data.inputs[],
+ &data.inputs,
|s, ty| s.print_type(&**ty)));
try!(word(&mut self.s, ")"));
}
try!(self.cbox(indent_unit));
try!(self.ibox(0));
- try!(self.print_outer_attributes(&arm.attrs[]));
+ try!(self.print_outer_attributes(&arm.attrs));
let mut first = true;
for p in &arm.pats {
if first {
pub fn print_ty_param(&mut self, param: &ast::TyParam) -> IoResult<()> {
try!(self.print_ident(param.ident));
- try!(self.print_bounds(":", ¶m.bounds[]));
+ try!(self.print_bounds(":", ¶m.bounds));
match param.default {
Some(ref default) => {
try!(space(&mut self.s));
try!(self.maybe_print_comment(lit.span.lo));
match self.next_lit(lit.span.lo) {
Some(ref ltrl) => {
- return word(&mut self.s, &(*ltrl).lit[]);
+ return word(&mut self.s, &(*ltrl).lit);
}
_ => ()
}
match t {
ast::SignedIntLit(st, ast::Plus) => {
word(&mut self.s,
- &ast_util::int_ty_to_string(st, Some(i as i64))[])
+ &ast_util::int_ty_to_string(st, Some(i as i64)))
}
ast::SignedIntLit(st, ast::Minus) => {
let istr = ast_util::int_ty_to_string(st, Some(-(i as i64)));
word(&mut self.s,
- &format!("-{}", istr)[])
+ &format!("-{}", istr))
}
ast::UnsignedIntLit(ut) => {
word(&mut self.s, &ast_util::uint_ty_to_string(ut, Some(i)))
}
ast::UnsuffixedIntLit(ast::Plus) => {
- word(&mut self.s, &format!("{}", i)[])
+ word(&mut self.s, &format!("{}", i))
}
ast::UnsuffixedIntLit(ast::Minus) => {
- word(&mut self.s, &format!("-{}", i)[])
+ word(&mut self.s, &format!("-{}", i))
}
}
}
&format!(
"{}{}",
&f,
- &ast_util::float_ty_to_string(t)[])[])
+ &ast_util::float_ty_to_string(t)))
}
ast::LitFloatUnsuffixed(ref f) => word(&mut self.s, &f[..]),
ast::LitBool(val) => {
escaped.extend(ascii::escape_default(ch as u8)
.map(|c| c as char));
}
- word(&mut self.s, &format!("b\"{}\"", escaped)[])
+ word(&mut self.s, &format!("b\"{}\"", escaped))
}
}
}
comments::Mixed => {
assert_eq!(cmnt.lines.len(), 1);
try!(zerobreak(&mut self.s));
- try!(word(&mut self.s, &cmnt.lines[0][]));
+ try!(word(&mut self.s, &cmnt.lines[0]));
zerobreak(&mut self.s)
}
comments::Isolated => {
comments::Trailing => {
try!(word(&mut self.s, " "));
if cmnt.lines.len() == 1 {
- try!(word(&mut self.s, &cmnt.lines[0][]));
+ try!(word(&mut self.s, &cmnt.lines[0]));
hardbreak(&mut self.s)
} else {
try!(self.ibox(0));
Some(abi::Rust) => Ok(()),
Some(abi) => {
try!(self.word_nbsp("extern"));
- self.word_nbsp(&abi.to_string()[])
+ self.word_nbsp(&abi.to_string())
}
None => Ok(())
}
match opt_abi {
Some(abi) => {
try!(self.word_nbsp("extern"));
- self.word_nbsp(&abi.to_string()[])
+ self.word_nbsp(&abi.to_string())
}
None => Ok(())
}
if abi != abi::Rust {
try!(self.word_nbsp("extern"));
- try!(self.word_nbsp(&abi.to_string()[]));
+ try!(self.word_nbsp(&abi.to_string()));
}
word(&mut self.s, "fn")