mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-11 20:58:54 +00:00
Fix the hover dash issues
This commit is contained in:
parent
cae2e859ff
commit
99952f3be2
4 changed files with 10 additions and 9 deletions
|
@ -154,15 +154,15 @@ impl ChangeFixture {
|
||||||
assert!(meta.path.starts_with(&source_root_prefix));
|
assert!(meta.path.starts_with(&source_root_prefix));
|
||||||
|
|
||||||
if let Some(krate) = meta.krate {
|
if let Some(krate) = meta.krate {
|
||||||
|
let crate_name = CrateName::normalize_dashes(&krate);
|
||||||
let crate_id = crate_graph.add_crate_root(
|
let crate_id = crate_graph.add_crate_root(
|
||||||
file_id,
|
file_id,
|
||||||
meta.edition,
|
meta.edition,
|
||||||
Some(krate.clone()),
|
Some(crate_name.clone()),
|
||||||
meta.cfg,
|
meta.cfg,
|
||||||
meta.env,
|
meta.env,
|
||||||
Default::default(),
|
Default::default(),
|
||||||
);
|
);
|
||||||
let crate_name = CrateName::normalize_dashes(&krate);
|
|
||||||
let prev = crates.insert(crate_name.clone(), crate_id);
|
let prev = crates.insert(crate_name.clone(), crate_id);
|
||||||
assert!(prev.is_none());
|
assert!(prev.is_none());
|
||||||
for dep in meta.deps {
|
for dep in meta.deps {
|
||||||
|
@ -187,7 +187,7 @@ impl ChangeFixture {
|
||||||
crate_graph.add_crate_root(
|
crate_graph.add_crate_root(
|
||||||
crate_root,
|
crate_root,
|
||||||
Edition::Edition2018,
|
Edition::Edition2018,
|
||||||
Some("test".to_string()),
|
Some(CrateName::new("test").unwrap()),
|
||||||
default_cfg,
|
default_cfg,
|
||||||
Env::default(),
|
Env::default(),
|
||||||
Default::default(),
|
Default::default(),
|
||||||
|
|
|
@ -130,7 +130,7 @@ pub struct CrateData {
|
||||||
/// The name to display to the end user.
|
/// The name to display to the end user.
|
||||||
/// This actual crate name can be different in a particular dependent crate
|
/// This actual crate name can be different in a particular dependent crate
|
||||||
/// or may even be missing for some cases, such as a dummy crate for the code snippet.
|
/// or may even be missing for some cases, such as a dummy crate for the code snippet.
|
||||||
pub display_name: Option<String>,
|
pub display_name: Option<CrateName>,
|
||||||
pub cfg_options: CfgOptions,
|
pub cfg_options: CfgOptions,
|
||||||
pub env: Env,
|
pub env: Env,
|
||||||
pub dependencies: Vec<Dependency>,
|
pub dependencies: Vec<Dependency>,
|
||||||
|
@ -159,7 +159,7 @@ impl CrateGraph {
|
||||||
&mut self,
|
&mut self,
|
||||||
file_id: FileId,
|
file_id: FileId,
|
||||||
edition: Edition,
|
edition: Edition,
|
||||||
display_name: Option<String>,
|
display_name: Option<CrateName>,
|
||||||
cfg_options: CfgOptions,
|
cfg_options: CfgOptions,
|
||||||
env: Env,
|
env: Env,
|
||||||
proc_macro: Vec<(SmolStr, Arc<dyn tt::TokenExpander>)>,
|
proc_macro: Vec<(SmolStr, Arc<dyn tt::TokenExpander>)>,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
use std::{iter, sync::Arc};
|
use std::{iter, sync::Arc};
|
||||||
|
|
||||||
use arrayvec::ArrayVec;
|
use arrayvec::ArrayVec;
|
||||||
use base_db::{CrateId, Edition, FileId};
|
use base_db::{CrateId, CrateName, Edition, FileId};
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
adt::ReprKind,
|
adt::ReprKind,
|
||||||
|
@ -98,7 +98,7 @@ impl Crate {
|
||||||
db.crate_graph()[self.id].edition
|
db.crate_graph()[self.id].edition
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn display_name(self, db: &dyn HirDatabase) -> Option<String> {
|
pub fn display_name(self, db: &dyn HirDatabase) -> Option<CrateName> {
|
||||||
db.crate_graph()[self.id].display_name.clone()
|
db.crate_graph()[self.id].display_name.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -411,7 +411,7 @@ impl ProjectWorkspace {
|
||||||
let crate_id = crate_graph.add_crate_root(
|
let crate_id = crate_graph.add_crate_root(
|
||||||
file_id,
|
file_id,
|
||||||
edition,
|
edition,
|
||||||
Some(cargo[pkg].name.clone()),
|
Some(CrateName::normalize_dashes(&cargo[pkg].name)),
|
||||||
cfg_options,
|
cfg_options,
|
||||||
env,
|
env,
|
||||||
proc_macro.clone(),
|
proc_macro.clone(),
|
||||||
|
@ -546,7 +546,8 @@ fn sysroot_to_crate_graph(
|
||||||
|
|
||||||
let env = Env::default();
|
let env = Env::default();
|
||||||
let proc_macro = vec![];
|
let proc_macro = vec![];
|
||||||
let name = sysroot[krate].name.clone();
|
let name = CrateName::new(&sysroot[krate].name)
|
||||||
|
.expect("Sysroot crates' names do not contain dashes");
|
||||||
let crate_id = crate_graph.add_crate_root(
|
let crate_id = crate_graph.add_crate_root(
|
||||||
file_id,
|
file_id,
|
||||||
Edition::Edition2018,
|
Edition::Edition2018,
|
||||||
|
|
Loading…
Reference in a new issue