From ede1f7d2a5a2f4038e3f3b2e953c44ee5ea06194 Mon Sep 17 00:00:00 2001 From: Matthias Krüger Date: Thu, 23 Aug 2018 10:14:52 +0200 Subject: use String::new() instead of String::from(""), "".to_string(), "".to_owned() or "".into() --- src/librustc/infer/error_reporting/mod.rs | 2 +- src/librustc/mir/mod.rs | 2 +- src/librustc/session/config.rs | 6 +++--- src/librustc/traits/error_reporting.rs | 6 +++--- src/librustc/traits/select.rs | 4 ++-- src/librustc/util/common.rs | 2 +- src/librustc/util/profiling.rs | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src/librustc') diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 02da3701db2..b05ea9a5ed4 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -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(), diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 66a42cfb11a..2ede575c739 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -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) } diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index d5946786252..a58bb4724d2 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1051,7 +1051,7 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options, "perform LLVM link-time optimizations"), target_cpu: Option = (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 = (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 = (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 = (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); diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 0aa15a4ae0c..405b320f3fe 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -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::>() .join(", ")) } else { - "".to_owned() + String::new() }, ); err.span_suggestion_with_applicability( diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index dd383732bf8..69bdeec6eea 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -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) diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 1ec025f78c9..bdfba7c3e3a 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -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), diff --git a/src/librustc/util/profiling.rs b/src/librustc/util/profiling.rs index 447b75e547f..74ff1a5f4fd 100644 --- a/src/librustc/util/profiling.rs +++ b/src/librustc/util/profiling.rs @@ -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!( -- cgit 1.4.1-3-g733a5