From 059ed25a3eea97f370c190803318d5cb7885e1a9 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 16 Mar 2020 11:47:52 +0200 Subject: Fix crate display name dashes --- crates/ra_ide/src/hover.rs | 27 ++++++++++++++++----------- crates/ra_ide/src/mock_analysis.rs | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) (limited to 'crates/ra_ide/src') diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index 3bdd61a2e..d1deca96b 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -94,17 +94,22 @@ fn definition_owner_name(db: &RootDatabase, def: &Definition) -> Option fn determine_mod_path(db: &RootDatabase, def: &Definition) -> Option { let mod_path = def.module(db).map(|module| { - once(db.crate_graph()[module.krate().into()].display_name.clone()) - .chain( - module - .path_to_root(db) - .into_iter() - .rev() - .map(|it| it.name(db).map(|name| name.to_string())), - ) - .chain(once(definition_owner_name(db, def))) - .flatten() - .join("::") + once( + db.crate_graph()[module.krate().into()] + .display_name + .as_ref() + .map(|name| name.get_name()), + ) + .chain( + module + .path_to_root(db) + .into_iter() + .rev() + .map(|it| it.name(db).map(|name| name.to_string())), + ) + .chain(once(definition_owner_name(db, def))) + .flatten() + .join("::") }); mod_path // FIXME: replace dashes with underscores in crate display name } diff --git a/crates/ra_ide/src/mock_analysis.rs b/crates/ra_ide/src/mock_analysis.rs index 25816cf6f..2cf77a31f 100644 --- a/crates/ra_ide/src/mock_analysis.rs +++ b/crates/ra_ide/src/mock_analysis.rs @@ -109,7 +109,7 @@ impl MockAnalysis { let other_crate = crate_graph.add_crate_root( file_id, Edition2018, - Some(crate_name.to_owned()), + Some(CrateName::new(crate_name).unwrap()), cfg_options, Env::default(), Default::default(), -- cgit v1.2.3