-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Fnty args rustdoc #44892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fnty args rustdoc #44892
Conversation
src/librustc/hir/mod.rs
Outdated
@@ -1426,7 +1426,7 @@ pub enum Ty_ { | |||
/// A reference (`&'a T` or `&'a mut T`) | |||
TyRptr(Lifetime, MutTy), | |||
/// A bare function (e.g. `fn(usize) -> bool`) | |||
TyBareFn(P<BareFnTy>), | |||
TyBareFn(P<BareFnTy>, HirVec<Spanned<Name>>), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we discussed it, you were supposed to put it in BareFnTy
. That should simplify things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah damn, got tricked by this message.
a644487
to
075c90a
Compare
Updated. |
src/librustc/hir/mod.rs
Outdated
@@ -1412,6 +1412,7 @@ pub struct BareFnTy { | |||
pub abi: Abi, | |||
pub lifetimes: HirVec<LifetimeDef>, | |||
pub decl: P<FnDecl>, | |||
pub args_name: HirVec<Spanned<Name>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arg_names
src/librustdoc/clean/mod.rs
Outdated
@@ -1244,12 +1244,25 @@ impl<'a> Clean<Arguments> for (&'a [P<hir::Ty>], hir::BodyId) { | |||
} | |||
} | |||
|
|||
impl<'a, A: Copy> Clean<FnDecl> for (&'a hir::FnDecl, A) | |||
impl<'a> Clean<Arguments> for (&'a [P<hir::Ty>], Vec<String>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing this impl
means you've done something wrong...
src/librustdoc/clean/mod.rs
Outdated
@@ -1927,7 +1940,34 @@ impl Clean<Type> for hir::Ty { | |||
_ => Infer // shouldn't happen | |||
} | |||
} | |||
TyBareFn(ref barefn) => BareFunction(box barefn.clean(cx)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BareFnTy
has its own Clean
impl, you should be changing that, not this - this is why I didn't want you to change the enum variant, but the struct.
075c90a
to
81c2eff
Compare
Updated. |
src/librustdoc/clean/mod.rs
Outdated
BareFunction(box BareFunctionDecl { | ||
unsafety: sig.unsafety(), | ||
generics: Generics { | ||
lifetimes: Vec::new(), | ||
type_params: Vec::new(), | ||
where_predicates: Vec::new() | ||
}, | ||
decl: (cx.tcx.hir.local_def_id(ast::CRATE_NODE_ID), sig).clean(cx), | ||
decl: decl, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this moved at all?
@@ -2491,7 +2505,23 @@ impl Clean<BareFunctionDecl> for hir::BareFnTy { | |||
type_params: Vec::new(), | |||
where_predicates: Vec::new() | |||
}, | |||
decl: (&*self.decl, &[][..]).clean(cx), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing impls are already powerful enough for this (unless I wasn't careful), all you need is to replace &[][..]
with &self.arg_names
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not exactly:
no method named `clean` found for type `(&rustc::hir::FnDecl, &syntax::ptr::P<[syntax::codemap::Spanned<syntax::ast::Symbol>]>)` in the current scope
--> src/librustdoc/clean/mod.rs:2507:50
|
2507 | decl: (&*self.decl, &self.arg_names).clean(cx),
| ^^^^^
|
= note: the method `clean` exists but the following trait bounds were not satisfied:
`(&[syntax::ptr::P<rustc::hir::Ty>], &syntax::ptr::P<[syntax::codemap::Spanned<syntax::ast::Symbol>]>) : clean::Clean<clean::Arguments>`
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `clean`, perhaps you need to implement it:
candidate #1: `clean::Clean`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like you need &self.arg_names[..]
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like, look for ForeignItemFn
, it starts off with the same information but it doesn't implement the cleaning itself.
1b80222
to
56c3dda
Compare
56c3dda
to
fe24e81
Compare
Updated. |
@bors r+ |
📌 Commit fe24e81 has been approved by |
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
☀️ Test successful - status-appveyor, status-travis |
Fixes #44570.
cc @QuietMisdreavus
cc @rust-lang/dev-tools
Considering the impact on the
hir
libs, I'll put @eddyb as reviewer.r? @eddyb