Skip to content

Commit f6406f7

Browse files
authored
Rollup merge of #68397 - ollie27:rustdoc_async_unsafe, r=Centril
rustdoc: Correct order of `async` and `unsafe` in `async unsafe fn`s The order was swapped in #61319 but rustdoc was never updated to match. r? @GuillaumeGomez
2 parents 32ecb6f + 3e0bfe1 commit f6406f7

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/librustdoc/html/render.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2321,8 +2321,8 @@ fn item_function(w: &mut Buffer, cx: &Context, it: &clean::Item, f: &clean::Func
23212321
"{}{}{}{}{:#}fn {}{:#}",
23222322
it.visibility.print_with_space(),
23232323
f.header.constness.print_with_space(),
2324-
f.header.unsafety.print_with_space(),
23252324
f.header.asyncness.print_with_space(),
2325+
f.header.unsafety.print_with_space(),
23262326
print_abi_with_space(f.header.abi),
23272327
it.name.as_ref().unwrap(),
23282328
f.generics.print()
@@ -2332,12 +2332,12 @@ fn item_function(w: &mut Buffer, cx: &Context, it: &clean::Item, f: &clean::Func
23322332
render_attributes(w, it, false);
23332333
write!(
23342334
w,
2335-
"{vis}{constness}{unsafety}{asyncness}{abi}fn \
2335+
"{vis}{constness}{asyncness}{unsafety}{abi}fn \
23362336
{name}{generics}{decl}{where_clause}</pre>",
23372337
vis = it.visibility.print_with_space(),
23382338
constness = f.header.constness.print_with_space(),
2339-
unsafety = f.header.unsafety.print_with_space(),
23402339
asyncness = f.header.asyncness.print_with_space(),
2340+
unsafety = f.header.unsafety.print_with_space(),
23412341
abi = print_abi_with_space(f.header.abi),
23422342
name = it.name.as_ref().unwrap(),
23432343
generics = f.generics.print(),
@@ -2832,8 +2832,8 @@ fn render_assoc_item(
28322832
"{}{}{}{}{}{:#}fn {}{:#}",
28332833
meth.visibility.print_with_space(),
28342834
header.constness.print_with_space(),
2835-
header.unsafety.print_with_space(),
28362835
header.asyncness.print_with_space(),
2836+
header.unsafety.print_with_space(),
28372837
print_default_space(meth.is_default()),
28382838
print_abi_with_space(header.abi),
28392839
name,
@@ -2854,8 +2854,8 @@ fn render_assoc_item(
28542854
if parent == ItemType::Trait { " " } else { "" },
28552855
meth.visibility.print_with_space(),
28562856
header.constness.print_with_space(),
2857-
header.unsafety.print_with_space(),
28582857
header.asyncness.print_with_space(),
2858+
header.unsafety.print_with_space(),
28592859
print_default_space(meth.is_default()),
28602860
print_abi_with_space(header.abi),
28612861
href = href,

src/test/rustdoc/async-fn.rs

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ pub async fn baz<T>(a: T) -> T {
1515
a
1616
}
1717

18+
// @has async_fn/fn.qux.html '//pre[@class="rust fn"]' 'pub async unsafe fn qux() -> char'
19+
pub async unsafe fn qux() -> char {
20+
'⚠'
21+
}
22+
1823
trait Bar {}
1924

2025
impl Bar for () {}
@@ -26,8 +31,10 @@ pub async fn quux() -> impl Bar {
2631

2732
// @has async_fn/struct.Foo.html
2833
// @matches - '//code' 'pub async fn f\(\)$'
34+
// @matches - '//code' 'pub async unsafe fn g\(\)$'
2935
pub struct Foo;
3036

3137
impl Foo {
3238
pub async fn f() {}
39+
pub async unsafe fn g() {}
3340
}

0 commit comments

Comments
 (0)