Skip to content

Commit 03b886d

Browse files
bors[bot]Veykril
andauthored
Merge #6719
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 <[email protected]>
2 parents 8a950df + a1c8bde commit 03b886d

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

crates/ide/src/folding_ranges.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ pub(crate) fn folding_ranges(file: &SourceFile) -> Vec<Fold> {
8383
fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> {
8484
match kind {
8585
COMMENT => Some(FoldKind::Comment),
86-
USE => Some(FoldKind::Imports),
8786
ARG_LIST | PARAM_LIST => Some(FoldKind::ArgList),
8887
ASSOC_ITEM_LIST
8988
| RECORD_FIELD_LIST
@@ -258,11 +257,11 @@ fn main() <fold block>{
258257
fn test_fold_imports() {
259258
check(
260259
r#"
261-
<fold imports>use std::<fold block>{
260+
use std::<fold block>{
262261
str,
263262
vec,
264263
io as iop
265-
}</fold>;</fold>
264+
}</fold>;
266265
267266
fn main() <fold block>{
268267
}</fold>"#,
@@ -306,9 +305,9 @@ use std::io as iop;</fold>
306305
<fold imports>use std::mem;
307306
use std::f64;</fold>
308307
309-
use std::collections::HashMap;
308+
<fold imports>use std::collections::HashMap;
310309
// Some random comment
311-
use std::collections::VecDeque;
310+
use std::collections::VecDeque;</fold>
312311
313312
fn main() <fold block>{
314313
}</fold>"#,
@@ -326,10 +325,10 @@ use std::io as iop;</fold>
326325
<fold imports>use std::mem;
327326
use std::f64;</fold>
328327
329-
<fold imports>use std::collections::<fold block>{
328+
use std::collections::<fold block>{
330329
HashMap,
331330
VecDeque,
332-
}</fold>;</fold>
331+
}</fold>;
333332
// Some random comment
334333
335334
fn main() <fold block>{

crates/syntax/src/ast/node_ext.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,3 +477,4 @@ impl ast::DocCommentsOwner for ast::Const {}
477477
impl ast::DocCommentsOwner for ast::TypeAlias {}
478478
impl ast::DocCommentsOwner for ast::Impl {}
479479
impl ast::DocCommentsOwner for ast::MacroCall {}
480+
impl ast::DocCommentsOwner for ast::Use {}

crates/syntax/src/parsing/text_tree_sink.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn n_attached_trivias<'a>(
148148
) -> usize {
149149
match kind {
150150
MACRO_CALL | CONST | TYPE_ALIAS | STRUCT | ENUM | VARIANT | FN | TRAIT | MODULE
151-
| RECORD_FIELD | STATIC => {
151+
| RECORD_FIELD | STATIC | USE => {
152152
let mut res = 0;
153153
let mut trivias = trivias.enumerate().peekable();
154154

crates/syntax/test_data/parser/inline/ok/0002_use_tree_list.rast

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ [email protected]
4949
5050
5151
52-
COMMENT@59..97 "// Rust 2018 (with a ..."
53-
54-
52+
USE@59..121
53+
[email protected] "// Rust 2018 (with a ..."
54+
5555
5656
5757
@@ -75,9 +75,9 @@ [email protected]
7575
7676
7777
78-
COMMENT@122..134 "// Rust 2015"
79-
80-
78+
USE@122..166
79+
[email protected] "// Rust 2015"
80+
8181
8282
8383
@@ -102,9 +102,9 @@ [email protected]
102102
103103
104104
105-
COMMENT@167..179 "// Rust 2015"
106-
107-
105+
USE@167..205
106+
[email protected] "// Rust 2015"
107+
108108
109109
110110

crates/syntax/test_data/parser/inline/ok/0110_use_path.rast

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ [email protected]
1010
[email protected] "crate_name"
1111
1212
13-
COMMENT@18..45 "// Rust 2018 - All fl ..."
14-
15-
13+
USE@18..61
14+
[email protected] "// Rust 2018 - All fl ..."
15+
1616
1717
1818
@@ -22,9 +22,9 @@ [email protected]
2222
[email protected] "crate_name"
2323
2424
25-
COMMENT@62..91 "// Rust 2018 - Anchor ..."
26-
27-
25+
USE@62..124
26+
[email protected] "// Rust 2018 - Anchor ..."
27+
2828
2929
3030

0 commit comments

Comments
 (0)