You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 28, 2025. It is now read-only.
Rollup merge of rust-lang#126922 - asquared31415:asm_binary_label, r=estebank
add lint for inline asm labels that look like binary
fixesrust-lang#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``
lint_builtin_anonymous_params = anonymous parameters are deprecated and will be removed in the next edition
53
53
.suggestion = try naming the parameter or explicitly ignoring it
54
54
55
-
lint_builtin_asm_labels = avoid using named labels in inline assembly
56
-
.help = only local labels of the form `<number>:` should be used in inline asm
57
-
.note = see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
58
-
59
55
lint_builtin_clashing_extern_diff_name = `{$this}` redeclares `{$orig}` with a different signature
60
56
.previous_decl_label = `{$orig}` previously declared here
61
57
.mismatch_label = this signature doesn't match the previous declaration
@@ -403,6 +399,19 @@ lint_incomplete_include =
403
399
404
400
lint_inner_macro_attribute_unstable = inner macro attributes are unstable
405
401
402
+
lint_invalid_asm_label_binary = avoid using labels containing only the digits `0` and `1` in inline assembly
403
+
.label = use a different label that doesn't start with `0` or `1`
404
+
.note = an LLVM bug makes these labels ambiguous with a binary literal number
405
+
.note = see <https://bugs.llvm.org/show_bug.cgi?id=36144> for more information
406
+
407
+
lint_invalid_asm_label_format_arg = avoid using named labels in inline assembly
408
+
.help = only local labels of the form `<number>:` should be used in inline asm
409
+
.note1 = format arguments may expand to a non-numeric value
410
+
.note2 = see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
411
+
lint_invalid_asm_label_named = avoid using named labels in inline assembly
412
+
.help = only local labels of the form `<number>:` should be used in inline asm
413
+
.note = see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
414
+
lint_invalid_asm_label_no_span = the label may be declared in the expansion of a macro
406
415
lint_invalid_crate_type_value = invalid `crate_type` value
0 commit comments