Open
Description
I tried this code:
#[target_feature(enable = "sse2")]
pub fn compute(x: u32) -> u32 {
x + 1
}
I expected to see this happen: rustdoc JSON should contain an entry for compute
whose header
field says:
"header": {
"is_const": false,
"is_unsafe": false,
"is_async": false,
"abi": "Rust"
},
Instead, this happened: the rustdoc JSON entry for compute
incorrectly lists it as unsafe
. Here's its entire item entry from a format_version: 46
rustdoc JSON file:
"0": {
"id": 0,
"crate_id": 0,
"name": "compute",
"span": {
"filename": "src/lib.rs",
"begin": [
2,
1
],
"end": [
4,
2
]
},
"visibility": "public",
"docs": null,
"links": {},
"attrs": [
"#[target_feature(enable = \"sse2\")]"
],
"deprecation": null,
"inner": {
"function": {
"sig": {
"inputs": [
[
"x",
{
"primitive": "u32"
}
]
],
"output": {
"primitive": "u32"
},
"is_c_variadic": false
},
"generics": {
"params": [],
"where_predicates": []
},
"header": {
"is_const": false,
"is_unsafe": true, # <--- BUG!
"is_async": false,
"abi": "Rust"
},
"has_body": true
}
}
},
Meta
rustc --version --verbose
:
rustc 1.89.0-nightly (45acf54ee 2025-06-16)
binary: rustc
commit-hash: 45acf54eea118ed27927282b5e0bfdcd80b7987c
commit-date: 2025-06-16
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5
@rustbot label +A-rustdoc-json