Skip to content

Commit ede1f7d

Browse files
committed
use String::new() instead of String::from(""), "".to_string(), "".to_owned() or "".into()
1 parent e73077e commit ede1f7d

File tree

87 files changed

+133
-133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+133
-133
lines changed

src/librustc/infer/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
13301330
s
13311331
};
13321332
let var_description = match var_origin {
1333-
infer::MiscVariable(_) => "".to_string(),
1333+
infer::MiscVariable(_) => String::new(),
13341334
infer::PatternRegion(_) => " for pattern".to_string(),
13351335
infer::AddrOfRegion(_) => " for borrow expression".to_string(),
13361336
infer::Autoref(_) => " for autoref".to_string(),

src/librustc/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2105,7 +2105,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
21052105
region
21062106
} else {
21072107
// Do not even print 'static
2108-
"".to_owned()
2108+
String::new()
21092109
};
21102110
write!(fmt, "&{}{}{:?}", region, kind_str, place)
21112111
}

src/librustc/session/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
10511051
"perform LLVM link-time optimizations"),
10521052
target_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
10531053
"select target processor (rustc --print target-cpus for details)"),
1054-
target_feature: String = ("".to_string(), parse_string, [TRACKED],
1054+
target_feature: String = (String::new(), parse_string, [TRACKED],
10551055
"target specific attributes (rustc --print target-features for details)"),
10561056
passes: Vec<String> = (Vec::new(), parse_list, [TRACKED],
10571057
"a list of extra LLVM passes to run (space separated)"),
@@ -1085,7 +1085,7 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
10851085
"choose the code model to use (rustc --print code-models for details)"),
10861086
metadata: Vec<String> = (Vec::new(), parse_list, [TRACKED],
10871087
"metadata to mangle symbol names with"),
1088-
extra_filename: String = ("".to_string(), parse_string, [UNTRACKED],
1088+
extra_filename: String = (String::new(), parse_string, [UNTRACKED],
10891089
"extra data to put in each output filename"),
10901090
codegen_units: Option<usize> = (None, parse_opt_uint, [UNTRACKED],
10911091
"divide crate into N units to optimize in parallel"),
@@ -1992,7 +1992,7 @@ pub fn build_session_options_and_crate_config(
19921992
};
19931993
if cg.target_feature == "help" {
19941994
prints.push(PrintRequest::TargetFeatures);
1995-
cg.target_feature = "".to_string();
1995+
cg.target_feature = String::new();
19961996
}
19971997
if cg.relocation_model.as_ref().map_or(false, |s| s == "help") {
19981998
prints.push(PrintRequest::RelocationModels);

src/librustc/traits/error_reporting.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
472472
if len > 5 {
473473
format!("\nand {} others", len - 4)
474474
} else {
475-
"".to_owned()
475+
String::new()
476476
}
477477
));
478478
}
@@ -917,7 +917,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
917917
remove_refs);
918918

919919
err.span_suggestion_short_with_applicability(
920-
sp, &format_str, String::from(""), Applicability::MachineApplicable
920+
sp, &format_str, String::new(), Applicability::MachineApplicable
921921
);
922922
break;
923923
}
@@ -1116,7 +1116,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
11161116
.collect::<Vec<String>>()
11171117
.join(", "))
11181118
} else {
1119-
"".to_owned()
1119+
String::new()
11201120
},
11211121
);
11221122
err.span_suggestion_with_applicability(

src/librustc/traits/select.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ impl IntercrateAmbiguityCause {
120120
&IntercrateAmbiguityCause::DownstreamCrate { ref trait_desc, ref self_desc } => {
121121
let self_desc = if let &Some(ref ty) = self_desc {
122122
format!(" for type `{}`", ty)
123-
} else { "".to_string() };
123+
} else { String::new() };
124124
format!("downstream crates may implement trait `{}`{}", trait_desc, self_desc)
125125
}
126126
&IntercrateAmbiguityCause::UpstreamCrateUpdate { ref trait_desc, ref self_desc } => {
127127
let self_desc = if let &Some(ref ty) = self_desc {
128128
format!(" for type `{}`", ty)
129-
} else { "".to_string() };
129+
} else { String::new() };
130130
format!("upstream crates may add new impl of trait `{}`{} \
131131
in future versions",
132132
trait_desc, self_desc)

src/librustc/util/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ fn print_time_passes_entry_internal(what: &str, dur: Duration) {
213213
let mb = n as f64 / 1_000_000.0;
214214
format!("; rss: {}MB", mb.round() as usize)
215215
}
216-
None => "".to_owned(),
216+
None => String::new(),
217217
};
218218
println!("{}time: {}{}\t{}",
219219
" ".repeat(indentation),

src/librustc/util/profiling.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ macro_rules! define_categories {
7373
(format!("{:.2}",
7474
(((hits as f32) / (total as f32)) * 100.0)), total.to_string())
7575
} else {
76-
("".into(), "".into())
76+
(String::new(), String::new())
7777
};
7878

7979
writeln!(

src/librustc_borrowck/borrowck/unused.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<'a, 'tcx> UnusedMutCx<'a, 'tcx> {
8787
.span_suggestion_short_with_applicability(
8888
mut_span,
8989
"remove this `mut`",
90-
"".to_owned(),
90+
String::new(),
9191
Applicability::MachineApplicable)
9292
.emit();
9393
}

src/librustc_borrowck/dataflow.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,21 +140,21 @@ impl<'a, 'tcx, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, 'tcx, O
140140
let gens_str = if gens.iter().any(|&u| u != 0) {
141141
format!(" gen: {}", bits_to_string(gens))
142142
} else {
143-
"".to_string()
143+
String::new()
144144
};
145145

146146
let action_kills = &self.action_kills[start .. end];
147147
let action_kills_str = if action_kills.iter().any(|&u| u != 0) {
148148
format!(" action_kill: {}", bits_to_string(action_kills))
149149
} else {
150-
"".to_string()
150+
String::new()
151151
};
152152

153153
let scope_kills = &self.scope_kills[start .. end];
154154
let scope_kills_str = if scope_kills.iter().any(|&u| u != 0) {
155155
format!(" scope_kill: {}", bits_to_string(scope_kills))
156156
} else {
157-
"".to_string()
157+
String::new()
158158
};
159159

160160
ps.synth_comment(

src/librustc_borrowck/graphviz.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<'a, 'tcx> DataflowLabeller<'a, 'tcx> {
5353
fn dataflow_for(&self, e: EntryOrExit, n: &Node<'a>) -> String {
5454
let id = n.1.data.id();
5555
debug!("dataflow_for({:?}, id={:?}) {:?}", e, id, self.variants);
56-
let mut sets = "".to_string();
56+
let mut sets = String::new();
5757
let mut seen_one = false;
5858
for &variant in &self.variants {
5959
if seen_one { sets.push_str(" "); } else { seen_one = true; }

0 commit comments

Comments
 (0)