diff options
| author | Joshua Nelson <jyn514@gmail.com> | 2020-11-10 07:49:06 -0500 |
|---|---|---|
| committer | Joshua Nelson <jyn514@gmail.com> | 2020-11-12 11:14:29 -0500 |
| commit | 38127caf730ab6e99d3ea546db4c2df69229afba (patch) | |
| tree | 302dd644286e9ccd5e4707606ecab366cb15dc04 | |
| parent | 2baa0ceff4e6dc75751fdca4be68e87f5cf35a6e (diff) | |
| download | rust-38127caf730ab6e99d3ea546db4c2df69229afba.tar.gz rust-38127caf730ab6e99d3ea546db4c2df69229afba.zip | |
Handle and test wildcard arguments
| -rw-r--r-- | compiler/rustc_ast_lowering/src/item.rs | 5 | ||||
| -rw-r--r-- | src/test/rustdoc/async-fn.rs | 6 | ||||
| -rw-r--r-- | src/test/rustdoc/const-generics/const-generics-docs.rs | 3 |
3 files changed, 11 insertions, 3 deletions
diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index 1335bb02580..d353bc19f7a 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -1102,10 +1102,13 @@ impl<'hir> LoweringContext<'_, 'hir> { 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); diff --git a/src/test/rustdoc/async-fn.rs b/src/test/rustdoc/async-fn.rs index d7c89073829..e7a7d1831f7 100644 --- a/src/test/rustdoc/async-fn.rs +++ b/src/test/rustdoc/async-fn.rs @@ -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 @@ impl Foo { 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>) {} diff --git a/src/test/rustdoc/const-generics/const-generics-docs.rs b/src/test/rustdoc/const-generics/const-generics-docs.rs index 8dcba36600d..9c68e067c6f 100644 --- a/src/test/rustdoc/const-generics/const-generics-docs.rs +++ b/src/test/rustdoc/const-generics/const-generics-docs.rs @@ -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"]' \ -// '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"]' \ |
