diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-01 09:03:47 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-01 09:03:47 +0100 |
commit | 686e115e7397028a94bde57df1acf0f066651285 (patch) | |
tree | 2a854f0f74ef4865c0b4196ed0a31abd0da74e2d /crates/ra_project_model/src/project_json.rs | |
parent | 30c2e714cc1677cbea40a47d7c0944c92f66b7c9 (diff) | |
parent | 80386ca5be78d8ea65483df3edeec1a89b09a5a3 (diff) |
Merge #5158
5158: Use CrateName correctly r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_project_model/src/project_json.rs')
-rw-r--r-- | crates/ra_project_model/src/project_json.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/crates/ra_project_model/src/project_json.rs b/crates/ra_project_model/src/project_json.rs index 4b5dcd634..9fe1e2dcb 100644 --- a/crates/ra_project_model/src/project_json.rs +++ b/crates/ra_project_model/src/project_json.rs | |||
@@ -4,9 +4,9 @@ use std::path::PathBuf; | |||
4 | 4 | ||
5 | use paths::{AbsPath, AbsPathBuf}; | 5 | use paths::{AbsPath, AbsPathBuf}; |
6 | use ra_cfg::CfgOptions; | 6 | use ra_cfg::CfgOptions; |
7 | use ra_db::{CrateId, Dependency, Edition}; | 7 | use ra_db::{CrateId, CrateName, Dependency, Edition}; |
8 | use rustc_hash::FxHashSet; | 8 | use rustc_hash::FxHashSet; |
9 | use serde::Deserialize; | 9 | use serde::{de, Deserialize}; |
10 | use stdx::split_delim; | 10 | use stdx::split_delim; |
11 | 11 | ||
12 | /// Roots and crates that compose this Rust project. | 12 | /// Roots and crates that compose this Rust project. |
@@ -50,7 +50,7 @@ impl ProjectJson { | |||
50 | .into_iter() | 50 | .into_iter() |
51 | .map(|dep_data| Dependency { | 51 | .map(|dep_data| Dependency { |
52 | crate_id: CrateId(dep_data.krate as u32), | 52 | crate_id: CrateId(dep_data.krate as u32), |
53 | name: dep_data.name.into(), | 53 | name: dep_data.name, |
54 | }) | 54 | }) |
55 | .collect::<Vec<_>>(), | 55 | .collect::<Vec<_>>(), |
56 | cfg: { | 56 | cfg: { |
@@ -113,5 +113,14 @@ struct DepData { | |||
113 | /// Identifies a crate by position in the crates array. | 113 | /// Identifies a crate by position in the crates array. |
114 | #[serde(rename = "crate")] | 114 | #[serde(rename = "crate")] |
115 | krate: usize, | 115 | krate: usize, |
116 | name: String, | 116 | #[serde(deserialize_with = "deserialize_crate_name")] |
117 | name: CrateName, | ||
118 | } | ||
119 | |||
120 | fn deserialize_crate_name<'de, D>(de: D) -> Result<CrateName, D::Error> | ||
121 | where | ||
122 | D: de::Deserializer<'de>, | ||
123 | { | ||
124 | let name = String::deserialize(de)?; | ||
125 | CrateName::new(&name).map_err(|err| de::Error::custom(format!("invalid crate name: {:?}", err))) | ||
117 | } | 126 | } |