Skip to content

Commit 0e84647

Browse files
committed
rustc/infer: use to_owned instead of to_string with string literals
1 parent 9fd6fad commit 0e84647

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/librustc/infer/error_reporting/need_type_info.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
100100
let mut labels = vec![(
101101
span,
102102
if &name == "_" {
103-
"cannot infer type".to_string()
103+
"cannot infer type".to_owned()
104104
} else {
105105
format!("cannot infer type for `{}`", name)
106106
},
@@ -138,20 +138,20 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
138138
// ```
139139
labels.clear();
140140
labels.push(
141-
(pattern.span, "consider giving this closure parameter a type".to_string()));
141+
(pattern.span, "consider giving this closure parameter a type".to_owned()));
142142
} else if let Some(pattern) = local_visitor.found_local_pattern {
143143
if let Some(simple_ident) = pattern.simple_ident() {
144144
match pattern.span.compiler_desugaring_kind() {
145145
None => labels.push((pattern.span,
146146
format!("consider giving `{}` a type", simple_ident))),
147147
Some(CompilerDesugaringKind::ForLoop) => labels.push((
148148
pattern.span,
149-
"the element type for this iterator is not specified".to_string(),
149+
"the element type for this iterator is not specified".to_owned(),
150150
)),
151151
_ => {}
152152
}
153153
} else {
154-
labels.push((pattern.span, "consider giving the pattern a type".to_string()));
154+
labels.push((pattern.span, "consider giving the pattern a type".to_owned()));
155155
}
156156
}
157157

src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
113113
(None, None) => {
114114
let (main_label_1, span_label_1) = if ty_sup.id == ty_sub.id {
115115
(
116-
"this type is declared with multiple lifetimes...".to_string(),
117-
"...but data with one lifetime flows into the other here".to_string()
116+
"this type is declared with multiple lifetimes...".to_owned(),
117+
"...but data with one lifetime flows into the other here".to_owned()
118118
)
119119
} else {
120120
(
121-
"these two types are declared with different lifetimes...".to_string(),
121+
"these two types are declared with different lifetimes...".to_owned(),
122122
format!(
123123
"...but data{} flows{} here",
124124
span_label_var1,
@@ -133,15 +133,15 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
133133
ty_sub.span,
134134
ret_span,
135135
"this parameter and the return type are declared \
136-
with different lifetimes...".to_string()
136+
with different lifetimes...".to_owned()
137137
,
138138
format!("...but data{} is returned here", span_label_var1),
139139
),
140140
(_, Some(ret_span)) => (
141141
ty_sup.span,
142142
ret_span,
143143
"this parameter and the return type are declared \
144-
with different lifetimes...".to_string()
144+
with different lifetimes...".to_owned()
145145
,
146146
format!("...but data{} is returned here", span_label_var1),
147147
),

src/librustc/infer/lexical_region_resolve/graphviz.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl<'a, 'gcx, 'tcx> dot::Labeller<'a> for ConstraintGraph<'a, 'gcx, 'tcx> {
198198
match *e {
199199
Edge::Constraint(ref c) =>
200200
dot::LabelText::label(format!("{:?}", self.map.get(c).unwrap())),
201-
Edge::EnclScope(..) => dot::LabelText::label("(enclosed)".to_string()),
201+
Edge::EnclScope(..) => dot::LabelText::label("(enclosed)".to_owned()),
202202
}
203203
}
204204
}

0 commit comments

Comments
 (0)