rust/src
Ralf Jung fadfcb644e
Rollup merge of #72625 - Amanieu:asm-srcloc, r=petrochenkov
Improve inline asm error diagnostics

Previously we were just using the raw LLVM error output (with line, caret, etc) as the diagnostic message, which ends up looking rather out of place with our existing diagnostics.

The new diagnostics properly format the diagnostics and also take advantage of LLVM's per-line `srcloc` attribute to map an error in inline assembly directly to the relevant line of source code.

Incidentally also fixes #71639 by disabling `srcloc` metadata during LTO builds since we don't know what crate it might have come from. We can only resolve `srcloc`s from the currently crate since it indexes into the source map for the current crate.

Fixes #72664
Fixes #71639

r? @petrochenkov

### Old style

```rust
#![feature(llvm_asm)]

fn main() {
    unsafe {
        let _x: i32;
        llvm_asm!(
            "mov $0, $1
             invalid_instruction $0, $1
             mov $0, $1"
             : "=&r" (_x)
             : "r" (0)
             :: "intel"
        );
    }
}
```

```
error: <inline asm>:3:14: error: invalid instruction mnemonic 'invalid_instruction'
             invalid_instruction ecx, eax
             ^~~~~~~~~~~~~~~~~~~

  --> src/main.rs:6:9
   |
6  | /         llvm_asm!(
7  | |             "mov $0, $1
8  | |              invalid_instruction $0, $1
9  | |              mov $0, $1"
...  |
12 | |              :: "intel"
13 | |         );
   | |__________^
```

### New style

```rust
#![feature(asm)]

fn main() {
    unsafe {
        asm!(
            "mov {0}, {1}
             invalid_instruction {0}, {1}
             mov {0}, {1}",
            out(reg) _,
            in(reg) 0i64,
        );
    }
}
```

