|
49 | 49 | //! user explores them belongs to that extension (it's totally valid to change
|
50 | 50 | //! rust-project.json over time via configuration request!)
|
51 | 51 |
|
52 |
| -use std::path::PathBuf; |
53 |
| - |
54 | 52 | use base_db::{CrateDisplayName, CrateId, CrateName, Dependency, Edition};
|
55 | 53 | use la_arena::RawIdx;
|
56 | 54 | use paths::{AbsPath, AbsPathBuf};
|
57 | 55 | use rustc_hash::FxHashMap;
|
58 | 56 | use serde::{de, Deserialize};
|
| 57 | +use std::path::PathBuf; |
59 | 58 |
|
60 | 59 | use crate::cfg_flag::CfgFlag;
|
61 | 60 |
|
@@ -99,26 +98,23 @@ impl ProjectJson {
|
99 | 98 | /// * `data` - The parsed contents of `rust-project.json`, or project json that's passed via
|
100 | 99 | /// configuration.
|
101 | 100 | pub fn new(base: &AbsPath, data: ProjectJsonData) -> ProjectJson {
|
| 101 | + let absolutize_on_base = |p| base.absolutize(p); |
102 | 102 | ProjectJson {
|
103 |
| - sysroot: data.sysroot.map(|it| base.join(it)), |
104 |
| - sysroot_src: data.sysroot_src.map(|it| base.join(it)), |
| 103 | + sysroot: data.sysroot.map(absolutize_on_base), |
| 104 | + sysroot_src: data.sysroot_src.map(absolutize_on_base), |
105 | 105 | project_root: base.to_path_buf(),
|
106 | 106 | crates: data
|
107 | 107 | .crates
|
108 | 108 | .into_iter()
|
109 | 109 | .map(|crate_data| {
|
110 |
| - let is_workspace_member = crate_data.is_workspace_member.unwrap_or_else(|| { |
111 |
| - crate_data.root_module.is_relative() |
112 |
| - && !crate_data.root_module.starts_with("..") |
113 |
| - || crate_data.root_module.starts_with(base) |
114 |
| - }); |
115 |
| - let root_module = base.join(crate_data.root_module).normalize(); |
| 110 | + let root_module = absolutize_on_base(crate_data.root_module); |
| 111 | + let is_workspace_member = crate_data |
| 112 | + .is_workspace_member |
| 113 | + .unwrap_or_else(|| root_module.starts_with(base)); |
116 | 114 | let (include, exclude) = match crate_data.source {
|
117 | 115 | Some(src) => {
|
118 | 116 | let absolutize = |dirs: Vec<PathBuf>| {
|
119 |
| - dirs.into_iter() |
120 |
| - .map(|it| base.join(it).normalize()) |
121 |
| - .collect::<Vec<_>>() |
| 117 | + dirs.into_iter().map(absolutize_on_base).collect::<Vec<_>>() |
122 | 118 | };
|
123 | 119 | (absolutize(src.include_dirs), absolutize(src.exclude_dirs))
|
124 | 120 | }
|
@@ -147,15 +143,15 @@ impl ProjectJson {
|
147 | 143 | env: crate_data.env,
|
148 | 144 | proc_macro_dylib_path: crate_data
|
149 | 145 | .proc_macro_dylib_path
|
150 |
| - .map(|it| base.join(it)), |
| 146 | + .map(absolutize_on_base), |
151 | 147 | is_workspace_member,
|
152 | 148 | include,
|
153 | 149 | exclude,
|
154 | 150 | is_proc_macro: crate_data.is_proc_macro,
|
155 | 151 | repository: crate_data.repository,
|
156 | 152 | }
|
157 | 153 | })
|
158 |
| - .collect::<Vec<_>>(), |
| 154 | + .collect(), |
159 | 155 | }
|
160 | 156 | }
|
161 | 157 |
|
@@ -243,7 +239,7 @@ struct CrateSource {
|
243 | 239 | exclude_dirs: Vec<PathBuf>,
|
244 | 240 | }
|
245 | 241 |
|
246 |
| -fn deserialize_crate_name<'de, D>(de: D) -> Result<CrateName, D::Error> |
| 242 | +fn deserialize_crate_name<'de, D>(de: D) -> std::result::Result<CrateName, D::Error> |
247 | 243 | where
|
248 | 244 | D: de::Deserializer<'de>,
|
249 | 245 | {
|
|
0 commit comments