use String::new() instead of String::from(""), "".to_string(), "".to_owned() or "".into()

This commit is contained in:
Matthias Krüger 2018-08-23 10:14:52 +02:00
parent e73077e106
commit ede1f7d2a5
87 changed files with 133 additions and 133 deletions

View File

@ -1330,7 +1330,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
s
};
let var_description = match var_origin {
infer::MiscVariable(_) => "".to_string(),
infer::MiscVariable(_) => String::new(),
infer::PatternRegion(_) => " for pattern".to_string(),
infer::AddrOfRegion(_) => " for borrow expression".to_string(),
infer::Autoref(_) => " for autoref".to_string(),

View File

@ -2105,7 +2105,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
region
} else {
// Do not even print 'static
"".to_owned()
String::new()
};
write!(fmt, "&{}{}{:?}", region, kind_str, place)
}

View File

@ -1051,7 +1051,7 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
"perform LLVM link-time optimizations"),
target_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
"select target processor (rustc --print target-cpus for details)"),
target_feature: String = ("".to_string(), parse_string, [TRACKED],
target_feature: String = (String::new(), parse_string, [TRACKED],
"target specific attributes (rustc --print target-features for details)"),
passes: Vec<String> = (Vec::new(), parse_list, [TRACKED],
"a list of extra LLVM passes to run (space separated)"),
@ -1085,7 +1085,7 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
"choose the code model to use (rustc --print code-models for details)"),
metadata: Vec<String> = (Vec::new(), parse_list, [TRACKED],
"metadata to mangle symbol names with"),
extra_filename: String = ("".to_string(), parse_string, [UNTRACKED],
extra_filename: String = (String::new(), parse_string, [UNTRACKED],
"extra data to put in each output filename"),
codegen_units: Option<usize> = (None, parse_opt_uint, [UNTRACKED],
"divide crate into N units to optimize in parallel"),
@ -1992,7 +1992,7 @@ pub fn build_session_options_and_crate_config(
};
if cg.target_feature == "help" {
prints.push(PrintRequest::TargetFeatures);
cg.target_feature = "".to_string();
cg.target_feature = String::new();
}
if cg.relocation_model.as_ref().map_or(false, |s| s == "help") {
prints.push(PrintRequest::RelocationModels);

View File

@ -472,7 +472,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
if len > 5 {
format!("\nand {} others", len - 4)
} else {
"".to_owned()
String::new()
}
));
}
@ -917,7 +917,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
remove_refs);
err.span_suggestion_short_with_applicability(
sp, &format_str, String::from(""), Applicability::MachineApplicable
sp, &format_str, String::new(), Applicability::MachineApplicable
);
break;
}
@ -1116,7 +1116,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
.collect::<Vec<String>>()
.join(", "))
} else {
"".to_owned()
String::new()
},
);
err.span_suggestion_with_applicability(

View File

@ -120,13 +120,13 @@ impl IntercrateAmbiguityCause {
&IntercrateAmbiguityCause::DownstreamCrate { ref trait_desc, ref self_desc } => {
let self_desc = if let &Some(ref ty) = self_desc {
format!(" for type `{}`", ty)
} else { "".to_string() };
} else { String::new() };
format!("downstream crates may implement trait `{}`{}", trait_desc, self_desc)
}
&IntercrateAmbiguityCause::UpstreamCrateUpdate { ref trait_desc, ref self_desc } => {
let self_desc = if let &Some(ref ty) = self_desc {
format!(" for type `{}`", ty)
} else { "".to_string() };
} else { String::new() };
format!("upstream crates may add new impl of trait `{}`{} \
in future versions",
trait_desc, self_desc)

View File

@ -213,7 +213,7 @@ fn print_time_passes_entry_internal(what: &str, dur: Duration) {
let mb = n as f64 / 1_000_000.0;
format!("; rss: {}MB", mb.round() as usize)
}
None => "".to_owned(),
None => String::new(),
};
println!("{}time: {}{}\t{}",
" ".repeat(indentation),

View File

@ -73,7 +73,7 @@ macro_rules! define_categories {
(format!("{:.2}",
(((hits as f32) / (total as f32)) * 100.0)), total.to_string())
} else {
("".into(), "".into())
(String::new(), String::new())
};
writeln!(

View File

@ -87,7 +87,7 @@ impl<'a, 'tcx> UnusedMutCx<'a, 'tcx> {
.span_suggestion_short_with_applicability(
mut_span,
"remove this `mut`",
"".to_owned(),
String::new(),
Applicability::MachineApplicable)
.emit();
}

View File

@ -140,21 +140,21 @@ impl<'a, 'tcx, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, 'tcx, O
let gens_str = if gens.iter().any(|&u| u != 0) {
format!(" gen: {}", bits_to_string(gens))
} else {
"".to_string()
String::new()
};
let action_kills = &self.action_kills[start .. end];
let action_kills_str = if action_kills.iter().any(|&u| u != 0) {
format!(" action_kill: {}", bits_to_string(action_kills))
} else {
"".to_string()
String::new()
};
let scope_kills = &self.scope_kills[start .. end];
let scope_kills_str = if scope_kills.iter().any(|&u| u != 0) {
format!(" scope_kill: {}", bits_to_string(scope_kills))
} else {
"".to_string()
String::new()
};
ps.synth_comment(

View File

@ -53,7 +53,7 @@ impl<'a, 'tcx> DataflowLabeller<'a, 'tcx> {
fn dataflow_for(&self, e: EntryOrExit, n: &Node<'a>) -> String {
let id = n.1.data.id();
debug!("dataflow_for({:?}, id={:?}) {:?}", e, id, self.variants);
let mut sets = "".to_string();
let mut sets = String::new();
let mut seen_one = false;
for &variant in &self.variants {
if seen_one { sets.push_str(" "); } else { seen_one = true; }

View File

@ -1191,7 +1191,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
member_descriptions);
vec![
MemberDescription {
name: "".to_string(),
name: String::new(),
type_metadata: variant_type_metadata,
offset: Size::ZERO,
size: self.layout.size,
@ -1220,7 +1220,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
variant_type_metadata,
member_descriptions);
MemberDescription {
name: "".to_string(),
name: String::new(),
type_metadata: variant_type_metadata,
offset: Size::ZERO,
size: variant.size,

View File

@ -85,7 +85,7 @@ pub fn html_of_effect(eff: &Effect) -> (String, String) {
fn html_of_duration(_start: &Instant, dur: &Duration) -> (String, String) {
use rustc::util::common::duration_to_secs_str;
(duration_to_secs_str(dur.clone()),
"".to_string()
String::new()
)
}

View File

@ -798,7 +798,7 @@ impl EmitterWriter {
// at by "in this macro invocation"
format!(" (#{})", i + 1)
} else {
"".to_string()
String::new()
})));
}
// Check to make sure we're not in any <*macros>
@ -813,7 +813,7 @@ impl EmitterWriter {
// backtrace is multiple levels deep
format!(" (#{})", i + 1)
} else {
"".to_string()
String::new()
})));
if !always_backtrace {
break;
@ -1065,7 +1065,7 @@ impl EmitterWriter {
let col = if let Some(first_annotation) = first_line.annotations.first() {
format!(":{}", first_annotation.start_col + 1)
} else {
"".to_string()
String::new()
};
format!("{}:{}{}",
annotated_file.file.name,

View File

@ -794,7 +794,7 @@ impl EarlyLintPass for DeprecatedAttr {
err.span_suggestion_short_with_applicability(
attr.span,
"remove this attribute",
"".to_owned(),
String::new(),
Applicability::MachineApplicable
);
err.emit();
@ -1250,7 +1250,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems {
err.span_suggestion_short_with_applicability(
no_mangle_attr.span,
"remove this attribute",
"".to_owned(),
String::new(),
// Use of `#[no_mangle]` suggests FFI intent; correct
// fix may be to monomorphize source by hand
Applicability::MaybeIncorrect

View File

@ -327,7 +327,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
err.span_suggestion_short_with_applicability(
mut_span,
"remove this `mut`",
"".to_owned(),
String::new(),
Applicability::MachineApplicable);
err.buffer(&mut mbcx.errors_buffer);

View File

@ -128,7 +128,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
}
} else {
item_msg = format!("data in a {}", pointer_type);
reason = "".to_string();
reason = String::new();
}
}
}
@ -138,7 +138,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
Place::Static(box Static { def_id, ty: _ }) => {
if let Place::Static(_) = access_place {
item_msg = format!("immutable static item `{}`", access_place_desc.unwrap());
reason = "".to_string();
reason = String::new();
} else {
item_msg = format!("`{}`", access_place_desc.unwrap());
let static_name = &self.tcx.item_name(*def_id);

View File

@ -474,7 +474,7 @@ pub trait BorrowckErrors<'cx>: Sized + Copy {
) -> DiagnosticBuilder<'cx> {
let moved_path = moved_path
.map(|mp| format!(": `{}`", mp))
.unwrap_or("".to_owned());
.unwrap_or(String::new());
let err = struct_span_err!(
self,

View File

@ -994,7 +994,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
let lev_suggestion =
match find_best_match_for_name(names, &ident.as_str(), None) {
Some(name) => format!(". Did you mean to use `{}`?", name),
None => "".to_owned(),
None => String::new(),
};
let msg = match module {
ModuleOrUniformRoot::Module(module) => {

View File

@ -1050,7 +1050,7 @@ impl<'a> DumpHandler<'a> {
.iter()
.any(|ct| *ct == CrateType::Executable);
let mut out_name = if executable {
"".to_owned()
String::new()
} else {
"lib".to_owned()
};

View File

@ -21,7 +21,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".to_string(),
arch: "aarch64".to_string(),
target_os: "ios".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "apple".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {

View File

@ -22,8 +22,8 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
arch: "aarch64".to_string(),
target_os: "fuchsia".to_string(),
target_env: "".to_string(),
target_vendor: "".to_string(),
target_env: String::new(),
target_vendor: String::new(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {
abi_blacklist: super::arm_base::abi_blacklist(),

View File

@ -27,7 +27,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
arch: "aarch64".to_string(),
target_os: "android".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {

View File

@ -24,7 +24,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
arch: "aarch64".to_string(),
target_os: "cloudabi".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -25,7 +25,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
arch: "aarch64".to_string(),
target_os: "freebsd".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {

View File

@ -24,7 +24,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
arch: "aarch64".to_string(),
target_os: "hermit".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -23,7 +23,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
arch: "aarch64".to_string(),
target_os: "netbsd".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -36,8 +36,8 @@ pub fn target() -> Result<Target, String> {
target_pointer_width: "64".to_string(),
target_c_int_width: "32".to_string(),
target_os: "none".to_string(),
target_env: "".to_string(),
target_vendor: "".to_string(),
target_env: String::new(),
target_vendor: String::new(),
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
arch: "aarch64".to_string(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),

View File

@ -23,7 +23,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
arch: "aarch64".to_string(),
target_os: "openbsd".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -24,7 +24,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
arch: "arm".to_string(),
target_os: "android".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {

View File

@ -22,8 +22,8 @@ pub fn target() -> TargetResult {
data_layout: "E-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
arch: "arm".to_string(),
target_os: "none".to_string(),
target_env: "".to_string(),
target_vendor: "".to_string(),
target_env: String::new(),
target_vendor: String::new(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {

View File

@ -21,7 +21,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32".to_string(),
arch: "arm".to_string(),
target_os: "ios".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "apple".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {

View File

@ -28,7 +28,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
arch: "arm".to_string(),
target_os: "android".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {

View File

@ -26,7 +26,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
arch: "arm".to_string(),
target_os: "cloudabi".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -21,7 +21,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32".to_string(),
arch: "arm".to_string(),
target_os: "ios".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "apple".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {

View File

@ -40,7 +40,7 @@ pub fn target() -> Result<Target, String> {
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
target_os: "emscripten".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
data_layout: "e-p:32:32-i64:64-v128:32:128-n32-S128".to_string(),
arch: "asmjs".to_string(),

View File

@ -21,7 +21,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128".to_string(),
arch: "x86".to_string(),
target_os: "ios".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "apple".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {

View File

@ -26,7 +26,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128".to_string(),
arch: "x86".to_string(),
target_os: "macos".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "apple".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -31,7 +31,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
arch: "x86".to_string(),
target_os: "android".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -26,7 +26,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
arch: "x86".to_string(),
target_os: "cloudabi".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -25,7 +25,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
arch: "x86".to_string(),
target_os: "dragonfly".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -25,7 +25,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
arch: "x86".to_string(),
target_os: "freebsd".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -25,7 +25,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
arch: "x86".to_string(),
target_os: "haiku".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -25,7 +25,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
arch: "x86".to_string(),
target_os: "netbsd".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -26,7 +26,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
arch: "x86".to_string(),
target_os: "openbsd".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -686,7 +686,7 @@ impl Default for TargetOptions {
post_link_args: LinkArgs::new(),
asm_args: Vec::new(),
cpu: "generic".to_string(),
features: "".to_string(),
features: String::new(),
dynamic_linking: false,
only_cdylib: false,
executables: false,
@ -698,7 +698,7 @@ impl Default for TargetOptions {
function_sections: true,
dll_prefix: "lib".to_string(),
dll_suffix: ".so".to_string(),
exe_suffix: "".to_string(),
exe_suffix: String::new(),
staticlib_prefix: "lib".to_string(),
staticlib_suffix: ".a".to_string(),
target_family: None,

View File

@ -19,8 +19,8 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16".to_string(),
arch: "msp430".to_string(),
target_os: "none".to_string(),
target_env: "".to_string(),
target_vendor: "".to_string(),
target_env: String::new(),
target_vendor: String::new(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {

View File

@ -26,7 +26,7 @@ pub fn target() -> TargetResult {
data_layout: "E-m:e-p:32:32-i64:64-n32".to_string(),
arch: "powerpc".to_string(),
target_os: "netbsd".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -19,7 +19,7 @@ pub fn target() -> TargetResult {
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
target_os: "none".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
arch: "riscv32".to_string(),
linker_flavor: LinkerFlavor::Ld,

View File

@ -24,7 +24,7 @@ pub fn target() -> TargetResult {
data_layout: "E-m:e-i64:64-n32:64-S128".to_string(),
arch: "sparc64".to_string(),
target_os: "netbsd".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -30,7 +30,7 @@ pub fn target() -> TargetResult {
// just be confusing.
arch: "sparc64".to_string(),
target_os: "solaris".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "sun".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -21,8 +21,8 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
arch: "arm".to_string(),
target_os: "none".to_string(),
target_env: "".to_string(),
target_vendor: "".to_string(),
target_env: String::new(),
target_vendor: String::new(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {

View File

@ -30,8 +30,8 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
arch: "arm".to_string(),
target_os: "none".to_string(),
target_env: "".to_string(),
target_vendor: "".to_string(),
target_env: String::new(),
target_vendor: String::new(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {

View File

@ -29,8 +29,8 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
arch: "arm".to_string(),
target_os: "none".to_string(),
target_env: "".to_string(),
target_vendor: "".to_string(),
target_env: String::new(),
target_vendor: String::new(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {

View File

@ -21,8 +21,8 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
arch: "arm".to_string(),
target_os: "none".to_string(),
target_env: "".to_string(),
target_vendor: "".to_string(),
target_env: String::new(),
target_vendor: String::new(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {

View File

@ -43,7 +43,7 @@ pub fn target() -> Result<Target, String> {
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
target_os: "emscripten".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
data_layout: "e-m:e-p:32:32-i64:64-n32:64-S128".to_string(),
arch: "wasm32".to_string(),

View File

@ -40,7 +40,7 @@ pub fn target() -> Result<Target, String> {
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
target_os: "emscripten".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
data_layout: "e-p:32:32-i64:64-v128:32:128-n32-S128".to_string(),
arch: "wasm32".to_string(),

View File

@ -32,7 +32,7 @@ pub fn target() -> Result<Target, String> {
// relatively self-explanatory!
exe_suffix: ".wasm".to_string(),
dll_prefix: "".to_string(),
dll_prefix: String::new(),
dll_suffix: ".wasm".to_string(),
linker_is_gnu: false,
@ -65,7 +65,7 @@ pub fn target() -> Result<Target, String> {
// This is basically guaranteed to change in the future, don't rely on
// this. Use `not(target_os = "emscripten")` for now.
target_os: "unknown".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
data_layout: "e-m:e-p:32:32-i64:64-n32:64-S128".to_string(),
arch: "wasm32".to_string(),

View File

@ -77,10 +77,10 @@ pub fn opts() -> TargetOptions {
linker: Some("gcc".to_string()),
dynamic_linking: true,
executables: true,
dll_prefix: "".to_string(),
dll_prefix: String::new(),
dll_suffix: ".dll".to_string(),
exe_suffix: ".exe".to_string(),
staticlib_prefix: "".to_string(),
staticlib_prefix: String::new(),
staticlib_suffix: ".lib".to_string(),
no_default_libraries: true,
target_family: Some("windows".to_string()),

View File

@ -21,10 +21,10 @@ pub fn opts() -> TargetOptions {
function_sections: true,
dynamic_linking: true,
executables: true,
dll_prefix: "".to_string(),
dll_prefix: String::new(),
dll_suffix: ".dll".to_string(),
exe_suffix: ".exe".to_string(),
staticlib_prefix: "".to_string(),
staticlib_prefix: String::new(),
staticlib_suffix: ".lib".to_string(),
target_family: Some("windows".to_string()),
is_like_windows: true,

View File

@ -26,7 +26,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:o-i64:64-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "macos".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "apple".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -21,7 +21,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:o-i64:64-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "ios".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "apple".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {

View File

@ -25,8 +25,8 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "fuchsia".to_string(),
target_env: "".to_string(),
target_vendor: "".to_string(),
target_env: String::new(),
target_vendor: String::new(),
linker_flavor: LinkerFlavor::Gcc,
options: base,
})

View File

@ -27,7 +27,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "android".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -33,7 +33,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "netbsd".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "rumprun".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -25,7 +25,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "solaris".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "sun".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -25,7 +25,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "bitrig".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -26,7 +26,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "cloudabi".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -25,7 +25,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "dragonfly".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -25,7 +25,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "freebsd".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -27,7 +27,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "haiku".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -25,7 +25,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "hermit".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -25,7 +25,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "netbsd".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -25,7 +25,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "openbsd".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -25,7 +25,7 @@ pub fn target() -> TargetResult {
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "redox".to_string(),
target_env: "".to_string(),
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,

View File

@ -3471,7 +3471,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
displayable_field_names.sort();
let truncated_fields_error = if len <= 3 {
"".to_string()
String::new()
} else {
format!(" and {} other field{}", (len - 3), if len - 3 == 1 {""} else {"s"})
};
@ -4783,7 +4783,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
err.span_suggestion_with_applicability(
span_semi,
"consider removing this semicolon",
"".to_string(),
String::new(),
Applicability::MachineApplicable);
}

View File

@ -142,7 +142,7 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) {
.span_suggestion_short_with_applicability(
span,
"remove it",
"".to_string(),
String::new(),
Applicability::MachineApplicable)
.emit();
continue;

View File

@ -568,7 +568,7 @@ impl Clean<Item> for doctree::Module {
let name = if self.name.is_some() {
self.name.expect("No name provided").clean(cx)
} else {
"".to_string()
String::new()
};
// maintain a stack of mod ids, for doc comment path resolution
@ -1760,7 +1760,7 @@ impl<'a, 'tcx> Clean<FnDecl> for (DefId, ty::PolyFnSig<'tcx>) {
values: sig.skip_binder().inputs().iter().map(|t| {
Argument {
type_: t.clean(cx),
name: names.next().map_or("".to_string(), |name| name.to_string()),
name: names.next().map_or(String::new(), |name| name.to_string()),
}
}).collect(),
},
@ -3596,7 +3596,7 @@ impl Clean<Item> for hir::ForeignItem {
ForeignStaticItem(Static {
type_: ty.clean(cx),
mutability: if mutbl {Mutable} else {Immutable},
expr: "".to_string(),
expr: String::new(),
})
}
hir::ForeignItemKind::Type => {
@ -3628,7 +3628,7 @@ impl ToSource for syntax_pos::Span {
debug!("converting span {:?} to snippet", self.clean(cx));
let sn = match cx.sess().source_map().span_to_snippet(*self) {
Ok(x) => x.to_string(),
Err(_) => "".to_string()
Err(_) => String::new()
};
debug!("got snippet {}", sn);
sn
@ -3824,19 +3824,19 @@ impl Clean<Stability> for attr::Stability {
feature: self.feature.to_string(),
since: match self.level {
attr::Stable {ref since} => since.to_string(),
_ => "".to_string(),
_ => String::new(),
},
deprecated_since: match self.rustc_depr {
Some(attr::RustcDeprecation {ref since, ..}) => since.to_string(),
_=> "".to_string(),
_=> String::new(),
},
deprecated_reason: match self.rustc_depr {
Some(ref depr) => depr.reason.to_string(),
_ => "".to_string(),
_ => String::new(),
},
unstable_reason: match self.level {
attr::Unstable { reason: Some(ref reason), .. } => reason.to_string(),
_ => "".to_string(),
_ => String::new(),
},
issue: match self.level {
attr::Unstable {issue, ..} => Some(issue),
@ -3855,8 +3855,8 @@ impl<'a> Clean<Stability> for &'a attr::Stability {
impl Clean<Deprecation> for attr::Deprecation {
fn clean(&self, _: &DocContext) -> Deprecation {
Deprecation {
since: self.since.as_ref().map_or("".to_string(), |s| s.to_string()),
note: self.note.as_ref().map_or("".to_string(), |s| s.to_string()),
since: self.since.as_ref().map_or(String::new(), |s| s.to_string()),
note: self.note.as_ref().map_or(String::new(), |s| s.to_string()),
}
}
}

View File

@ -620,7 +620,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
clean::BorrowedRef{ lifetime: ref l, mutability, type_: ref ty} => {
let lt = match *l {
Some(ref l) => format!("{} ", *l),
_ => "".to_string(),
_ => String::new(),
};
let m = MutableSpace(mutability);
let amp = if f.alternate() {

View File

@ -156,13 +156,13 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
root_path = page.root_path,
suffix=page.resource_suffix)
} else {
"".to_owned()
String::new()
},
content = *t,
root_path = page.root_path,
css_class = page.css_class,
logo = if layout.logo.is_empty() {
"".to_string()
String::new()
} else {
format!("<a href='{}{}/index.html'>\
<img src='{}' alt='logo' width='100'></a>",
@ -173,7 +173,7 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
description = page.description,
keywords = page.keywords,
favicon = if layout.favicon.is_empty() {
"".to_string()
String::new()
} else {
format!(r#"<link rel="shortcut icon" href="{}">"#, layout.favicon)
},

View File

@ -504,8 +504,8 @@ pub fn run(mut krate: clean::Crate,
local_sources: FxHashMap(),
issue_tracker_base_url: None,
layout: layout::Layout {
logo: "".to_string(),
favicon: "".to_string(),
logo: String::new(),
favicon: String::new(),
external_html: external_html.clone(),
krate: krate.name.clone(),
},
@ -2183,7 +2183,7 @@ fn shorter<'a>(s: Option<&'a str>) -> String {
!chr.is_whitespace()
})
}).collect::<Vec<_>>().join("\n"),
None => "".to_string()
None => String::new()
}
}
@ -2479,7 +2479,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
stab_docs = stab_docs,
docs = MarkdownSummaryLine(doc_value, &myitem.links()),
class = myitem.type_(),
stab = myitem.stability_class().unwrap_or("".to_string()),
stab = myitem.stability_class().unwrap_or(String::new()),
unsafety_flag = unsafety_flag,
href = item_path(myitem.type_(), myitem.name.as_ref().unwrap()),
title_type = myitem.type_(),

View File

@ -184,7 +184,7 @@ pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::Toke
Ok(..) => {
// Add this input file to the code map to make it available as
// dependency information, but don't enter it's contents
cx.source_map().new_source_file(file.into(), "".to_string());
cx.source_map().new_source_file(file.into(), String::new());
base::MacEager::expr(cx.expr_lit(sp, ast::LitKind::ByteStr(Lrc::new(bytes))))
}

View File

@ -230,7 +230,7 @@ fn trim_whitespace_prefix_and_push_line(lines: &mut Vec<String>, s: String, col:
if col < len {
(&s[col..len]).to_string()
} else {
"".to_string()
String::new()
}
}
None => s,

View File

@ -684,7 +684,7 @@ impl<'a> Parser<'a> {
let mut i = tokens.iter();
// This might be a sign we need a connect method on Iterator.
let b = i.next()
.map_or("".to_string(), |t| t.to_string());
.map_or(String::new(), |t| t.to_string());
i.enumerate().fold(b, |mut b, (i, a)| {
if tokens.len() > 2 && i == tokens.len() - 2 {
b.push_str(", or ");
@ -786,7 +786,7 @@ impl<'a> Parser<'a> {
} else {
err.span_label(self.span, "expected identifier");
if self.token == token::Comma && self.look_ahead(1, |t| t.is_ident()) {
err.span_suggestion(self.span, "remove this comma", "".into());
err.span_suggestion(self.span, "remove this comma", String::new());
}
}
err
@ -2506,7 +2506,7 @@ impl<'a> Parser<'a> {
err.span_suggestion_short_with_applicability(
self.span,
"remove this comma",
"".to_owned(),
String::new(),
Applicability::MachineApplicable
);
err.note("the base struct must always be the last field");
@ -3473,7 +3473,7 @@ impl<'a> Parser<'a> {
e.span_suggestion_short_with_applicability(
match_span,
"try removing this `match`",
"".to_owned(),
String::new(),
Applicability::MaybeIncorrect // speculative
);
}
@ -3850,7 +3850,7 @@ impl<'a> Parser<'a> {
if self.token == token::CloseDelim(token::Brace) {
// If the struct looks otherwise well formed, recover and continue.
if let Some(sp) = comma_sp {
err.span_suggestion_short(sp, "remove this comma", "".into());
err.span_suggestion_short(sp, "remove this comma", String::new());
}
err.emit();
break;
@ -3890,7 +3890,7 @@ impl<'a> Parser<'a> {
err.multipart_suggestion(
"move the `..` to the end of the field list",
vec![
(etc_span, "".into()),
(etc_span, String::new()),
(self.span, format!("{}.. }}", if ate_comma { "" } else { ", " })),
],
);
@ -6190,7 +6190,7 @@ impl<'a> Parser<'a> {
if token_str == ";" {
let msg = "consider removing this semicolon";
err.span_suggestion_short_with_applicability(
self.span, msg, "".to_string(), Applicability::MachineApplicable
self.span, msg, String::new(), Applicability::MachineApplicable
);
if !items.is_empty() { // Issue #51603
let previous_item = &items[items.len()-1];

View File

@ -1030,7 +1030,7 @@ mod tests {
cm.new_source_file(PathBuf::from("blork.rs").into(),
"first line.\nsecond line".to_string());
cm.new_source_file(PathBuf::from("empty.rs").into(),
"".to_string());
String::new());
cm.new_source_file(PathBuf::from("blork2.rs").into(),
"first line.\nsecond line".to_string());
cm

View File

@ -102,7 +102,7 @@ impl<T: Write> OutputFormatter for JsonFormatter<T> {
let deviation = (bs.ns_iter_summ.max - bs.ns_iter_summ.min) as usize;
let mbps = if bs.mb_s == 0 {
"".into()
String::new()
} else {
format!(r#", "mib_per_second": {}"#, bs.mb_s)
};

View File

@ -559,7 +559,7 @@ impl Config {
let mut strs: Vec<String> = nv.splitn(2, '=').map(str::to_owned).collect();
match strs.len() {
1 => (strs.pop().unwrap(), "".to_owned()),
1 => (strs.pop().unwrap(), String::new()),
2 => {
let end = strs.pop().unwrap();
(strs.pop().unwrap(), end)

View File

@ -252,7 +252,7 @@ pub fn collect_lib_features(base_src_path: &Path) -> Features {
// add it to the set of known library features so we can still generate docs.
lib_features.insert("compiler_builtins_lib".to_owned(), Feature {
level: Status::Unstable,
since: "".to_owned(),
since: String::new(),
has_gate_test: false,
tracking_issue: None,
});