Files
rust/tests/ui/attributes
Matthias Krüger 99abbd6a01 Rollup merge of #155817 - folkertdev:link-name-null-empty, r=mejrs
validate `#[link_name = "..."]` & `#[link(name = "...")]` parameters

fixes https://github.com/rust-lang/rust/issues/155776
fixes https://github.com/rust-lang/rust/issues/155484

specifically, do not allow NULL bytes and the empty string in `#[link_name = "..."]` and `#[link(name = "...")]`.

Like some of the others I think this formally needs to be looked at by T-lang because these errors would not show up if not linking.

The LLVM erorr on `#[linke_name = "\0"]` is emitted here, it is not e.g. target-specific.

d593279c0b/llvm/lib/IR/Value.cpp (L336-L342)

On `#[link(name = "")]` we already error today. A NULL byte in `#[link(name = "\0")]` is caught by the linker (https://godbolt.org/z/vnz9sYbPs), using `#[link_name = ""]` makes LLVM generate a name (https://godbolt.org/z/1hWEo4cxf) which is not useful and likely to cause linker errors.

r? jdonszelmann
2026-05-10 03:17:02 +02:00
..
2026-03-09 09:11:06 +00:00
2025-08-14 18:18:42 +02:00
…
2026-02-22 20:20:33 +01:00
2026-04-17 12:37:58 +02:00
2026-04-17 12:37:58 +02:00
2025-08-14 18:18:42 +02:00
2025-08-14 18:18:42 +02:00
2026-01-11 10:54:45 +01:00
2026-01-18 22:41:00 +01:00
2026-03-17 17:30:56 +01:00
2026-03-17 17:30:56 +01:00
2026-03-17 17:30:56 +01:00
2026-03-17 17:30:56 +01:00
2026-03-17 17:30:56 +01:00
2026-04-21 12:28:25 +02:00
2025-08-14 18:18:42 +02:00
2026-03-17 17:30:56 +01:00
2025-12-10 12:28:05 +01:00
2025-08-14 18:18:42 +02:00
2025-08-14 18:18:42 +02:00
2025-08-14 18:18:42 +02:00
2025-08-14 18:18:42 +02:00
2025-08-14 18:18:42 +02:00
2026-04-19 23:51:38 +05:30
2025-08-19 09:03:54 +02:00
2026-04-27 09:53:10 +02:00