about summary refs log tree commit diff
diff options
context:
space:
mode:
authorlrh2000 <lrh2000@pku.edu.cn>2021-07-09 21:00:51 +0800
committerlrh2000 <lrh2000@pku.edu.cn>2021-07-09 23:09:50 +0800
commit0cb6f07ef2690b9ad5941c33a0928bf72788829d (patch)
tree104560217863e4b12de1d99ee2f77db76bfec5f1
parentcda90f55419ce449f3a9db327465d9b2ae7dfce9 (diff)
downloadrust-0cb6f07ef2690b9ad5941c33a0928bf72788829d.tar.gz
rust-0cb6f07ef2690b9ad5941c33a0928bf72788829d.zip
Avoid unnecessary `String::clone`
-rw-r--r--compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
index bc950778bcc..2cb126f1a7e 100644
--- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
+++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
@@ -1314,9 +1314,9 @@ struct TupleMemberDescriptionFactory<'tcx> {
 
 impl<'tcx> TupleMemberDescriptionFactory<'tcx> {
     fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) -> Vec<MemberDescription<'ll>> {
-        let capture_names = match *self.ty.kind() {
+        let mut capture_names = match *self.ty.kind() {
             ty::Generator(def_id, ..) | ty::Closure(def_id, ..) => {
-                Some(closure_saved_names_of_captured_variables(cx.tcx, def_id))
+                Some(closure_saved_names_of_captured_variables(cx.tcx, def_id).into_iter())
             }
             _ => None,
         };
@@ -1326,8 +1326,8 @@ impl<'tcx> TupleMemberDescriptionFactory<'tcx> {
             .enumerate()
             .map(|(i, &component_type)| {
                 let (size, align) = cx.size_and_align_of(component_type);
-                let name = if let Some(names) = capture_names.as_ref() {
-                    names[i].clone()
+                let name = if let Some(names) = capture_names.as_mut() {
+                    names.next().unwrap()
                 } else {
                     format!("__{}", i)
                 };