1
Fork 0

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 @@ impl<'hir> LoweringContext<'_, 'hir> {
ident, ident,
_, _,
) => (ident, true), ) => (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. // we can keep the same name for the parameter.
// This lets rustdoc render it correctly in documentation. // This lets rustdoc render it correctly in documentation.
hir::PatKind::Binding(_, _, ident, _) => (ident, false), 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. // Replace the ident for bindings that aren't simple.
let name = format!("__arg{}", index); let name = format!("__arg{}", index);

View file

@ -1,4 +1,5 @@
// edition:2018 // edition:2018
#![feature(min_const_generics)]
// @has async_fn/fn.foo.html '//pre[@class="rust fn"]' 'pub async fn foo() -> Option<Foo>' // @has async_fn/fn.foo.html '//pre[@class="rust fn"]' 'pub async fn foo() -> Option<Foo>'
pub async fn foo() -> Option<Foo> { pub async fn foo() -> Option<Foo> {
@ -46,3 +47,8 @@ impl Foo {
pub async unsafe fn g() {} pub async unsafe fn g() {}
pub async fn mut_self(mut self, mut first: usize) {} 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 async fn a_sink<const N: usize>(v: [u8; N]) -> impl Trait<N> {
} }
// @has foo/fn.b_sink.html '//pre[@class="rust fn"]' \ // @has foo/fn.b_sink.html '//pre[@class="rust fn"]' \
// 'pub async fn b_sink<const N: usize>(__arg0: impl Trait<N>)' // 'pub async fn b_sink<const N: usize>(_: 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"]' \ // @has foo/fn.concrete.html '//pre[@class="rust fn"]' \