Skip to content

Commit

Permalink
Don't format!() string literals
Browse files Browse the repository at this point in the history
  • Loading branch information
ljedrz committed Jul 28, 2018
1 parent 4f1e235 commit 421b2ba
Show file tree
Hide file tree
Showing 42 changed files with 168 additions and 172 deletions.
16 changes: 8 additions & 8 deletions src/bootstrap/dist.rs
Expand Up @@ -94,7 +94,7 @@ impl Step for Docs {

builder.info(&format!("Dist docs ({})", host));
if !builder.config.docs {
builder.info(&format!("\tskipping - docs disabled"));
builder.info("\tskipping - docs disabled");
return distdir(builder).join(format!("{}-{}.tar.gz", name, host));
}

Expand Down Expand Up @@ -156,7 +156,7 @@ impl Step for RustcDocs {

builder.info(&format!("Dist compiler docs ({})", host));
if !builder.config.compiler_docs {
builder.info(&format!("\tskipping - compiler docs disabled"));
builder.info("\tskipping - compiler docs disabled");
return distdir(builder).join(format!("{}-{}.tar.gz", name, host));
}

Expand Down Expand Up @@ -639,7 +639,7 @@ impl Step for Std {
// The only true set of target libraries came from the build triple, so
// let's reduce redundant work by only producing archives from that host.
if compiler.host != builder.config.build {
builder.info(&format!("\tskipping, not a build host"));
builder.info("\tskipping, not a build host");
return distdir(builder).join(format!("{}-{}.tar.gz", name, target));
}

Expand Down Expand Up @@ -715,11 +715,11 @@ impl Step for Analysis {
let compiler = self.compiler;
let target = self.target;
assert!(builder.config.extended);
builder.info(&format!("Dist analysis"));
builder.info("Dist analysis");
let name = pkgname(builder, "rust-analysis");

if &compiler.host != builder.config.build {
builder.info(&format!("\tskipping, not a build host"));
builder.info("\tskipping, not a build host");
return distdir(builder).join(format!("{}-{}.tar.gz", name, target));
}

Expand Down Expand Up @@ -824,7 +824,7 @@ impl Step for Src {

/// Creates the `rust-src` installer component
fn run(self, builder: &Builder) -> PathBuf {
builder.info(&format!("Dist src"));
builder.info("Dist src");

let name = pkgname(builder, "rust-src");
let image = tmpdir(builder).join(format!("{}-image", name));
Expand Down Expand Up @@ -918,7 +918,7 @@ impl Step for PlainSourceTarball {

/// Creates the plain source tarball
fn run(self, builder: &Builder) -> PathBuf {
builder.info(&format!("Create plain source tarball"));
builder.info("Create plain source tarball");

// Make sure that the root folder of tarball has the correct name
let plain_name = format!("{}-src", pkgname(builder, "rustc"));
Expand Down Expand Up @@ -998,7 +998,7 @@ impl Step for PlainSourceTarball {
if let Some(dir) = tarball.parent() {
builder.create_dir(&dir);
}
builder.info(&format!("running installer"));
builder.info("running installer");
let mut cmd = rust_installer(builder);
cmd.arg("tarball")
.arg("--input").arg(&plain_name)
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/doc.rs
Expand Up @@ -686,7 +686,7 @@ impl Step for Rustc {
};

if !builder.config.compiler_docs {
builder.info(&format!("\tskipping - compiler/librustdoc docs disabled"));
builder.info("\tskipping - compiler/librustdoc docs disabled");
return;
}

Expand Down Expand Up @@ -788,7 +788,7 @@ impl Step for Rustdoc {
};

if !builder.config.compiler_docs {
builder.info(&format!("\tskipping - compiler/librustdoc docs disabled"));
builder.info("\tskipping - compiler/librustdoc docs disabled");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/native.rs
Expand Up @@ -474,7 +474,7 @@ impl Step for TestHelpers {
}

let _folder = builder.fold_output(|| "build_test_helpers");
builder.info(&format!("Building test helpers"));
builder.info("Building test helpers");
t!(fs::create_dir_all(&dst));
let mut cfg = cc::Build::new();

Expand Down
8 changes: 4 additions & 4 deletions src/librustc/hir/check_attr.rs
Expand Up @@ -248,8 +248,8 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
self.emit_repr_error(
attr.span,
stmt.span,
&format!("attribute should not be applied to a statement"),
&format!("not a struct, enum or union"),
"attribute should not be applied to a statement",
"not a struct, enum or union",
);
}
}
Expand All @@ -269,8 +269,8 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
self.emit_repr_error(
attr.span,
expr.span,
&format!("attribute should not be applied to an expression"),
&format!("not defining a struct, enum or union"),
"attribute should not be applied to an expression",
"not defining a struct, enum or union",
);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/infer/error_reporting/need_type_info.rs
Expand Up @@ -137,7 +137,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// ^ consider giving this closure parameter a type
// ```
labels.clear();
labels.push((pattern.span, format!("consider giving this closure parameter a type")));
labels.push(
(pattern.span, "consider giving this closure parameter a type".to_string()));
} else if let Some(pattern) = local_visitor.found_local_pattern {
if let Some(simple_ident) = pattern.simple_ident() {
match pattern.span.compiler_desugaring_kind() {
Expand All @@ -150,7 +151,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
_ => {}
}
} else {
labels.push((pattern.span, format!("consider giving the pattern a type")));
labels.push((pattern.span, "consider giving the pattern a type".to_string()));
}
}

Expand Down
Expand Up @@ -99,30 +99,26 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
let span_label_var1 = if let Some(simple_ident) = anon_arg_sup.pat.simple_ident() {
format!(" from `{}`", simple_ident)
} else {
format!("")
String::new()
};

let span_label_var2 = if let Some(simple_ident) = anon_arg_sub.pat.simple_ident() {
format!(" into `{}`", simple_ident)
} else {
format!("")
String::new()
};


let (span_1, span_2, main_label, span_label) = match (sup_is_ret_type, sub_is_ret_type) {
(None, None) => {
let (main_label_1, span_label_1) = if ty_sup.id == ty_sub.id {
(
format!("this type is declared with multiple lifetimes..."),
format!(
"...but data{} flows{} here",
format!(" with one lifetime"),
format!(" into the other")
),
"this type is declared with multiple lifetimes...".to_string(),
"...but data with one lifetime flows into the other here".to_string()
)
} else {
(
format!("these two types are declared with different lifetimes..."),
"these two types are declared with different lifetimes...".to_string(),
format!(
"...but data{} flows{} here",
span_label_var1,
Expand All @@ -136,27 +132,25 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
(Some(ret_span), _) => (
ty_sub.span,
ret_span,
format!(
"this parameter and the return type are declared \
with different lifetimes...",
),
"this parameter and the return type are declared \
with different lifetimes...".to_string()
,
format!("...but data{} is returned here", span_label_var1),
),
(_, Some(ret_span)) => (
ty_sup.span,
ret_span,
format!(
"this parameter and the return type are declared \
with different lifetimes...",
),
"this parameter and the return type are declared \
with different lifetimes...".to_string()
,
format!("...but data{} is returned here", span_label_var1),
),
};


struct_span_err!(self.tcx.sess, span, E0623, "lifetime mismatch")
.span_label(span_1, main_label)
.span_label(span_2, format!(""))
.span_label(span_2, String::new())
.span_label(span, span_label)
.emit();
return Some(ErrorReported);
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/infer/lexical_region_resolve/graphviz.rs
Expand Up @@ -204,7 +204,7 @@ impl<'a, 'gcx, 'tcx> dot::Labeller<'a> for ConstraintGraph<'a, 'gcx, 'tcx> {
match *e {
Edge::Constraint(ref c) =>
dot::LabelText::label(format!("{:?}", self.map.get(c).unwrap())),
Edge::EnclScope(..) => dot::LabelText::label(format!("(enclosed)")),
Edge::EnclScope(..) => dot::LabelText::label("(enclosed)".to_string()),
}
}
}
Expand Down Expand Up @@ -273,7 +273,7 @@ fn dump_region_data_to<'a, 'gcx, 'tcx>(region_rels: &RegionRelations<'a, 'gcx, '
debug!("dump_region_data map (len: {}) path: {}",
map.len(),
path);
let g = ConstraintGraph::new(format!("region_data"), region_rels, map);
let g = ConstraintGraph::new("region_data".to_string(), region_rels, map);
debug!("dump_region_data calling render");
let mut v = Vec::new();
dot::render(&g, &mut v).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/lint/builtin.rs
Expand Up @@ -424,7 +424,7 @@ impl BuiltinLintDiagnostics {
Ok(ref s) if is_global => (format!("dyn ({})", s),
Applicability::MachineApplicable),
Ok(s) => (format!("dyn {}", s), Applicability::MachineApplicable),
Err(_) => (format!("dyn <type>"), Applicability::HasPlaceholders)
Err(_) => ("dyn <type>".to_string(), Applicability::HasPlaceholders)
};
db.span_suggestion_with_applicability(span, "use `dyn`", sugg, app);
}
Expand All @@ -441,7 +441,7 @@ impl BuiltinLintDiagnostics {

(format!("crate{}{}", opt_colon, s), Applicability::MachineApplicable)
}
Err(_) => (format!("crate::<path>"), Applicability::HasPlaceholders)
Err(_) => ("crate::<path>".to_string(), Applicability::HasPlaceholders)
};
db.span_suggestion_with_applicability(span, "use `crate`", sugg, app);
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/intrinsicck.rs
Expand Up @@ -107,7 +107,7 @@ impl<'a, 'tcx> ExprVisitor<'a, 'tcx> {
}
Err(LayoutError::Unknown(bad)) => {
if bad == ty {
format!("this type's size can vary")
"this type's size can vary".to_string()
} else {
format!("size can vary because of {}", bad)
}
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/middle/mem_categorization.rs
Expand Up @@ -1512,15 +1512,15 @@ impl<'tcx> cmt_<'tcx> {
None => {
match pk {
Unique => {
format!("`Box` content")
"`Box` content".to_string()
}
UnsafePtr(..) => {
format!("dereference of raw pointer")
"dereference of raw pointer".to_string()
}
BorrowedPtr(..) => {
match self.note {
NoteIndex => format!("indexed content"),
_ => format!("borrowed content"),
NoteIndex => "indexed content".to_string(),
_ => "borrowed content".to_string(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/resolve_lifetime.rs
Expand Up @@ -2665,7 +2665,7 @@ pub fn report_missing_lifetime_specifiers(
let msg = if count > 1 {
format!("expected {} lifetime parameters", count)
} else {
format!("expected lifetime parameter")
"expected lifetime parameter".to_string()
};

err.span_label(span, msg);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/specialize/mod.rs
Expand Up @@ -364,7 +364,7 @@ pub(super) fn specialization_graph_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx
match tcx.span_of_impl(overlap.with_impl) {
Ok(span) => {
err.span_label(tcx.sess.codemap().def_span(span),
format!("first implementation here"));
"first implementation here".to_string());
err.span_label(impl_span,
format!("conflicting implementation{}",
overlap.self_desc
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/error.rs
Expand Up @@ -204,7 +204,7 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> {
format!("&{}", tymut_string)
}
}
ty::TyFnDef(..) => format!("fn item"),
ty::TyFnDef(..) => "fn item".to_string(),
ty::TyFnPtr(_) => "fn pointer".to_string(),
ty::TyDynamic(ref inner, ..) => {
inner.principal().map_or_else(|| "trait".to_string(),
Expand Down

0 comments on commit 421b2ba

Please sign in to comment.