Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 84f92f3

Browse files
rustdoc: Don't mark #[target_feature] functions as ⚠
Closes https://www.github.com/rust-lang/rust/issues/142952
1 parent 36b2163 commit 84f92f3

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

‎src/librustdoc/html/render/print_item.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,8 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
469469

470470
let unsafety_flag = match myitem.kind {
471471
clean::FunctionItem(_) | clean::ForeignFunctionItem(..)
472-
if myitem.fn_header(tcx).unwrap().is_unsafe() =>
472+
if myitem.fn_header(tcx).unwrap().safety
473+
== hir::HeaderSafety::Normal(hir::Safety::Unsafe) =>
473474
{
474475
"<sup title=\"unsafe function\">⚠</sup>"
475476
}

‎tests/rustdoc/target-feature.rs‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#![crate_name = "foo"]
2+
3+
//@ has 'foo/index.html'
4+
5+
//@ has - '//dl[@class="item-table"]/dt[1]//a' 'f1_safe'
6+
//@ has - '//dl[@class="item-table"]/dt[1]//code' 'popcnt'
7+
//@ count - '//dl[@class="item-table"]/dt[1]//sup' 0
8+
//@ has - '//dl[@class="item-table"]/dt[2]//a' 'f2_not_safe'
9+
//@ has - '//dl[@class="item-table"]/dt[2]//code' 'avx2'
10+
//@ count - '//dl[@class="item-table"]/dt[2]//sup' 1
11+
//@ has - '//dl[@class="item-table"]/dt[2]//sup' '⚠'
12+
13+
#[target_feature(enable = "popcnt")]
14+
//@ has 'foo/fn.f1_safe.html'
15+
//@ matches - '//pre[@class="rust item-decl"]' '^pub fn f1_safe'
16+
//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \
17+
// 'Available with target feature popcnt only.'
18+
pub fn f1_safe() {}
19+
20+
//@ has 'foo/fn.f2_not_safe.html'
21+
//@ matches - '//pre[@class="rust item-decl"]' '^pub unsafe fn f2_not_safe()'
22+
//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \
23+
// 'Available with target feature avx2 only.'
24+
#[target_feature(enable = "avx2")]
25+
pub unsafe fn f2_not_safe() {}
26+
27+
//@ has 'foo/fn.f3_multifeatures_in_attr.html'
28+
//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \
29+
// 'Available on target features popcnt and avx2 only.'
30+
#[target_feature(enable = "popcnt", enable = "avx2")]
31+
pub fn f3_multifeatures_in_attr() {}
32+
33+
//@ has 'foo/fn.f4_multi_attrs.html'
34+
//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \
35+
// 'Available on target features popcnt and avx2 only.'
36+
#[target_feature(enable = "popcnt")]
37+
#[target_feature(enable = "avx2")]
38+
pub fn f4_multi_attrs() {}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /