6719: Use items can also have doc comments r=matklad a=Veykril

Prior to this change modules show more docs than they have cause they inherit the docs from documented use items inside of them.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2020-12-07 18:48:35 +00:00 committed by GitHub
commit 03b886de53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 23 deletions

View file

@ -83,7 +83,6 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> {
fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> { fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> {
match kind { match kind {
COMMENT => Some(FoldKind::Comment), COMMENT => Some(FoldKind::Comment),
USE => Some(FoldKind::Imports),
ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList), ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList),
ASSOC_ITEM_LIST ASSOC_ITEM_LIST
| RECORD_FIELD_LIST | RECORD_FIELD_LIST
@ -258,11 +257,11 @@ fn main() <fold block>{
fn test_fold_imports() { fn test_fold_imports() {
check( check(
r#" r#"
<fold imports>use std::<fold block>{ use std::<fold block>{
str, str,
vec, vec,
io as iop io as iop
}</fold>;</fold> }</fold>;
fn main() <fold block>{ fn main() <fold block>{
}</fold>"#, }</fold>"#,
@ -306,9 +305,9 @@ use std::io as iop;</fold>
<fold imports>use std::mem; <fold imports>use std::mem;
use std::f64;</fold> use std::f64;</fold>
use std::collections::HashMap; <fold imports>use std::collections::HashMap;
// Some random comment // Some random comment
use std::collections::VecDeque; use std::collections::VecDeque;</fold>
fn main() <fold block>{ fn main() <fold block>{
}</fold>"#, }</fold>"#,
@ -326,10 +325,10 @@ use std::io as iop;</fold>
<fold imports>use std::mem; <fold imports>use std::mem;
use std::f64;</fold> use std::f64;</fold>
<fold imports>use std::collections::<fold block>{ use std::collections::<fold block>{
HashMap, HashMap,
VecDeque, VecDeque,
}</fold>;</fold> }</fold>;
// Some random comment // Some random comment
fn main() <fold block>{ fn main() <fold block>{

View file

@ -477,3 +477,4 @@ impl ast::DocCommentsOwner for ast::Const {}
impl ast::DocCommentsOwner for ast::TypeAlias {} impl ast::DocCommentsOwner for ast::TypeAlias {}
impl ast::DocCommentsOwner for ast::Impl {} impl ast::DocCommentsOwner for ast::Impl {}
impl ast::DocCommentsOwner for ast::MacroCall {} impl ast::DocCommentsOwner for ast::MacroCall {}
impl ast::DocCommentsOwner for ast::Use {}

View file

@ -148,7 +148,7 @@ fn n_attached_trivias<'a>(
) -> usize { ) -> usize {
match kind { match kind {
MACRO_CALL | CONST | TYPE_ALIAS | STRUCT | ENUM | VARIANT | FN | TRAIT | MODULE MACRO_CALL | CONST | TYPE_ALIAS | STRUCT | ENUM | VARIANT | FN | TRAIT | MODULE
| RECORD_FIELD | STATIC => { | RECORD_FIELD | STATIC | USE => {
let mut res = 0; let mut res = 0;
let mut trivias = trivias.enumerate().peekable(); let mut trivias = trivias.enumerate().peekable();

View file

@ -49,9 +49,9 @@ SOURCE_FILE@0..249
R_CURLY@56..57 "}" R_CURLY@56..57 "}"
SEMICOLON@57..58 ";" SEMICOLON@57..58 ";"
WHITESPACE@58..59 " " WHITESPACE@58..59 " "
USE@59..121
COMMENT@59..97 "// Rust 2018 (with a ..." COMMENT@59..97 "// Rust 2018 (with a ..."
WHITESPACE@97..98 "\n" WHITESPACE@97..98 "\n"
USE@98..121
USE_KW@98..101 "use" USE_KW@98..101 "use"
WHITESPACE@101..102 " " WHITESPACE@101..102 " "
USE_TREE@102..120 USE_TREE@102..120
@ -75,9 +75,9 @@ SOURCE_FILE@0..249
R_CURLY@119..120 "}" R_CURLY@119..120 "}"
SEMICOLON@120..121 ";" SEMICOLON@120..121 ";"
WHITESPACE@121..122 " " WHITESPACE@121..122 " "
USE@122..166
COMMENT@122..134 "// Rust 2015" COMMENT@122..134 "// Rust 2015"
WHITESPACE@134..135 "\n" WHITESPACE@134..135 "\n"
USE@135..166
USE_KW@135..138 "use" USE_KW@135..138 "use"
WHITESPACE@138..139 " " WHITESPACE@138..139 " "
USE_TREE@139..165 USE_TREE@139..165
@ -102,9 +102,9 @@ SOURCE_FILE@0..249
R_CURLY@164..165 "}" R_CURLY@164..165 "}"
SEMICOLON@165..166 ";" SEMICOLON@165..166 ";"
WHITESPACE@166..167 " " WHITESPACE@166..167 " "
USE@167..205
COMMENT@167..179 "// Rust 2015" COMMENT@167..179 "// Rust 2015"
WHITESPACE@179..180 "\n" WHITESPACE@179..180 "\n"
USE@180..205
USE_KW@180..183 "use" USE_KW@180..183 "use"
WHITESPACE@183..184 " " WHITESPACE@183..184 " "
USE_TREE@184..204 USE_TREE@184..204

View file

@ -10,9 +10,9 @@ SOURCE_FILE@0..154
IDENT@6..16 "crate_name" IDENT@6..16 "crate_name"
SEMICOLON@16..17 ";" SEMICOLON@16..17 ";"
WHITESPACE@17..18 " " WHITESPACE@17..18 " "
USE@18..61
COMMENT@18..45 "// Rust 2018 - All fl ..." COMMENT@18..45 "// Rust 2018 - All fl ..."
WHITESPACE@45..46 "\n" WHITESPACE@45..46 "\n"
USE@46..61
USE_KW@46..49 "use" USE_KW@46..49 "use"
WHITESPACE@49..50 " " WHITESPACE@49..50 " "
USE_TREE@50..60 USE_TREE@50..60
@ -22,9 +22,9 @@ SOURCE_FILE@0..154
IDENT@50..60 "crate_name" IDENT@50..60 "crate_name"
SEMICOLON@60..61 ";" SEMICOLON@60..61 ";"
WHITESPACE@61..62 " " WHITESPACE@61..62 " "
USE@62..124
COMMENT@62..91 "// Rust 2018 - Anchor ..." COMMENT@62..91 "// Rust 2018 - Anchor ..."
WHITESPACE@91..92 "\n" WHITESPACE@91..92 "\n"
USE@92..124
USE_KW@92..95 "use" USE_KW@92..95 "use"
WHITESPACE@95..96 " " WHITESPACE@95..96 " "
USE_TREE@96..123 USE_TREE@96..123