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.

https://github.com/llvm/llvm-project/blob/d593279c0b2891f0b0c8af3f70a1a0383b4ad1b5/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
2025-05-12 16:35:09 +02:00
2024-08-16 09:07:55 +10: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
2025-06-08 11:25:09 +05: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
2025-02-25 18:17:32 +01:00
2025-02-25 18:17:32 +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
2025-06-20 15:06:29 +02:00
2025-06-28 16:24:17 +05:00
2025-06-29 15:37:33 +05:00
2025-06-18 12:37:08 +02:00
2025-06-18 12:37:08 +02:00
2026-03-17 17:30:56 +01:00
2025-01-07 16:04:14 +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