Skip to content

Commit 92b31cc

Browse files
committed
avoid Ty to String conversions
1 parent 34805f3 commit 92b31cc

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
223223
if let Some(def) = aty.ty_adt_def() {
224224
// We also want to be able to select the slice's type's original
225225
// signature with no type arguments resolved
226-
let type_string = self.tcx.type_of(def.did()).to_string();
227-
flags.push((sym::_Self, Some(format!("[{type_string}]"))));
226+
flags.push((sym::_Self, Some(format!("[{}]", self.tcx.type_of(def.did())))));
228227
}
229228
if aty.is_integral() {
230229
flags.push((sym::_Self, Some("[{integral}]".to_string())));
@@ -242,10 +241,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
242241
if let Some(def) = aty.ty_adt_def() {
243242
// We also want to be able to select the array's type's original
244243
// signature with no type arguments resolved
245-
let type_string = self.tcx.type_of(def.did()).to_string();
246-
flags.push((sym::_Self, Some(format!("[{type_string}; _]"))));
244+
let def_ty = self.tcx.type_of(def.did());
245+
flags.push((sym::_Self, Some(format!("[{def_ty}; _]"))));
247246
if let Some(n) = len {
248-
flags.push((sym::_Self, Some(format!("[{type_string}; {n}]"))));
247+
flags.push((sym::_Self, Some(format!("[{def_ty}; {n}]"))));
249248
}
250249
}
251250
if aty.is_integral() {

0 commit comments

Comments
 (0)