mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Convert x.as_str().to_string()
to x.to_string()
where possible.
This commit is contained in:
parent
9cf59b5178
commit
5bc7084f7e
@ -525,7 +525,7 @@ impl<'tcx> DepNodeParams<'tcx> for CrateNum {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
|
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
|
// either in std or core, i.e. has either a `::std::ops::Range` or
|
||||||
// `::core::ops::Range` prefix.
|
// `::core::ops::Range` prefix.
|
||||||
fn is_range_path(path: &Path) -> bool {
|
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();
|
let segs: Vec<_> = segs.iter().map(|seg| &**seg).collect();
|
||||||
|
|
||||||
// "{{root}}" is the equivalent of `::` prefix in `Path`.
|
// "{{root}}" is the equivalent of `::` prefix in `Path`.
|
||||||
|
@ -564,7 +564,7 @@ impl<'a> State<'a> {
|
|||||||
}
|
}
|
||||||
hir::ItemKind::GlobalAsm(ref ga) => {
|
hir::ItemKind::GlobalAsm(ref ga) => {
|
||||||
self.head(visibility_qualified(&item.vis, "global asm"));
|
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()
|
self.end()
|
||||||
}
|
}
|
||||||
hir::ItemKind::TyAlias(ref ty, ref generics) => {
|
hir::ItemKind::TyAlias(ref ty, ref generics) => {
|
||||||
@ -1855,7 +1855,7 @@ impl<'a> State<'a> {
|
|||||||
self.commasep(Inconsistent, &decl.inputs, |s, ty| {
|
self.commasep(Inconsistent, &decl.inputs, |s, ty| {
|
||||||
s.ibox(INDENT_UNIT);
|
s.ibox(INDENT_UNIT);
|
||||||
if let Some(arg_name) = arg_names.get(i) {
|
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.word(":");
|
||||||
s.s.space();
|
s.s.space();
|
||||||
} else if let Some(body_id) = body_id {
|
} else if let Some(body_id) = body_id {
|
||||||
|
@ -180,7 +180,7 @@ impl<'tcx> OnUnimplementedDirective {
|
|||||||
c.ident().map_or(false, |ident| {
|
c.ident().map_or(false, |ident| {
|
||||||
options.contains(&(
|
options.contains(&(
|
||||||
ident.name,
|
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 sorted_cnums = sorted_cnums_including_local_crate(tcx);
|
||||||
let prev_cnums: Vec<_> = sorted_cnums.iter()
|
let prev_cnums: Vec<_> = sorted_cnums.iter()
|
||||||
.map(|&cnum| {
|
.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);
|
let crate_disambiguator = tcx.crate_disambiguator(cnum);
|
||||||
(cnum.as_u32(), crate_name, crate_disambiguator)
|
(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() {
|
} else if let Some(kind) = *tcx.sess.allocator_kind.get() {
|
||||||
let llmod_id = cgu_name_builder.build_cgu_name(LOCAL_CRATE,
|
let llmod_id = cgu_name_builder.build_cgu_name(LOCAL_CRATE,
|
||||||
&["crate"],
|
&["crate"],
|
||||||
Some("allocator")).as_str()
|
Some("allocator")).to_string();
|
||||||
.to_string();
|
|
||||||
let mut modules = backend.new_metadata(tcx, &llmod_id);
|
let mut modules = backend.new_metadata(tcx, &llmod_id);
|
||||||
time(tcx.sess, "write allocator module", || {
|
time(tcx.sess, "write allocator module", || {
|
||||||
backend.codegen_allocator(tcx, &mut modules, kind)
|
backend.codegen_allocator(tcx, &mut modules, kind)
|
||||||
@ -576,8 +575,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
|||||||
// Codegen the encoded metadata.
|
// Codegen the encoded metadata.
|
||||||
let metadata_cgu_name = cgu_name_builder.build_cgu_name(LOCAL_CRATE,
|
let metadata_cgu_name = cgu_name_builder.build_cgu_name(LOCAL_CRATE,
|
||||||
&["crate"],
|
&["crate"],
|
||||||
Some("metadata")).as_str()
|
Some("metadata")).to_string();
|
||||||
.to_string();
|
|
||||||
let mut metadata_llvm_module = backend.new_metadata(tcx, &metadata_cgu_name);
|
let mut metadata_llvm_module = backend.new_metadata(tcx, &metadata_cgu_name);
|
||||||
time(tcx.sess, "write compressed metadata", || {
|
time(tcx.sess, "write compressed metadata", || {
|
||||||
backend.write_compressed_metadata(tcx, &ongoing_codegen.metadata,
|
backend.write_compressed_metadata(tcx, &ongoing_codegen.metadata,
|
||||||
|
@ -94,8 +94,8 @@ impl AssertModuleSource<'tcx> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let user_path = self.field(attr, sym::module).as_str().to_string();
|
let user_path = self.field(attr, sym::module).to_string();
|
||||||
let crate_name = self.tcx.crate_name(LOCAL_CRATE).as_str().to_string();
|
let crate_name = self.tcx.crate_name(LOCAL_CRATE).to_string();
|
||||||
|
|
||||||
if !user_path.starts_with(&crate_name) {
|
if !user_path.starts_with(&crate_name) {
|
||||||
let msg = format!("Found malformed codegen unit name `{}`. \
|
let msg = format!("Found malformed codegen unit name `{}`. \
|
||||||
@ -131,7 +131,7 @@ impl AssertModuleSource<'tcx> {
|
|||||||
cgu_name,
|
cgu_name,
|
||||||
self.available_cgus
|
self.available_cgus
|
||||||
.iter()
|
.iter()
|
||||||
.map(|cgu| cgu.as_str().to_string())
|
.map(|cgu| cgu.to_string())
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(", ")));
|
.join(", ")));
|
||||||
}
|
}
|
||||||
|
@ -1167,7 +1167,7 @@ fn external_path(cx: &DocContext<'_>, name: Symbol, trait_did: Option<DefId>, ha
|
|||||||
global: false,
|
global: false,
|
||||||
res: Res::Err,
|
res: Res::Err,
|
||||||
segments: vec![PathSegment {
|
segments: vec![PathSegment {
|
||||||
name: name.as_str().to_string(),
|
name: name.to_string(),
|
||||||
args: external_generic_args(cx, trait_did, has_self, bindings, substs)
|
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());
|
self.maybe_print_comment(attr.span.lo());
|
||||||
if attr.is_sugared_doc {
|
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()
|
self.hardbreak()
|
||||||
} else {
|
} else {
|
||||||
match attr.style {
|
match attr.style {
|
||||||
@ -1234,7 +1234,7 @@ impl<'a> State<'a> {
|
|||||||
}
|
}
|
||||||
ast::ItemKind::GlobalAsm(ref ga) => {
|
ast::ItemKind::GlobalAsm(ref ga) => {
|
||||||
self.head(visibility_qualified(&item.vis, "global_asm!"));
|
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();
|
self.end();
|
||||||
}
|
}
|
||||||
ast::ItemKind::TyAlias(ref ty, ref generics) => {
|
ast::ItemKind::TyAlias(ref ty, ref generics) => {
|
||||||
@ -2335,7 +2335,7 @@ impl<'a> State<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
crate fn print_name(&mut self, name: ast::Name) {
|
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))
|
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);
|
let mut p = Parser::new(cx.parse_sess(), tts, Some(directory), true, false, None);
|
||||||
p.root_module_name =
|
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.last_type_ascription = cx.current_expansion.prior_type_ascription;
|
||||||
|
|
||||||
p.process_potential_macro_variable();
|
p.process_potential_macro_variable();
|
||||||
|
Loading…
Reference in New Issue
Block a user