diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-12-30 07:45:33 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-30 07:45:33 +0000 |
commit | e7d2b5888b8a7e632ae9080108ccbc450316fd86 (patch) | |
tree | 721f9183ad55b80a77b1ae787e6e5f299def28ef /crates/syntax/src | |
parent | 848e817f603ed12e065bc3057d12e04b481fb5bb (diff) | |
parent | ddbf484acf15efd73b61ac80a941730b507c01de (diff) |
Merge #7088
7088: Smarter bracketed `use` diagnostic r=lnicola a=AdnoC
Closes https://github.com/rust-analyzer/rust-analyzer/issues/4531
Makes it so that if a bracketed use statement contains a comment inside the braces, no "Unnecessary braces in use statement" diagnostic is shown.
Co-authored-by: AdnoC <[email protected]>
Diffstat (limited to 'crates/syntax/src')
-rw-r--r-- | crates/syntax/src/ast/node_ext.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs index c45cb514a..2aa472fb4 100644 --- a/crates/syntax/src/ast/node_ext.rs +++ b/crates/syntax/src/ast/node_ext.rs | |||
@@ -193,6 +193,14 @@ impl ast::UseTreeList { | |||
193 | .and_then(ast::UseTree::cast) | 193 | .and_then(ast::UseTree::cast) |
194 | .expect("UseTreeLists are always nested in UseTrees") | 194 | .expect("UseTreeLists are always nested in UseTrees") |
195 | } | 195 | } |
196 | |||
197 | pub fn has_inner_comment(&self) -> bool { | ||
198 | self.syntax() | ||
199 | .children_with_tokens() | ||
200 | .filter_map(|it| it.into_token()) | ||
201 | .find_map(ast::Comment::cast) | ||
202 | .is_some() | ||
203 | } | ||
196 | } | 204 | } |
197 | 205 | ||
198 | impl ast::Impl { | 206 | impl ast::Impl { |