Skip to content

Commit

Permalink
Auto merge of #44892 - GuillaumeGomez:fnty-args-rustdoc, r=eddyb
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Oct 7, 2017
2 parents bb4d149 + fe24e81 commit 05f8ddc
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
8 changes: 5 additions & 3 deletions src/librustc/hir/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?
Expand Down Expand Up @@ -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() {
Expand All @@ -2163,7 +2165,7 @@ impl<'a> State<'a> {
name,
&generics,
&hir::Inherited,
&[],
arg_names,
None)?;
self.end()
}
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/ich/impls_hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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_ {
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/test/rustdoc/fn-pointer-arg-name.rs
Original file line number Diff line number Diff line change
@@ -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)) {}

0 comments on commit 05f8ddc

Please sign in to comment.