]> git.lizzy.rs Git - rust.git/commitdiff
Fix cases of conflicting two-phase borrows
authorMatthew Jasper <mjjasper1@gmail.com>
Wed, 27 Feb 2019 20:32:12 +0000 (20:32 +0000)
committerMatthew Jasper <mjjasper1@gmail.com>
Thu, 4 Apr 2019 17:47:10 +0000 (18:47 +0100)
src/librustc_codegen_llvm/abi.rs
src/librustc_mir/transform/add_retag.rs
src/libsyntax_ext/format.rs

index 3a0d9e1334cf6b6783af1f44501809bacecbbb02..348616790b0bc7c57ecab9240c5d9b94e2ec916c 100644 (file)
@@ -266,7 +266,8 @@ fn store_fn_arg(
                 OperandValue::Ref(next(), Some(next()), self.layout.align.abi).store(bx, dst);
             }
             PassMode::Direct(_) | PassMode::Indirect(_, None) | PassMode::Cast(_) => {
-                self.store(bx, next(), dst);
+                let next_arg = next();
+                self.store(bx, next_arg, dst);
             }
         }
     }
index 9b9e6594296bac191813550e1d44dc18cf7cce82..a393847fd4922a546a4c1c52f935cead07755254 100644 (file)
@@ -164,7 +164,7 @@ fn run_pass<'a, 'tcx>(&self,
                         if src_ty.is_region_ptr() {
                             // The only `Misc` casts on references are those creating raw pointers.
                             assert!(dest_ty.is_unsafe_ptr());
-                            (RetagKind::Raw, place)
+                            (RetagKind::Raw, place.clone())
                         } else {
                             // Some other cast, no retag
                             continue
@@ -182,7 +182,7 @@ fn run_pass<'a, 'tcx>(&self,
                             _ =>
                                 RetagKind::Default,
                         };
-                        (kind, place)
+                        (kind, place.clone())
                     }
                     // Do nothing for the rest
                     _ => continue,
@@ -191,7 +191,7 @@ fn run_pass<'a, 'tcx>(&self,
                 let source_info = block_data.statements[i].source_info;
                 block_data.statements.insert(i+1, Statement {
                     source_info,
-                    kind: StatementKind::Retag(retag_kind, place.clone()),
+                    kind: StatementKind::Retag(retag_kind, place),
                 });
             }
         }
index 5efa6b36f675dce2bfc6099525e77feb48b1b453..24fbc9b6caf3fd8ddb4c9a14eb47d197bed2c852 100644 (file)
@@ -347,9 +347,9 @@ fn verify_arg_type(&mut self, arg: Position, ty: ArgumentType) {
 
             Named(name) => {
                 match self.names.get(&name) {
-                    Some(idx) => {
+                    Some(&idx) => {
                         // Treat as positional arg.
-                        self.verify_arg_type(Exact(*idx), ty)
+                        self.verify_arg_type(Exact(idx), ty)
                     }
                     None => {
                         let msg = format!("there is no argument named `{}`", name);