Convert x.as_str().to_string()
to x.to_string()
where possible.
This commit is contained in:
parent
9cf59b5178
commit
5bc7084f7e
10 changed files with 16 additions and 18 deletions
|
@ -525,7 +525,7 @@ impl<'tcx> DepNodeParams<'tcx> for CrateNum {
|
|||
}
|
||||
|
||||
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
|
||||
tcx.crate_name(*self).as_str().to_string()
|
||||
tcx.crate_name(*self).to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3382,7 +3382,7 @@ pub fn is_range_literal(sess: &Session, expr: &hir::Expr) -> bool {
|
|||
// either in std or core, i.e. has either a `::std::ops::Range` or
|
||||
// `::core::ops::Range` prefix.
|
||||
fn is_range_path(path: &Path) -> bool {
|
||||
let segs: Vec<_> = path.segments.iter().map(|seg| seg.ident.as_str().to_string()).collect();
|
||||
let segs: Vec<_> = path.segments.iter().map(|seg| seg.ident.to_string()).collect();
|
||||
let segs: Vec<_> = segs.iter().map(|seg| &**seg).collect();
|
||||
|
||||
// "{{root}}" is the equivalent of `::` prefix in `Path`.
|
||||
|
|
|
@ -564,7 +564,7 @@ impl<'a> State<'a> {
|
|||
}
|
||||
hir::ItemKind::GlobalAsm(ref ga) => {
|
||||
self.head(visibility_qualified(&item.vis, "global asm"));
|
||||
self.s.word(ga.asm.as_str().to_string());
|
||||
self.s.word(ga.asm.to_string());
|
||||
self.end()
|
||||
}
|
||||
hir::ItemKind::TyAlias(ref ty, ref generics) => {
|
||||
|
@ -1855,7 +1855,7 @@ impl<'a> State<'a> {
|
|||
self.commasep(Inconsistent, &decl.inputs, |s, ty| {
|
||||
s.ibox(INDENT_UNIT);
|
||||
if let Some(arg_name) = arg_names.get(i) {
|
||||
s.s.word(arg_name.as_str().to_string());
|
||||
s.s.word(arg_name.to_string());
|
||||
s.s.word(":");
|
||||
s.s.space();
|
||||
} else if let Some(body_id) = body_id {
|
||||
|
|
|
@ -180,7 +180,7 @@ impl<'tcx> OnUnimplementedDirective {
|
|||
c.ident().map_or(false, |ident| {
|
||||
options.contains(&(
|
||||
ident.name,
|
||||
c.value_str().map(|s| s.as_str().to_string())
|
||||
c.value_str().map(|s| s.to_string())
|
||||
))
|
||||
})
|
||||
}) {
|
||||
|
|
|
@ -264,7 +264,7 @@ impl<'sess> OnDiskCache<'sess> {
|
|||
let sorted_cnums = sorted_cnums_including_local_crate(tcx);
|
||||
let prev_cnums: Vec<_> = sorted_cnums.iter()
|
||||
.map(|&cnum| {
|
||||
let crate_name = tcx.original_crate_name(cnum).as_str().to_string();
|
||||
let crate_name = tcx.original_crate_name(cnum).to_string();
|
||||
let crate_disambiguator = tcx.crate_disambiguator(cnum);
|
||||
(cnum.as_u32(), crate_name, crate_disambiguator)
|
||||
})
|
||||
|
|
|
@ -552,8 +552,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
|||
} else if let Some(kind) = *tcx.sess.allocator_kind.get() {
|
||||
let llmod_id = cgu_name_builder.build_cgu_name(LOCAL_CRATE,
|
||||
&["crate"],
|
||||
Some("allocator")).as_str()
|
||||
.to_string();
|
||||
Some("allocator")).to_string();
|
||||
let mut modules = backend.new_metadata(tcx, &llmod_id);
|
||||
time(tcx.sess, "write allocator module", || {
|
||||
backend.codegen_allocator(tcx, &mut modules, kind)
|
||||
|
@ -576,8 +575,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
|||
// Codegen the encoded metadata.
|
||||
let metadata_cgu_name = cgu_name_builder.build_cgu_name(LOCAL_CRATE,
|
||||
&["crate"],
|
||||
Some("metadata")).as_str()
|
||||
.to_string();
|
||||
Some("metadata")).to_string();
|
||||
let mut metadata_llvm_module = backend.new_metadata(tcx, &metadata_cgu_name);
|
||||
time(tcx.sess, "write compressed metadata", || {
|
||||
backend.write_compressed_metadata(tcx, &ongoing_codegen.metadata,
|
||||
|
|
|
@ -94,8 +94,8 @@ impl AssertModuleSource<'tcx> {
|
|||
return;
|
||||
}
|
||||
|
||||
let user_path = self.field(attr, sym::module).as_str().to_string();
|
||||
let crate_name = self.tcx.crate_name(LOCAL_CRATE).as_str().to_string();
|
||||
let user_path = self.field(attr, sym::module).to_string();
|
||||
let crate_name = self.tcx.crate_name(LOCAL_CRATE).to_string();
|
||||
|
||||
if !user_path.starts_with(&crate_name) {
|
||||
let msg = format!("Found malformed codegen unit name `{}`. \
|
||||
|
@ -131,7 +131,7 @@ impl AssertModuleSource<'tcx> {
|
|||
cgu_name,
|
||||
self.available_cgus
|
||||
.iter()
|
||||
.map(|cgu| cgu.as_str().to_string())
|
||||
.map(|cgu| cgu.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")));
|
||||
}
|
||||
|
|
|
@ -1167,7 +1167,7 @@ fn external_path(cx: &DocContext<'_>, name: Symbol, trait_did: Option<DefId>, ha
|
|||
global: false,
|
||||
res: Res::Err,
|
||||
segments: vec![PathSegment {
|
||||
name: name.as_str().to_string(),
|
||||
name: name.to_string(),
|
||||
args: external_generic_args(cx, trait_did, has_self, bindings, substs)
|
||||
}],
|
||||
}
|
||||
|
|
|
@ -623,7 +623,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
|
|||
}
|
||||
self.maybe_print_comment(attr.span.lo());
|
||||
if attr.is_sugared_doc {
|
||||
self.word(attr.value_str().unwrap().as_str().to_string());
|
||||
self.word(attr.value_str().unwrap().to_string());
|
||||
self.hardbreak()
|
||||
} else {
|
||||
match attr.style {
|
||||
|
@ -1234,7 +1234,7 @@ impl<'a> State<'a> {
|
|||
}
|
||||
ast::ItemKind::GlobalAsm(ref ga) => {
|
||||
self.head(visibility_qualified(&item.vis, "global_asm!"));
|
||||
self.s.word(ga.asm.as_str().to_string());
|
||||
self.s.word(ga.asm.to_string());
|
||||
self.end();
|
||||
}
|
||||
ast::ItemKind::TyAlias(ref ty, ref generics) => {
|
||||
|
@ -2335,7 +2335,7 @@ impl<'a> State<'a> {
|
|||
}
|
||||
|
||||
crate fn print_name(&mut self, name: ast::Name) {
|
||||
self.s.word(name.as_str().to_string());
|
||||
self.s.word(name.to_string());
|
||||
self.ann.post(self, AnnNode::Name(&name))
|
||||
}
|
||||
|
||||
|
|
|
@ -225,7 +225,7 @@ fn generic_extension<'cx>(
|
|||
};
|
||||
let mut p = Parser::new(cx.parse_sess(), tts, Some(directory), true, false, None);
|
||||
p.root_module_name =
|
||||
cx.current_expansion.module.mod_path.last().map(|id| id.as_str().to_string());
|
||||
cx.current_expansion.module.mod_path.last().map(|id| id.to_string());
|
||||
p.last_type_ascription = cx.current_expansion.prior_type_ascription;
|
||||
|
||||
p.process_potential_macro_variable();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue