diff options
| author | bors <bors@rust-lang.org> | 2020-06-11 18:11:07 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-06-11 18:11:07 +0000 |
| commit | a37c32e2d5fb186627ffe99a391c7fd6fd159334 (patch) | |
| tree | df7e39d8ffe113bd11f9cf75a54bec2157d219b8 /src/librustc_codegen_ssa | |
| parent | 50c0192c64241d723066add22c53d472e2b9cba9 (diff) | |
| parent | 8650df5dea7a27852a7fa6bd2585905abb521db7 (diff) | |
Auto merge of #73246 - Dylan-DPC:rollup-xnm531f, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - #72180 (remove extra space from crate-level doctest names) - #73012 (Show `SyntaxContext` in formatted `Span` debug output) - #73097 (Try_run must only be used if toolstate is populated) - #73169 (Handle assembler warnings properly) - #73182 (Track span of function in method calls, and use this in #[track_caller]) - #73207 (Clean up E0648 explanation) - #73230 (Suggest including unused asm arguments in a comment to avoid error) Failed merges: r? @ghost
Diffstat (limited to 'src/librustc_codegen_ssa')
| -rw-r--r-- | src/librustc_codegen_ssa/back/write.rs | 20 | ||||
| -rw-r--r-- | src/librustc_codegen_ssa/mir/block.rs | 12 |
2 files changed, 23 insertions, 9 deletions
diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs index cb5c95c11fa..c118e5ebdb7 100644 --- a/src/librustc_codegen_ssa/back/write.rs +++ b/src/librustc_codegen_ssa/back/write.rs @@ -1551,7 +1551,7 @@ fn spawn_work<B: ExtraBackendMethods>(cgcx: CodegenContext<B>, work: WorkItem<B> enum SharedEmitterMessage { Diagnostic(Diagnostic), - InlineAsmError(u32, String, Option<(String, Vec<InnerSpan>)>), + InlineAsmError(u32, String, Level, Option<(String, Vec<InnerSpan>)>), AbortIfErrors, Fatal(String), } @@ -1576,9 +1576,10 @@ impl SharedEmitter { &self, cookie: u32, msg: String, + level: Level, source: Option<(String, Vec<InnerSpan>)>, ) { - drop(self.sender.send(SharedEmitterMessage::InlineAsmError(cookie, msg, source))); + drop(self.sender.send(SharedEmitterMessage::InlineAsmError(cookie, msg, level, source))); } pub fn fatal(&self, msg: &str) { @@ -1631,16 +1632,21 @@ impl SharedEmitterMain { } handler.emit_diagnostic(&d); } - Ok(SharedEmitterMessage::InlineAsmError(cookie, msg, source)) => { + Ok(SharedEmitterMessage::InlineAsmError(cookie, msg, level, source)) => { let msg = msg.strip_prefix("error: ").unwrap_or(&msg); + let mut err = match level { + Level::Error => sess.struct_err(&msg), + Level::Warning => sess.struct_warn(&msg), + Level::Note => sess.struct_note_without_error(&msg), + _ => bug!("Invalid inline asm diagnostic level"), + }; + // If the cookie is 0 then we don't have span information. - let mut err = if cookie == 0 { - sess.struct_err(&msg) - } else { + if cookie != 0 { let pos = BytePos::from_u32(cookie); let span = Span::with_root_ctxt(pos, pos); - sess.struct_span_err(span, &msg) + err.set_span(span); }; // Point to the generated assembly if it is available. diff --git a/src/librustc_codegen_ssa/mir/block.rs b/src/librustc_codegen_ssa/mir/block.rs index 30a84c4e47b..74d7fc16215 100644 --- a/src/librustc_codegen_ssa/mir/block.rs +++ b/src/librustc_codegen_ssa/mir/block.rs @@ -530,6 +530,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { args: &Vec<mir::Operand<'tcx>>, destination: &Option<(mir::Place<'tcx>, mir::BasicBlock)>, cleanup: Option<mir::BasicBlock>, + fn_span: Span, ) { let span = terminator.source_info.span; // Create the callee. This is a fn ptr or zero-sized and hence a kind of scalar. @@ -634,7 +635,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { if intrinsic == Some("caller_location") { if let Some((_, target)) = destination.as_ref() { - let location = self.get_caller_location(&mut bx, span); + let location = self.get_caller_location(&mut bx, fn_span); if let ReturnDest::IndirectOperand(tmp, _) = ret_dest { location.val.store(&mut bx, tmp); @@ -798,7 +799,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { args.len() + 1, "#[track_caller] fn's must have 1 more argument in their ABI than in their MIR", ); - let location = self.get_caller_location(&mut bx, span); + let location = self.get_caller_location(&mut bx, fn_span); + debug!( + "codegen_call_terminator({:?}): location={:?} (fn_span {:?})", + terminator, location, fn_span + ); + let last_arg = fn_abi.args.last().unwrap(); self.codegen_argument(&mut bx, location, &mut llargs, last_arg); } @@ -1016,6 +1022,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { ref destination, cleanup, from_hir_call: _, + fn_span, } => { self.codegen_call_terminator( helper, @@ -1025,6 +1032,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { args, destination, cleanup, + fn_span, ); } mir::TerminatorKind::GeneratorDrop | mir::TerminatorKind::Yield { .. } => { |
