mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-12 08:36:03 +00:00
commit
7214008f60
@ -18,7 +18,6 @@ use config::BlockIndentStyle;
|
||||
|
||||
use syntax::{ast, ptr};
|
||||
use syntax::codemap::{Pos, Span, BytePos, mk_sp};
|
||||
use syntax::parse::token;
|
||||
use syntax::print::pprust;
|
||||
use syntax::visit::Visitor;
|
||||
|
||||
@ -539,7 +538,7 @@ fn rewrite_field(context: &RewriteContext,
|
||||
width: usize,
|
||||
offset: usize)
|
||||
-> Option<String> {
|
||||
let name = &token::get_ident(field.ident.node);
|
||||
let name = &field.ident.node.to_string();
|
||||
let overhead = name.len() + 2;
|
||||
let expr = field.expr.rewrite(context, width - overhead, offset + overhead);
|
||||
expr.map(|s| format!("{}: {}", name, s))
|
||||
|
@ -14,7 +14,6 @@ use rewrite::{Rewrite, RewriteContext};
|
||||
use config::Config;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::parse::token;
|
||||
use syntax::print::pprust;
|
||||
use syntax::codemap::{CodeMap, Span};
|
||||
|
||||
@ -52,11 +51,10 @@ impl Rewrite for ast::ViewPath {
|
||||
|
||||
fn rewrite_single_use_list(path_str: String, vpi: ast::PathListItem) -> String {
|
||||
if let ast::PathListItem_::PathListIdent{ name, .. } = vpi.node {
|
||||
let name_str = token::get_ident(name).to_string();
|
||||
if path_str.len() == 0 {
|
||||
name_str
|
||||
name.to_string()
|
||||
} else {
|
||||
format!("{}::{}", path_str, name_str)
|
||||
format!("{}::{}", path_str, name)
|
||||
}
|
||||
} else {
|
||||
if path_str.len() != 0 {
|
||||
@ -121,7 +119,7 @@ pub fn rewrite_use_list(width: usize,
|
||||
|vpi| vpi.span.hi,
|
||||
|vpi| match vpi.node {
|
||||
ast::PathListItem_::PathListIdent{ name, .. } => {
|
||||
token::get_ident(name).to_string()
|
||||
name.to_string()
|
||||
}
|
||||
ast::PathListItem_::PathListMod{ .. } => {
|
||||
"self".to_owned()
|
||||
|
@ -124,7 +124,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
|
||||
// fn foo
|
||||
result.push_str("fn ");
|
||||
result.push_str(&token::get_ident(ident));
|
||||
result.push_str(&ident.to_string());
|
||||
|
||||
// Generics.
|
||||
let generics_indent = indent + result.len();
|
||||
@ -626,7 +626,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
}
|
||||
|
||||
fn format_header(&self, item_name: &str, ident: ast::Ident, vis: ast::Visibility) -> String {
|
||||
format!("{}{}{}", format_visibility(vis), item_name, &token::get_ident(ident))
|
||||
format!("{}{}{}", format_visibility(vis), item_name, ident)
|
||||
}
|
||||
|
||||
fn format_generics(&self,
|
||||
@ -658,7 +658,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
}
|
||||
|
||||
let name = match field.node.kind {
|
||||
ast::StructFieldKind::NamedField(ident, _) => Some(token::get_ident(ident)),
|
||||
ast::StructFieldKind::NamedField(ident, _) => Some(ident.to_string()),
|
||||
ast::StructFieldKind::UnnamedField(_) => None,
|
||||
};
|
||||
let vis = match field.node.kind {
|
||||
|
@ -11,7 +11,6 @@
|
||||
use visitor::FmtVisitor;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::parse::token;
|
||||
use syntax::print::pprust;
|
||||
|
||||
impl<'a> FmtVisitor<'a> {
|
||||
@ -79,7 +78,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
|
||||
pub fn rewrite_ty_param(&self, ty_param: &ast::TyParam) -> String {
|
||||
let mut result = String::with_capacity(128);
|
||||
result.push_str(&token::get_ident(ty_param.ident));
|
||||
result.push_str(&ty_param.ident.to_string());
|
||||
if ty_param.bounds.len() > 0 {
|
||||
result.push_str(": ");
|
||||
result.push_str(&ty_param.bounds.iter().map(|b| self.rewrite_ty_bound(b))
|
||||
|
@ -11,7 +11,7 @@
|
||||
use syntax::ast;
|
||||
use syntax::codemap::{self, CodeMap, Span, BytePos};
|
||||
use syntax::visit;
|
||||
use syntax::parse::{token, parser};
|
||||
use syntax::parse::parser;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use utils;
|
||||
@ -365,7 +365,7 @@ impl<'a> FmtVisitor<'a> {
|
||||
|
||||
match parser::Parser::default_submod_path(id, &dir_path, &self.codemap).result {
|
||||
Ok(parser::ModulePathSuccess { path, .. }) => path,
|
||||
_ => panic!("Couldn't find module {}", token::get_ident(id))
|
||||
_ => panic!("Couldn't find module {}", id)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user