Skip to content

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

Merged
merged 2 commits into from
Oct 7, 2017
Merged

Fnty args rustdoc #44892

merged 2 commits into from
Oct 7, 2017

Conversation

GuillaumeGomez
Copy link
Member

Fixes #44570.

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

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

r? @eddyb

@aidanhs aidanhs added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 28, 2017
@@ -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>>),
Copy link
Member

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.

Copy link
Member Author

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.

@GuillaumeGomez
Copy link
Member Author

Updated.

@@ -1412,6 +1412,7 @@ pub struct BareFnTy {
pub abi: Abi,
pub lifetimes: HirVec<LifetimeDef>,
pub decl: P<FnDecl>,
pub args_name: HirVec<Spanned<Name>>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arg_names

@@ -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>) {
Copy link
Member

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...

@@ -1927,7 +1940,34 @@ impl Clean<Type> for hir::Ty {
_ => Infer // shouldn't happen
}
}
TyBareFn(ref barefn) => BareFunction(box barefn.clean(cx)),
Copy link
Member

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.

@GuillaumeGomez
Copy link
Member Author

Updated.

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,
Copy link
Member

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),
Copy link
Member

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.

Copy link
Member Author

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`

Copy link
Member

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?

Copy link
Member

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.

@GuillaumeGomez GuillaumeGomez force-pushed the fnty-args-rustdoc branch 2 times, most recently from 1b80222 to 56c3dda Compare October 7, 2017 14:51
@GuillaumeGomez
Copy link
Member Author

Updated.

@eddyb
Copy link
Member

eddyb commented Oct 7, 2017

@bors r+

@bors
Copy link
Collaborator

bors commented Oct 7, 2017

📌 Commit fe24e81 has been approved by eddyb

@bors
Copy link
Collaborator

bors commented Oct 7, 2017

⌛ Testing commit fe24e81 with merge 05f8ddc...

bors added a commit that referenced this pull request Oct 7, 2017
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
@bors
Copy link
Collaborator

bors commented Oct 7, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: eddyb
Pushing 05f8ddc to master...

@bors bors merged commit fe24e81 into rust-lang:master Oct 7, 2017
@GuillaumeGomez GuillaumeGomez deleted the fnty-args-rustdoc branch October 8, 2017 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants