Pretty print root module of extern crates

This commit is contained in:
oxalica 2021-03-16 01:24:21 +08:00
parent 7c855c940a
commit 73fc05fdca
No known key found for this signature in database
GPG key ID: CED392DE0C483D00

View file

@ -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}}"),
}
}