]> git.lizzy.rs Git - rust.git/commitdiff
Better visibility check.
authorAndrea Pretto <eulerdisk@gmail.com>
Sat, 26 Jan 2019 12:21:41 +0000 (13:21 +0100)
committerAndrea Pretto <eulerdisk@gmail.com>
Sat, 26 Jan 2019 12:32:48 +0000 (13:32 +0100)
crates/ra_ide_api_light/src/folding_ranges.rs

index 0f2f1399b697276225d932f0d3f448930f3f7c5f..87feb9bd8d5fc5f69acd4dd4964226bf629998e3 100644 (file)
@@ -83,7 +83,11 @@ fn fold_kind(kind: SyntaxKind) -> Option<FoldKind> {
 }
 
 fn has_visibility(node: &SyntaxNode) -> bool {
-    return node.descendants().any(|n| n.kind() == VISIBILITY);
+    use ast::VisibilityOwner;
+
+    return ast::Module::cast(node)
+        .and_then(|m| m.visibility())
+        .is_some();
 }
 
 fn has_newline(node: &SyntaxNode) -> bool {