diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index ea4eb761964..7f6c5b1a9ce 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -1713,7 +1713,7 @@ pub enum StatementKind<'tcx> { InlineAsm { asm: Box, outputs: Box<[Place<'tcx>]>, - inputs: Box<[Operand<'tcx>]>, + inputs: Box<[(Span, Operand<'tcx>)]>, }, /// Assert the given places to be valid inhabitants of their type. These statements are diff --git a/src/librustc/mir/visit.rs b/src/librustc/mir/visit.rs index d2b0a6a37a7..b9d23caf71c 100644 --- a/src/librustc/mir/visit.rs +++ b/src/librustc/mir/visit.rs @@ -383,7 +383,8 @@ fn super_statement(&mut self, for output in & $($mutability)* outputs[..] { self.visit_place(output, PlaceContext::AsmOutput, location); } - for input in & $($mutability)* inputs[..] { + for (span, input) in & $($mutability)* inputs[..] { + self.visit_span(span); self.visit_operand(input, location); } } diff --git a/src/librustc_codegen_llvm/mir/statement.rs b/src/librustc_codegen_llvm/mir/statement.rs index 93be0074f6e..2a873fb4cbb 100644 --- a/src/librustc_codegen_llvm/mir/statement.rs +++ b/src/librustc_codegen_llvm/mir/statement.rs @@ -84,18 +84,18 @@ pub fn codegen_statement(&mut self, }).collect(); let input_vals = inputs.iter() - .try_fold(Vec::with_capacity(inputs.len()), |mut acc, input| { + .try_fold(Vec::with_capacity(inputs.len()), |mut acc, (span, input)| { let op = self.codegen_operand(&bx, input); if let OperandValue::Immediate(_) = op.val { acc.push(op.immediate()); Ok(acc) } else { - Err(op) + Err(span) } }); - if input_vals.is_err() { - span_err!(bx.sess(), statement.source_info.span, E0669, + if let Err(span) = input_vals { + span_err!(bx.sess(), span.to_owned(), E0669, "invalid value for constraint in inline assembly"); } else { let input_vals = input_vals.unwrap(); diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 0943b36440a..ec05f9be1fc 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -565,7 +565,7 @@ fn visit_statement_entry( ); } } - for input in inputs.iter() { + for (_, input) in inputs.iter() { self.consume_operand(context, (input, span), flow_state); } } diff --git a/src/librustc_mir/borrow_check/nll/invalidation.rs b/src/librustc_mir/borrow_check/nll/invalidation.rs index a9b5531bae5..5c2d4788a4c 100644 --- a/src/librustc_mir/borrow_check/nll/invalidation.rs +++ b/src/librustc_mir/borrow_check/nll/invalidation.rs @@ -128,7 +128,7 @@ fn visit_statement(&mut self, ); } } - for input in inputs.iter() { + for (_, input) in inputs.iter() { self.consume_operand(context, input); } } diff --git a/src/librustc_mir/build/expr/stmt.rs b/src/librustc_mir/build/expr/stmt.rs index d2b39f088b6..8f52499124a 100644 --- a/src/librustc_mir/build/expr/stmt.rs +++ b/src/librustc_mir/build/expr/stmt.rs @@ -167,8 +167,12 @@ pub fn stmt_expr(&mut self, mut block: BasicBlock, expr: Expr<'tcx>) -> BlockAnd .into_boxed_slice(); let inputs = inputs .into_iter() - .map(|input| unpack!(block = this.as_local_operand(block, input))) - .collect::>() + .map(|input| { + ( + input.span(), + unpack!(block = this.as_local_operand(block, input)), + ) + }).collect::>() .into_boxed_slice(); this.cfg.push( block, diff --git a/src/librustc_mir/dataflow/move_paths/builder.rs b/src/librustc_mir/dataflow/move_paths/builder.rs index 32b11870116..c64ebb0771f 100644 --- a/src/librustc_mir/dataflow/move_paths/builder.rs +++ b/src/librustc_mir/dataflow/move_paths/builder.rs @@ -290,7 +290,7 @@ fn gather_statement(&mut self, stmt: &Statement<'tcx>) { self.gather_init(output, InitKind::Deep); } } - for input in inputs.iter() { + for (_, input) in inputs.iter() { self.gather_operand(input); } } diff --git a/src/test/ui/inline-asm-bad-operand.stderr b/src/test/ui/inline-asm-bad-operand.stderr index 6971215a95f..ceef990d181 100644 --- a/src/test/ui/inline-asm-bad-operand.stderr +++ b/src/test/ui/inline-asm-bad-operand.stderr @@ -1,32 +1,32 @@ error[E0669]: invalid value for constraint in inline assembly - --> $DIR/inline-asm-bad-operand.rs:28:9 + --> $DIR/inline-asm-bad-operand.rs:28:24 | LL | asm!("" :: "r"("")); //~ ERROR E0669 - | ^^^^^^^^^^^^^^^^^^^^ + | ^^ error[E0669]: invalid value for constraint in inline assembly - --> $DIR/inline-asm-bad-operand.rs:33:9 + --> $DIR/inline-asm-bad-operand.rs:33:32 | LL | asm!("ret" : : "{rdi}"(target)); //~ ERROR E0669 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^ error[E0669]: invalid value for constraint in inline assembly - --> $DIR/inline-asm-bad-operand.rs:40:14 + --> $DIR/inline-asm-bad-operand.rs:40:29 | LL | unsafe { asm!("" :: "i"(hello)) }; //~ ERROR E0669 - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ error[E0669]: invalid value for constraint in inline assembly - --> $DIR/inline-asm-bad-operand.rs:48:9 + --> $DIR/inline-asm-bad-operand.rs:48:38 | LL | asm!("movups $1, %xmm0"::"m"(arr)); //~ ERROR E0669 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ error[E0669]: invalid value for constraint in inline assembly - --> $DIR/inline-asm-bad-operand.rs:55:9 + --> $DIR/inline-asm-bad-operand.rs:55:32 | LL | asm!("mov sp, $0"::"r"(addr)); //~ ERROR E0669 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^ error: aborting due to 5 previous errors