Skip to content

Commit 38127ca

Browse files
committed
Handle and test wildcard arguments
1 parent 2baa0ce commit 38127ca

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

compiler/rustc_ast_lowering/src/item.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1102,10 +1102,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
11021102
ident,
11031103
_,
11041104
) => (ident, true),
1105-
// For `ref mut` arguments, we can't reuse the binding, but
1105+
// For `ref mut` or wildcard arguments, we can't reuse the binding, but
11061106
// we can keep the same name for the parameter.
11071107
// This lets rustdoc render it correctly in documentation.
11081108
hir::PatKind::Binding(_, _, ident, _) => (ident, false),
1109+
hir::PatKind::Wild => {
1110+
(Ident::with_dummy_span(rustc_span::symbol::kw::Underscore), false)
1111+
}
11091112
_ => {
11101113
// Replace the ident for bindings that aren't simple.
11111114
let name = format!("__arg{}", index);

src/test/rustdoc/async-fn.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// edition:2018
2+
#![feature(min_const_generics)]
23

34
// @has async_fn/fn.foo.html '//pre[@class="rust fn"]' 'pub async fn foo() -> Option<Foo>'
45
pub async fn foo() -> Option<Foo> {
@@ -46,3 +47,8 @@ impl Foo {
4647
pub async unsafe fn g() {}
4748
pub async fn mut_self(mut self, mut first: usize) {}
4849
}
50+
51+
pub trait Trait<const N: usize> {}
52+
// @has async_fn/fn.const_generics.html
53+
// @has - '//pre[@class="rust fn"]' 'pub async fn const_generics<const N: usize>(_: impl Trait<N>)'
54+
pub async fn const_generics<const N: usize>(_: impl Trait<N>) {}

src/test/rustdoc/const-generics/const-generics-docs.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ pub async fn a_sink<const N: usize>(v: [u8; N]) -> impl Trait<N> {
7070
}
7171

7272
// @has foo/fn.b_sink.html '//pre[@class="rust fn"]' \
73-
// 'pub async fn b_sink<const N: usize>(__arg0: impl Trait<N>)'
74-
// FIXME(const_generics): This should be `_` not `__arg0`.
73+
// 'pub async fn b_sink<const N: usize>(_: impl Trait<N>)'
7574
pub async fn b_sink<const N: usize>(_: impl Trait<N>) {}
7675

7776
// @has foo/fn.concrete.html '//pre[@class="rust fn"]' \

0 commit comments

Comments
 (0)