```
error: invalid instruction mnemonic 'invalid_instruction'
 --> test.rs:7:14
  |
7 |              invalid_instruction {0}, {1}
  |              ^
  |
note: instantiated into assembly here
 --> <inline asm>:3:14
  |
3 |              invalid_instruction rax, rcx
  |              ^^^^^^^^^^^^^^^^^^^
```
2020-05-30 23:08:44 +02:00
..
bootstrap Auto merge of #72671 - flip1995:clippyup, r=Xanewok 2020-05-29 11:16:45 +00:00
build_helper
ci Revert MSYS2 CI workaround 2020-05-22 19:08:39 +02:00
doc Rollup merge of #72439 - westernmagic:master, r=Amanieu 2020-05-29 21:58:34 +02:00
etc
liballoc Rollup merge of #72499 - mendess:master, r=dtolnay 2020-05-30 13:45:06 +02:00
libarena Be less aggressive with DroplessArena/TypedArena growth. 2020-05-13 11:35:32 +10:00
libcore Rollup merge of #72368 - CAD97:rangeto, r=dtolnay 2020-05-30 13:45:02 +02:00
libfmt_macros Improve inline asm error diagnostics 2020-05-29 17:05:35 +01:00
libgraphviz
libpanic_abort
libpanic_unwind make abort intrinsic safe, and correct its documentation 2020-05-17 11:23:42 +02:00
libproc_macro Add test for proc_macro::LineColumn 2020-05-21 17:15:13 -07:00
libprofiler_builtins
librustc_apfloat
librustc_ast Rollup merge of #72625 - Amanieu:asm-srcloc, r=petrochenkov 2020-05-30 23:08:44 +02:00
librustc_ast_lowering Rollup merge of #72625 - Amanieu:asm-srcloc, r=petrochenkov 2020-05-30 23:08:44 +02:00
librustc_ast_passes Disallow forbidden usage of non-ascii identifiers. 2020-05-17 01:31:18 +08:00
librustc_ast_pretty Move InlineAsmTemplatePiece and InlineAsmOptions to librustc_ast 2020-05-18 14:41:33 +01:00
librustc_attr Fix clippy warnings 2020-05-11 17:13:32 +02:00
librustc_builtin_macros Improve inline asm error diagnostics 2020-05-29 17:05:35 +01:00
librustc_codegen_llvm Rollup merge of #72625 - Amanieu:asm-srcloc, r=petrochenkov 2020-05-30 23:08:44 +02:00
librustc_codegen_ssa Rollup merge of #72625 - Amanieu:asm-srcloc, r=petrochenkov 2020-05-30 23:08:44 +02:00
librustc_data_structures Add Extend::{extend_one,extend_reserve} 2020-05-29 17:05:17 -07:00
librustc_driver Use OnceCell instead of Once 2020-05-22 13:31:02 -07:00
librustc_error_codes Rollup merge of #72540 - davidtwco:issue-67552-mono-collector-comparison, r=varkor 2020-05-30 13:45:10 +02:00
librustc_errors Fix spacing of expected/found notes without a label 2020-05-27 16:27:15 -07:00
librustc_expand standardize limit comparisons with Limit type 2020-05-28 10:33:07 +01:00
librustc_feature Rollup merge of #71862 - LeSeulArtichaut:unsafe-block-in-unsafe-fn, r=nikomatsakis 2020-05-29 21:58:25 +02:00
librustc_fs_util
librustc_hir Rollup merge of #72625 - Amanieu:asm-srcloc, r=petrochenkov 2020-05-30 23:08:44 +02:00
librustc_hir_pretty Move InlineAsmTemplatePiece and InlineAsmOptions to librustc_ast 2020-05-18 14:41:33 +01:00
librustc_incremental Change WorkProduct::saved_files to an Option. 2020-05-12 17:55:07 +10:00
librustc_index Add Extend::{extend_one,extend_reserve} 2020-05-29 17:05:17 -07:00
librustc_infer Tweak wording and spans of 'static dyn Trait/impl Trait requirements 2020-05-30 10:22:27 -07:00
librustc_interface more LocalDefIds 2020-05-30 12:22:29 +02:00
librustc_lexer Fix bug in shebang handling 2020-05-25 10:11:08 -04:00
librustc_lint Rollup merge of #71862 - LeSeulArtichaut:unsafe-block-in-unsafe-fn, r=nikomatsakis 2020-05-29 21:58:25 +02:00
librustc_llvm
librustc_macros
librustc_metadata Implement warning for unused dependencies. 2020-05-25 22:47:55 -07:00
librustc_middle Rollup merge of #72625 - Amanieu:asm-srcloc, r=petrochenkov 2020-05-30 23:08:44 +02:00
librustc_mir Rollup merge of #72625 - Amanieu:asm-srcloc, r=petrochenkov 2020-05-30 23:08:44 +02:00
librustc_mir_build Rollup merge of #72625 - Amanieu:asm-srcloc, r=petrochenkov 2020-05-30 23:08:44 +02:00
librustc_parse Rollup merge of #72585 - Aaron1011:feature/opt-item-tokens, r=petrochenkov 2020-05-30 13:45:13 +02:00
librustc_passes liveness: Warn about unused captured variables 2020-05-29 17:46:38 +02:00
librustc_plugin_impl Remove ast::{Ident, Name} reexports. 2020-05-08 13:13:15 +02:00
librustc_privacy iterate List by value 2020-05-23 12:24:19 +02:00
librustc_query_system Rollup merge of #72126 - nnethercote:change-WorkProduct-saved_files, r=alexcrichton 2020-05-14 18:21:50 +02:00
librustc_resolve Remove remaining calls to as_local_node_id 2020-05-29 20:05:44 +01:00
librustc_save_analysis Use OnceCell instead of Once 2020-05-22 13:31:02 -07:00
librustc_session Rollup merge of #72540 - davidtwco:issue-67552-mono-collector-comparison, r=varkor 2020-05-30 13:45:10 +02:00
librustc_span Rollup merge of #72625 - Amanieu:asm-srcloc, r=petrochenkov 2020-05-30 23:08:44 +02:00
librustc_symbol_mangling iterate List by value 2020-05-23 12:24:19 +02:00
librustc_target Rollup merge of #72439 - westernmagic:master, r=Amanieu 2020-05-29 21:58:34 +02:00
librustc_trait_selection Rollup merge of #72540 - davidtwco:issue-67552-mono-collector-comparison, r=varkor 2020-05-30 13:45:10 +02:00
librustc_traits standardize limit comparisons with Limit type 2020-05-28 10:33:07 +01:00
librustc_ty standardize limit comparisons with Limit type 2020-05-28 10:33:07 +01:00
librustc_typeck Rollup merge of #72540 - davidtwco:issue-67552-mono-collector-comparison, r=varkor 2020-05-30 13:45:10 +02:00
librustdoc Update src/librustdoc/core.rs 2020-05-28 13:23:33 -04:00
libserialize linker: More systematic handling of CRT objects 2020-05-14 10:45:11 +03:00
libstd Rollup merge of #72162 - cuviper:extend_one, r=Mark-Simulacrum 2020-05-30 12:39:10 +09:00
libterm
libtest Fix clippy warnings 2020-05-11 17:13:32 +02:00
libunwind rustc_target: Avoid an inappropriate use of post_link_objects 2020-05-20 21:33:37 +03:00
llvm-project@943dbddc8e Update LLVM submodule 2020-05-20 20:14:16 +02:00
rtstartup
rustc
rustllvm Improve inline asm error diagnostics 2020-05-29 17:05:35 +01:00
stdarch@ec6fccd34c Update stdarch 2020-05-09 16:03:40 -04:00
test Rollup merge of #72625 - Amanieu:asm-srcloc, r=petrochenkov 2020-05-30 23:08:44 +02:00
tools Auto merge of #72671 - flip1995:clippyup, r=Xanewok 2020-05-29 11:16:45 +00:00
README.md
stage0.txt

This directory contains the source code of the rust project, including:

  • rustc and its tests
  • libstd
  • Various submodules for tools, like rustdoc, rls, etc.

For more information on how various parts of the compiler work, see the rustc dev guide.