add lint for inline asm labels that look like binary by asquared31415 · Pull Request #126922 · rust-lang/rust (original) (raw)

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

r? @estebank