Auto merge of #44892 - GuillaumeGomez:fnty-args-rustdoc, r=eddyb

Fnty args rustdoc

Fixes #44570.

cc @QuietMisdreavus
cc @rust-lang/dev-tools

Considering the impact on the `hir` libs, I'll put @eddyb as reviewer.

r? @eddyb
This commit is contained in:
bors 2017-10-07 19:39:31 +00:00
commit 05f8ddc46a
6 changed files with 25 additions and 5 deletions

View file

@ -673,6 +673,7 @@ impl<'a> LoweringContext<'a> {
unsafety: self.lower_unsafety(f.unsafety),
abi: f.abi,
decl: self.lower_fn_decl(&f.decl),
arg_names: self.lower_fn_args_to_names(&f.decl),
}))
}
TyKind::Never => hir::TyNever,

View file

@ -1418,6 +1418,7 @@ pub struct BareFnTy {
pub abi: Abi,
pub lifetimes: HirVec<LifetimeDef>,
pub decl: P<FnDecl>,
pub arg_names: HirVec<Spanned<Name>>,
}
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]

View file

@ -399,7 +399,8 @@ impl<'a> State<'a> {
},
span: syntax_pos::DUMMY_SP,
};
self.print_ty_fn(f.abi, f.unsafety, &f.decl, None, &generics)?;
self.print_ty_fn(f.abi, f.unsafety, &f.decl, None, &generics,
&f.arg_names[..])?;
}
hir::TyPath(ref qpath) => {
self.print_qpath(qpath, false)?
@ -2140,7 +2141,8 @@ impl<'a> State<'a> {
unsafety: hir::Unsafety,
decl: &hir::FnDecl,
name: Option<ast::Name>,
generics: &hir::Generics)
generics: &hir::Generics,
arg_names: &[Spanned<ast::Name>])
-> io::Result<()> {
self.ibox(indent_unit)?;
if !generics.lifetimes.is_empty() || !generics.ty_params.is_empty() {
@ -2163,7 +2165,7 @@ impl<'a> State<'a> {
name,
&generics,
&hir::Inherited,
&[],
arg_names,
None)?;
self.end()
}

View file

@ -274,7 +274,8 @@ impl_stable_hash_for!(struct hir::BareFnTy {
unsafety,
abi,
lifetimes,
decl
decl,
arg_names
});
impl_stable_hash_for!(enum hir::Ty_ {

View file

@ -2491,7 +2491,7 @@ impl Clean<BareFunctionDecl> for hir::BareFnTy {
type_params: Vec::new(),
where_predicates: Vec::new()
},
decl: (&*self.decl, &[][..]).clean(cx),
decl: (&*self.decl, &self.arg_names[..]).clean(cx),
abi: self.abi,
}
}

View file

@ -0,0 +1,15 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![crate_name = "foo"]
// @has foo/fn.f.html
// @has - '//*[@class="rust fn"]' 'pub fn f(callback: fn(len: usize, foo: u32))'
pub fn f(callback: fn(len: usize, foo: u32)) {}