Remove SmolStr from project model

This commit is contained in:
Florian Diebold 2019-02-09 10:51:06 +01:00
parent ddbf43b630
commit 12c70871cc
5 changed files with 7 additions and 19 deletions

1
Cargo.lock generated
View file

@ -1057,7 +1057,6 @@ dependencies = [
"ra_db 0.1.0", "ra_db 0.1.0",
"ra_vfs 0.1.0", "ra_vfs 0.1.0",
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"smol_str 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"test_utils 0.1.0", "test_utils 0.1.0",
"walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
] ]

View file

@ -5,21 +5,13 @@ version = "0.1.0"
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"] authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
[dependencies] [dependencies]
# itertools = "0.8.0"
# join_to_string = "0.1.3"
log = "0.4.5" log = "0.4.5"
# relative-path = "0.4.0"
# rayon = "1.0.2"
# fst = "0.3.1"
rustc-hash = "1.0" rustc-hash = "1.0"
# parking_lot = "0.7.0"
# unicase = "2.2.0"
# TODO get rid of these? # TODO get rid of these?
failure = "0.1.4" failure = "0.1.4"
failure_derive = "0.1.4" failure_derive = "0.1.4"
smol_str = { version = "0.1.9", features = ["serde"] }
walkdir = "2.2.7" walkdir = "2.2.7"
cargo_metadata = "0.7.0" cargo_metadata = "0.7.0"

View file

@ -1,7 +1,6 @@
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use cargo_metadata::{MetadataCommand, CargoOpt}; use cargo_metadata::{MetadataCommand, CargoOpt};
use smol_str::SmolStr;
use ra_arena::{Arena, RawId, impl_arena_id}; use ra_arena::{Arena, RawId, impl_arena_id};
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use failure::format_err; use failure::format_err;
@ -31,7 +30,7 @@ impl_arena_id!(Target);
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
struct PackageData { struct PackageData {
name: SmolStr, name: String,
manifest: PathBuf, manifest: PathBuf,
targets: Vec<Target>, targets: Vec<Target>,
is_member: bool, is_member: bool,
@ -41,13 +40,13 @@ struct PackageData {
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct PackageDependency { pub struct PackageDependency {
pub pkg: Package, pub pkg: Package,
pub name: SmolStr, pub name: String,
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
struct TargetData { struct TargetData {
pkg: Package, pkg: Package,
name: SmolStr, name: String,
root: PathBuf, root: PathBuf,
kind: TargetKind, kind: TargetKind,
} }

View file

@ -47,7 +47,7 @@ impl ProjectWorkspace {
if let (Some(&from), Some(&to)) = if let (Some(&from), Some(&to)) =
(sysroot_crates.get(&from), sysroot_crates.get(&to)) (sysroot_crates.get(&from), sysroot_crates.get(&to))
{ {
if let Err(_) = crate_graph.add_dep(from, name.clone(), to) { if let Err(_) = crate_graph.add_dep(from, name.into(), to) {
log::error!("cyclic dependency between sysroot crates") log::error!("cyclic dependency between sysroot crates")
} }
} }
@ -101,7 +101,7 @@ impl ProjectWorkspace {
for dep in pkg.dependencies(&self.cargo) { for dep in pkg.dependencies(&self.cargo) {
if let Some(&to) = pkg_to_lib_crate.get(&dep.pkg) { if let Some(&to) = pkg_to_lib_crate.get(&dep.pkg) {
for &from in pkg_crates.get(&pkg).into_iter().flatten() { for &from in pkg_crates.get(&pkg).into_iter().flatten() {
if let Err(_) = crate_graph.add_dep(from, dep.name.clone(), to) { if let Err(_) = crate_graph.add_dep(from, dep.name.clone().into(), to) {
log::error!( log::error!(
"cyclic dependency {} -> {}", "cyclic dependency {} -> {}",
pkg.name(&self.cargo), pkg.name(&self.cargo),

View file

@ -3,8 +3,6 @@ use std::{
process::Command, process::Command,
}; };
use smol_str::SmolStr;
use ra_arena::{Arena, RawId, impl_arena_id}; use ra_arena::{Arena, RawId, impl_arena_id};
use crate::Result; use crate::Result;
@ -20,7 +18,7 @@ impl_arena_id!(SysrootCrate);
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
struct SysrootCrateData { struct SysrootCrateData {
name: SmolStr, name: String,
root: PathBuf, root: PathBuf,
deps: Vec<SysrootCrate>, deps: Vec<SysrootCrate>,
} }
@ -81,7 +79,7 @@ impl Sysroot {
} }
impl SysrootCrate { impl SysrootCrate {
pub fn name(self, sysroot: &Sysroot) -> &SmolStr { pub fn name(self, sysroot: &Sysroot) -> &str {
&sysroot.crates[self].name &sysroot.crates[self].name
} }
pub fn root(self, sysroot: &Sysroot) -> &Path { pub fn root(self, sysroot: &Sysroot) -> &Path {