From 73fc05fdca348a899c78f527d08f323cd582100d Mon Sep 17 00:00:00 2001 From: oxalica Date: Tue, 16 Mar 2021 01:24:21 +0800 Subject: Pretty print root module of extern crates --- crates/hir/src/display.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'crates/hir') diff --git a/crates/hir/src/display.rs b/crates/hir/src/display.rs index e3660442c..44cdcc296 100644 --- a/crates/hir/src/display.rs +++ b/crates/hir/src/display.rs @@ -431,6 +431,10 @@ impl HirDisplay for Module { // FIXME: Module doesn't have visibility saved in data. match self.name(f.db) { Some(name) => write!(f, "mod {}", name), + None if self.crate_root(f.db) == *self => match self.krate().display_name(f.db) { + Some(name) => write!(f, "extern crate {}", name), + None => write!(f, "extern crate {{unknown}}"), + }, None => write!(f, "mod {{unnamed}}"), } } -- cgit v1.2.3