rust/tests/ui/asm
Jubilee fc0136e4f4
Rollup merge of #126922 - asquared31415:asm_binary_label, r=estebank
add lint for inline asm labels that look like binary

fixes #94426

Due to a bug/feature in LLVM, labels composed of only the digits `0` and `1` can sometimes be confused with binary literals, even if a binary literal would not be valid in that position.

This PR adds detection for such labels and also as a drive-by change, adds a note to cases such as `asm!(include_str!("file"))` that the label that it found came from an expansion of a macro, it wasn't found in the source code.

I expect this PR to upset some people that were using labels `0:` or `1:` without issue because they never hit the case where LLVM got it wrong, but adding a heuristic to the lint to prevent this is not feasible - it would involve writing a whole assembly parser for every target that we have assembly support for.

[zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202024-06-20/near/445870628)

r? ``@estebank``
2024-07-12 13:47:05 -07:00
..
aarch64 Fix aarch64 test 2024-07-11 20:40:02 +00:00
x86_64 Account for `let foo = expr`; to suggest `const foo: Ty = expr;` 2024-07-11 20:39:24 +00:00
arm-low-dreg.rs compiler: Fix arm32 asm issues by hierarchically sorting reg classes 2024-06-22 21:39:58 -07:00
bad-arch.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
bad-arch.stderr trigger `unsafe_code` on `global_asm!` invocations 2024-02-20 00:14:53 +01:00
bad-template.aarch64.stderr Update tests 2024-03-03 09:24:38 -05:00
bad-template.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
bad-template.x86_64.stderr Update tests 2024-03-03 09:24:38 -05:00
binary_asm_labels.rs add lint for inline asm labels that look like binary 2024-07-09 01:23:49 +00:00
binary_asm_labels.stderr add lint for inline asm labels that look like binary 2024-07-09 01:23:49 +00:00
const-error.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
const-error.stderr make sure we still eagerly emit errors 2023-11-25 18:00:35 +00:00
empty_global_asm.rs Move 100 entries from tests/ui into subdirs 2024-05-20 19:55:59 -07:00
fail-const-eval-issue-121099.rs Update test with `//@ needs-asm-support` 2024-03-18 22:33:04 -04:00
fail-const-eval-issue-121099.stderr Update test with `//@ needs-asm-support` 2024-03-18 22:33:04 -04:00
generic-const.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
inline-syntax.arm.stderr Fix two UI tests with incorrect directive / invalid revision 2024-02-14 09:13:53 +00:00
inline-syntax.arm_llvm_18.stderr Fix two UI tests with incorrect directive / invalid revision 2024-02-14 09:13:53 +00:00
inline-syntax.rs Remove useless configs in tests 2024-04-07 01:16:45 +02:00
inline-syntax.x86_64.stderr Fix two UI tests with incorrect directive / invalid revision 2024-02-14 09:13:53 +00:00
issue-72570.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
issue-72570.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-85247.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
issue-85247.rwpi.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-87802.rs Update test directives for `wasm32-wasip1` 2024-03-11 09:36:35 -07:00
issue-87802.stderr Update test directives for `wasm32-wasip1` 2024-03-11 09:36:35 -07:00
issue-89305.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
issue-89305.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-92378.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
issue-97490.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
issue-99071.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
issue-99071.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-99122-2.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
issue-99122.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
issue-99122.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-113788.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
issue-113788.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
may_unwind.rs Add needs-unwind annotations to a couple of tests 2024-03-25 14:19:07 +00:00
naked-functions-ffi.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
naked-functions-ffi.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
naked-functions-unused.aarch64.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
naked-functions-unused.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
naked-functions-unused.x86_64.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
naked-functions.rs Update test directives for `wasm32-wasip1` 2024-03-11 09:36:35 -07:00
naked-functions.stderr Update test directives for `wasm32-wasip1` 2024-03-11 09:36:35 -07:00
naked-invalid-attr.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
naked-invalid-attr.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
named-asm-labels.rs add lint for inline asm labels that look like binary 2024-07-09 01:23:49 +00:00
named-asm-labels.s Move /src/test to /tests 2023-01-11 09:32:08 +00:00
named-asm-labels.stderr add lint for inline asm labels that look like binary 2024-07-09 01:23:49 +00:00
noreturn.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
parse-error.rs Add tests for asm goto 2024-02-24 19:49:16 +00:00
parse-error.stderr Account for `let foo = expr`; to suggest `const foo: Ty = expr;` 2024-07-11 20:39:24 +00:00
reg-conflict.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
reg-conflict.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
simple_global_asm.rs Move 100 entries from tests/ui into subdirs 2024-05-20 19:55:59 -07:00
type-check-1.rs Update test directives for `wasm32-wasip1` 2024-03-11 09:36:35 -07:00
type-check-1.stderr Account for `let foo = expr`; to suggest `const foo: Ty = expr;` 2024-07-11 20:39:24 +00:00
type-check-4.rs Update test directives for `wasm32-wasip1` 2024-03-11 09:36:35 -07:00
type-check-4.stderr Update test directives for `wasm32-wasip1` 2024-03-11 09:36:35 -07:00
unpretty-expanded.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
unpretty-expanded.stdout [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00