mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 04:08:40 +00:00
Fix invalid rustdoc rendering for FnTy args
This commit is contained in:
parent
3493c62ff2
commit
fe24e815a2
@ -574,7 +574,7 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
|
|||||||
TyTup(ref tuple_element_types) => {
|
TyTup(ref tuple_element_types) => {
|
||||||
walk_list!(visitor, visit_ty, tuple_element_types);
|
walk_list!(visitor, visit_ty, tuple_element_types);
|
||||||
}
|
}
|
||||||
TyBareFn(ref function_declaration, _) => {
|
TyBareFn(ref function_declaration) => {
|
||||||
visitor.visit_fn_decl(&function_declaration.decl);
|
visitor.visit_fn_decl(&function_declaration.decl);
|
||||||
walk_list!(visitor, visit_lifetime_def, &function_declaration.lifetimes);
|
walk_list!(visitor, visit_lifetime_def, &function_declaration.lifetimes);
|
||||||
}
|
}
|
||||||
|
@ -673,15 +673,8 @@ impl<'a> LoweringContext<'a> {
|
|||||||
unsafety: self.lower_unsafety(f.unsafety),
|
unsafety: self.lower_unsafety(f.unsafety),
|
||||||
abi: f.abi,
|
abi: f.abi,
|
||||||
decl: self.lower_fn_decl(&f.decl),
|
decl: self.lower_fn_decl(&f.decl),
|
||||||
},
|
arg_names: self.lower_fn_args_to_names(&f.decl),
|
||||||
decl.inputs.iter().map(|arg| {
|
}))
|
||||||
match arg.pat.node {
|
|
||||||
PatKind::Ident(_, ident, None) => {
|
|
||||||
respan(ident.span, ident.node.name)
|
|
||||||
}
|
|
||||||
_ => respan(arg.pat.span, keywords::Invalid.name()),
|
|
||||||
}
|
|
||||||
}).collect()))
|
|
||||||
}
|
}
|
||||||
TyKind::Never => hir::TyNever,
|
TyKind::Never => hir::TyNever,
|
||||||
TyKind::Tup(ref tys) => {
|
TyKind::Tup(ref tys) => {
|
||||||
|
@ -1418,6 +1418,7 @@ pub struct BareFnTy {
|
|||||||
pub abi: Abi,
|
pub abi: Abi,
|
||||||
pub lifetimes: HirVec<LifetimeDef>,
|
pub lifetimes: HirVec<LifetimeDef>,
|
||||||
pub decl: P<FnDecl>,
|
pub decl: P<FnDecl>,
|
||||||
|
pub arg_names: HirVec<Spanned<Name>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
|
@ -399,7 +399,8 @@ impl<'a> State<'a> {
|
|||||||
},
|
},
|
||||||
span: syntax_pos::DUMMY_SP,
|
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) => {
|
hir::TyPath(ref qpath) => {
|
||||||
self.print_qpath(qpath, false)?
|
self.print_qpath(qpath, false)?
|
||||||
@ -2140,7 +2141,8 @@ impl<'a> State<'a> {
|
|||||||
unsafety: hir::Unsafety,
|
unsafety: hir::Unsafety,
|
||||||
decl: &hir::FnDecl,
|
decl: &hir::FnDecl,
|
||||||
name: Option<ast::Name>,
|
name: Option<ast::Name>,
|
||||||
generics: &hir::Generics)
|
generics: &hir::Generics,
|
||||||
|
arg_names: &[Spanned<ast::Name>])
|
||||||
-> io::Result<()> {
|
-> io::Result<()> {
|
||||||
self.ibox(indent_unit)?;
|
self.ibox(indent_unit)?;
|
||||||
if !generics.lifetimes.is_empty() || !generics.ty_params.is_empty() {
|
if !generics.lifetimes.is_empty() || !generics.ty_params.is_empty() {
|
||||||
@ -2163,7 +2165,7 @@ impl<'a> State<'a> {
|
|||||||
name,
|
name,
|
||||||
&generics,
|
&generics,
|
||||||
&hir::Inherited,
|
&hir::Inherited,
|
||||||
&[],
|
arg_names,
|
||||||
None)?;
|
None)?;
|
||||||
self.end()
|
self.end()
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,8 @@ impl_stable_hash_for!(struct hir::BareFnTy {
|
|||||||
unsafety,
|
unsafety,
|
||||||
abi,
|
abi,
|
||||||
lifetimes,
|
lifetimes,
|
||||||
decl
|
decl,
|
||||||
|
arg_names
|
||||||
});
|
});
|
||||||
|
|
||||||
impl_stable_hash_for!(enum hir::Ty_ {
|
impl_stable_hash_for!(enum hir::Ty_ {
|
||||||
|
@ -2491,7 +2491,7 @@ impl Clean<BareFunctionDecl> for hir::BareFnTy {
|
|||||||
type_params: Vec::new(),
|
type_params: Vec::new(),
|
||||||
where_predicates: Vec::new()
|
where_predicates: Vec::new()
|
||||||
},
|
},
|
||||||
decl: (&*self.decl, &[][..]).clean(cx),
|
decl: (&*self.decl, &self.arg_names[..]).clean(cx),
|
||||||
abi: self.abi,
|
abi: self.abi,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
src/test/rustdoc/fn-pointer-arg-name.rs
Normal file
15
src/test/rustdoc/fn-pointer-arg-name.rs
Normal 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)) {}
|
Loading…
Reference in New Issue
Block a user