diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-01-20 22:07:38 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-01-20 22:07:38 +0000 |
commit | 70f7a10013775c1dce10b0d7a7724a48bb76b065 (patch) | |
tree | 2f3c97e5f45a8579cc860dc9a57123dbb5302b8b /crates/ide/src/display | |
parent | 7d5ed18c42c4ee80e776d04254d69750b70e14ba (diff) | |
parent | 82146737acc74b2483f39f1dd0ae4dfffcfda824 (diff) |
Merge #7366
7366: Treat BlockExpr as a potential module origin r=jonas-schievink a=jonas-schievink
A block containing inner items acts like the root module of a crate, so it needs to be representable as a `ModuleSource` and `ModuleOrigin`.
Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/ide/src/display')
-rw-r--r-- | crates/ide/src/display/navigation_target.rs | 1 | ||||
-rw-r--r-- | crates/ide/src/display/short_label.rs | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs index 671aa1373..9c568c90c 100644 --- a/crates/ide/src/display/navigation_target.rs +++ b/crates/ide/src/display/navigation_target.rs | |||
@@ -294,6 +294,7 @@ impl ToNav for hir::Module { | |||
294 | ModuleSource::Module(node) => { | 294 | ModuleSource::Module(node) => { |
295 | (node.syntax(), node.name().map(|it| it.syntax().text_range())) | 295 | (node.syntax(), node.name().map(|it| it.syntax().text_range())) |
296 | } | 296 | } |
297 | ModuleSource::BlockExpr(node) => (node.syntax(), None), | ||
297 | }; | 298 | }; |
298 | let frange = src.with_value(syntax).original_file_range(db); | 299 | let frange = src.with_value(syntax).original_file_range(db); |
299 | NavigationTarget::from_syntax(frange.file_id, name, focus, frange.range, SymbolKind::Module) | 300 | NavigationTarget::from_syntax(frange.file_id, name, focus, frange.range, SymbolKind::Module) |
diff --git a/crates/ide/src/display/short_label.rs b/crates/ide/src/display/short_label.rs index b8e4cc181..7ac050473 100644 --- a/crates/ide/src/display/short_label.rs +++ b/crates/ide/src/display/short_label.rs | |||
@@ -53,6 +53,12 @@ impl ShortLabel for ast::SourceFile { | |||
53 | } | 53 | } |
54 | } | 54 | } |
55 | 55 | ||
56 | impl ShortLabel for ast::BlockExpr { | ||
57 | fn short_label(&self) -> Option<String> { | ||
58 | None | ||
59 | } | ||
60 | } | ||
61 | |||
56 | impl ShortLabel for ast::TypeAlias { | 62 | impl ShortLabel for ast::TypeAlias { |
57 | fn short_label(&self) -> Option<String> { | 63 | fn short_label(&self) -> Option<String> { |
58 | short_label_from_node(self, "type ") | 64 | short_label_from_node(self, "type ") |