Skip to content

Commit 05f8ddc

Browse files
committedOct 7, 2017
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
2 parents bb4d149 + fe24e81 commit 05f8ddc

File tree

6 files changed

+25
-5
lines changed

6 files changed

+25
-5
lines changed
 

‎src/librustc/hir/lowering.rs

+1
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,7 @@ impl<'a> LoweringContext<'a> {
673673
unsafety: self.lower_unsafety(f.unsafety),
674674
abi: f.abi,
675675
decl: self.lower_fn_decl(&f.decl),
676+
arg_names: self.lower_fn_args_to_names(&f.decl),
676677
}))
677678
}
678679
TyKind::Never => hir::TyNever,

‎src/librustc/hir/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,7 @@ pub struct BareFnTy {
14181418
pub abi: Abi,
14191419
pub lifetimes: HirVec<LifetimeDef>,
14201420
pub decl: P<FnDecl>,
1421+
pub arg_names: HirVec<Spanned<Name>>,
14211422
}
14221423

14231424
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]

‎src/librustc/hir/print.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,8 @@ impl<'a> State<'a> {
399399
},
400400
span: syntax_pos::DUMMY_SP,
401401
};
402-
self.print_ty_fn(f.abi, f.unsafety, &f.decl, None, &generics)?;
402+
self.print_ty_fn(f.abi, f.unsafety, &f.decl, None, &generics,
403+
&f.arg_names[..])?;
403404
}
404405
hir::TyPath(ref qpath) => {
405406
self.print_qpath(qpath, false)?
@@ -2140,7 +2141,8 @@ impl<'a> State<'a> {
21402141
unsafety: hir::Unsafety,
21412142
decl: &hir::FnDecl,
21422143
name: Option<ast::Name>,
2143-
generics: &hir::Generics)
2144+
generics: &hir::Generics,
2145+
arg_names: &[Spanned<ast::Name>])
21442146
-> io::Result<()> {
21452147
self.ibox(indent_unit)?;
21462148
if !generics.lifetimes.is_empty() || !generics.ty_params.is_empty() {
@@ -2163,7 +2165,7 @@ impl<'a> State<'a> {
21632165
name,
21642166
&generics,
21652167
&hir::Inherited,
2166-
&[],
2168+
arg_names,
21672169
None)?;
21682170
self.end()
21692171
}

‎src/librustc/ich/impls_hir.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ impl_stable_hash_for!(struct hir::BareFnTy {
274274
unsafety,
275275
abi,
276276
lifetimes,
277-
decl
277+
decl,
278+
arg_names
278279
});
279280

280281
impl_stable_hash_for!(enum hir::Ty_ {

‎src/librustdoc/clean/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2491,7 +2491,7 @@ impl Clean<BareFunctionDecl> for hir::BareFnTy {
24912491
type_params: Vec::new(),
24922492
where_predicates: Vec::new()
24932493
},
2494-
decl: (&*self.decl, &[][..]).clean(cx),
2494+
decl: (&*self.decl, &self.arg_names[..]).clean(cx),
24952495
abi: self.abi,
24962496
}
24972497
}
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_name = "foo"]
12+
13+
// @has foo/fn.f.html
14+
// @has - '//*[@class="rust fn"]' 'pub fn f(callback: fn(len: usize, foo: u32))'
15+
pub fn f(callback: fn(len: usize, foo: u32)) {}

0 commit comments

Comments
 (0)
Please sign in to comment.