Skip to content

Special case for empty comments in doc comment kind #4134

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
Apr 25, 2020

Conversation

edwin0cheng
Copy link
Member

@edwin0cheng edwin0cheng commented Apr 25, 2020

Part of #4103

Fix ui/empty/empty-comment.rs macros

@edwin0cheng edwin0cheng requested a review from matklad April 25, 2020 09:39
@matklad
Copy link
Member

matklad commented Apr 25, 2020

bors r+

I wonder though, if we can/need fix something on the macro side as well.. It seems weird that macro non-panicing depends on an impl details of a function elsewhere. Perhaps we can lift some invariants to types or something...

bors bot added a commit that referenced this pull request Apr 25, 2020
4134: Special case for empty comments in doc comment kind  r=matklad a=edwin0cheng

Part of #4103

Fix `ui/empty/empty-comment.rs macros`

Co-authored-by: Edwin Cheng <[email protected]>
@bors
Copy link
Contributor

bors bot commented Apr 25, 2020

Build failed:

@edwin0cheng
Copy link
Member Author

I wonder though, if we can/need fix something on the macro side as well.. It seems weird that macro non-panicing depends on an impl details of a function elsewhere. Perhaps we can lift some invariants to types or something...

The panic is actually raised by here:

https://github.com/rust-analyzer/rust-analyzer/blob/f654f4943552888c2b8f079cf687970268d81f18/crates/ra_mbe/src/syntax_bridge.rs#L164-L177

It bascially try to convert a comment text to #[doc(sth)] , I think we could move this logic to ast::make ?

@edwin0cheng
Copy link
Member Author

bors retry

@bors
Copy link
Contributor

bors bot commented Apr 25, 2020

@bors bors bot merged commit 7bc7173 into rust-lang:master Apr 25, 2020
@edwin0cheng edwin0cheng deleted the special-cast-empty-comments branch April 25, 2020 11:26
@matklad
Copy link
Member

matklad commented Apr 25, 2020

So, I think semantically what we do here is that we extract contents of the comment. We have DocCommentsOwner::doc_comment_text which does a similar job. I probably would expect an ast::Comment::contents() -> String method to be used to implement both getting docs (which is stiched form many line comments) and for lowering doc comemnts to attributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants