mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-27 18:26:19 +00:00
Cleanup Name string rendering
This commit is contained in:
parent
c78cc2baa9
commit
76585539f5
38 changed files with 145 additions and 249 deletions
|
|
@ -10,7 +10,6 @@ use rustc_hash::FxHashSet;
|
|||
use smallvec::SmallVec;
|
||||
use span::Edition;
|
||||
use stdx::{format_to, TupleExt};
|
||||
use syntax::ToSmolStr;
|
||||
use triomphe::Arc;
|
||||
|
||||
use crate::{
|
||||
|
|
@ -88,9 +87,9 @@ impl ImportMap {
|
|||
.iter()
|
||||
// We've only collected items, whose name cannot be tuple field so unwrapping is fine.
|
||||
.flat_map(|(&item, (info, _))| {
|
||||
info.iter().enumerate().map(move |(idx, info)| {
|
||||
(item, info.name.unescaped().display(db.upcast()).to_smolstr(), idx as u32)
|
||||
})
|
||||
info.iter()
|
||||
.enumerate()
|
||||
.map(move |(idx, info)| (item, info.name.as_str(), idx as u32))
|
||||
})
|
||||
.collect();
|
||||
importables.sort_by(|(_, l_info, _), (_, r_info, _)| {
|
||||
|
|
@ -441,7 +440,7 @@ pub fn search_dependencies(
|
|||
}
|
||||
|
||||
fn search_maps(
|
||||
db: &dyn DefDatabase,
|
||||
_db: &dyn DefDatabase,
|
||||
import_maps: &[Arc<ImportMap>],
|
||||
mut stream: fst::map::Union<'_>,
|
||||
query: &Query,
|
||||
|
|
@ -464,11 +463,7 @@ fn search_maps(
|
|||
.then(|| (item, &import_infos[info_idx as usize]))
|
||||
})
|
||||
.filter(|&(_, info)| {
|
||||
query.search_mode.check(
|
||||
&query.query,
|
||||
query.case_sensitive,
|
||||
&info.name.unescaped().display(db.upcast()).to_smolstr(),
|
||||
)
|
||||
query.search_mode.check(&query.query, query.case_sensitive, info.name.as_str())
|
||||
});
|
||||
res.extend(iter.map(TupleExt::head));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ use base_db::AnchoredPath;
|
|||
use hir_expand::{name::Name, HirFileIdExt};
|
||||
use limit::Limit;
|
||||
use span::EditionedFileId;
|
||||
use syntax::ToSmolStr as _;
|
||||
|
||||
use crate::{db::DefDatabase, HirFileId};
|
||||
|
||||
|
|
@ -35,7 +34,7 @@ impl ModDir {
|
|||
let path = match attr_path {
|
||||
None => {
|
||||
let mut path = self.dir_path.clone();
|
||||
path.push(&name.unescaped().display_no_db().to_smolstr());
|
||||
path.push(name.as_str());
|
||||
path
|
||||
}
|
||||
Some(attr_path) => {
|
||||
|
|
@ -66,7 +65,7 @@ impl ModDir {
|
|||
name: &Name,
|
||||
attr_path: Option<&str>,
|
||||
) -> Result<(EditionedFileId, bool, ModDir), Box<[String]>> {
|
||||
let name = name.unescaped();
|
||||
let name = name.as_str();
|
||||
|
||||
let mut candidate_files = ArrayVec::<_, 2>::new();
|
||||
match attr_path {
|
||||
|
|
@ -74,16 +73,8 @@ impl ModDir {
|
|||
candidate_files.push(self.dir_path.join_attr(attr_path, self.root_non_dir_owner))
|
||||
}
|
||||
None => {
|
||||
candidate_files.push(format!(
|
||||
"{}{}.rs",
|
||||
self.dir_path.0,
|
||||
name.display(db.upcast())
|
||||
));
|
||||
candidate_files.push(format!(
|
||||
"{}{}/mod.rs",
|
||||
self.dir_path.0,
|
||||
name.display(db.upcast())
|
||||
));
|
||||
candidate_files.push(format!("{}{}.rs", self.dir_path.0, name));
|
||||
candidate_files.push(format!("{}{}/mod.rs", self.dir_path.0, name));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -97,7 +88,7 @@ impl ModDir {
|
|||
let dir_path = if root_dir_owner {
|
||||
DirPath::empty()
|
||||
} else {
|
||||
DirPath::new(format!("{}/", name.display(db.upcast())))
|
||||
DirPath::new(format!("{}/", name))
|
||||
};
|
||||
if let Some(mod_dir) = self.child(dir_path, !root_dir_owner) {
|
||||
return Ok((
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue