Handle and test wildcard arguments

This commit is contained in:
Joshua Nelson 2020-11-10 07:49:06 -05:00
parent 2baa0ceff4
commit 38127caf73
3 changed files with 11 additions and 3 deletions

View File

@ -1102,10 +1102,13 @@ fn lower_maybe_async_body(
ident,
_,
) => (ident, true),
// For `ref mut` arguments, we can't reuse the binding, but
// For `ref mut` or wildcard arguments, we can't reuse the binding, but
// we can keep the same name for the parameter.
// This lets rustdoc render it correctly in documentation.
hir::PatKind::Binding(_, _, ident, _) => (ident, false),
hir::PatKind::Wild => {
(Ident::with_dummy_span(rustc_span::symbol::kw::Underscore), false)
}
_ => {
// Replace the ident for bindings that aren't simple.
let name = format!("__arg{}", index);

View File

@ -1,4 +1,5 @@
// edition:2018
#![feature(min_const_generics)]
// @has async_fn/fn.foo.html '//pre[@class="rust fn"]' 'pub async fn foo() -> Option<Foo>'
pub async fn foo() -> Option<Foo> {
@ -46,3 +47,8 @@ pub async fn f() {}
pub async unsafe fn g() {}
pub async fn mut_self(mut self, mut first: usize) {}
}
pub trait Trait<const N: usize> {}
// @has async_fn/fn.const_generics.html
// @has - '//pre[@class="rust fn"]' 'pub async fn const_generics<const N: usize>(_: impl Trait<N>)'
pub async fn const_generics<const N: usize>(_: impl Trait<N>) {}

View File

@ -70,8 +70,7 @@ pub fn test<const N: usize>() -> impl Trait<N> where u8: Trait<N> {
}
// @has foo/fn.b_sink.html '//pre[@class="rust fn"]' \
// 'pub async fn b_sink<const N: usize>(__arg0: impl Trait<N>)'
// FIXME(const_generics): This should be `_` not `__arg0`.
// 'pub async fn b_sink<const N: usize>(_: impl Trait<N>)'
pub async fn b_sink<const N: usize>(_: impl Trait<N>) {}
// @has foo/fn.concrete.html '//pre[@class="rust fn"]' \