4280: Add documents owner for ImplDef and SourceFile r=matklad a=edwin0cheng

When working on #3182, I found that `ImplDef` and `SourceFile` do not implemet `DocCommentsOwer` trait, and I tested it in `cargo doc` that `impl` could has some doc-comments.

I am not so sure about `SourceFile` case, but in theory if that file is a crate root, the doc comment of it should represent the whole crate documentation, right ?

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
This commit is contained in:
bors[bot] 2020-05-03 10:46:07 +00:00 committed by GitHub
commit baa35b02b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -12,6 +12,7 @@ pub struct SourceFile {
}
impl ast::ModuleItemOwner for SourceFile {}
impl ast::AttrsOwner for SourceFile {}
impl ast::DocCommentsOwner for SourceFile {}
impl SourceFile {
pub fn modules(&self) -> AstChildren<Module> { support::children(&self.syntax) }
}
@ -259,6 +260,7 @@ pub struct ImplDef {
}
impl ast::TypeParamsOwner for ImplDef {}
impl ast::AttrsOwner for ImplDef {}
impl ast::DocCommentsOwner for ImplDef {}
impl ImplDef {
pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }

View file

@ -305,7 +305,7 @@ macro_rules! ast_enums {
pub(crate) const AST_SRC: AstSrc = AstSrc {
tokens: &["Whitespace", "Comment", "String", "RawString"],
nodes: &ast_nodes! {
struct SourceFile: ModuleItemOwner, AttrsOwner {
struct SourceFile: ModuleItemOwner, AttrsOwner, DocCommentsOwner {
modules: [Module],
}
@ -401,7 +401,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
T![;]
}
struct ImplDef: TypeParamsOwner, AttrsOwner {
struct ImplDef: TypeParamsOwner, AttrsOwner, DocCommentsOwner {
T![default],
T![const],
T![unsafe],