aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock26
-rw-r--r--crates/flycheck/Cargo.toml4
-rw-r--r--crates/flycheck/src/lib.rs5
-rw-r--r--crates/proc_macro_srv/Cargo.toml2
-rw-r--r--crates/proc_macro_srv/src/tests/utils.rs3
-rw-r--r--crates/project_model/Cargo.toml10
-rw-r--r--crates/project_model/src/build_data.rs23
-rw-r--r--crates/project_model/src/cargo_workspace.rs9
-rw-r--r--crates/rust-analyzer/src/diagnostics/to_proto.rs2
9 files changed, 47 insertions, 37 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 625c61883..739edb932 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -112,6 +112,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
112checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" 112checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b"
113 113
114[[package]] 114[[package]]
115name = "camino"
116version = "1.0.1"
117source = "registry+https://github.com/rust-lang/crates.io-index"
118checksum = "9bb47ab72bdba43021afa16dc1ef4d80c980d366b17ed37ea8d2ebe2087075b9"
119dependencies = [
120 "serde",
121]
122
123[[package]]
115name = "cargo-platform" 124name = "cargo-platform"
116version = "0.1.1" 125version = "0.1.1"
117source = "registry+https://github.com/rust-lang/crates.io-index" 126source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -122,10 +131,11 @@ dependencies = [
122 131
123[[package]] 132[[package]]
124name = "cargo_metadata" 133name = "cargo_metadata"
125version = "0.12.3" 134version = "0.13.1"
126source = "registry+https://github.com/rust-lang/crates.io-index" 135source = "registry+https://github.com/rust-lang/crates.io-index"
127checksum = "7714a157da7991e23d90686b9524b9e12e0407a108647f52e9328f4b3d51ac7f" 136checksum = "081e3f0755c1f380c2d010481b6fa2e02973586d5f2b24eebb7a2a1d98b143d8"
128dependencies = [ 137dependencies = [
138 "camino",
129 "cargo-platform", 139 "cargo-platform",
130 "semver", 140 "semver",
131 "semver-parser", 141 "semver-parser",
@@ -779,9 +789,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
779 789
780[[package]] 790[[package]]
781name = "libc" 791name = "libc"
782version = "0.2.86" 792version = "0.2.87"
783source = "registry+https://github.com/rust-lang/crates.io-index" 793source = "registry+https://github.com/rust-lang/crates.io-index"
784checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c" 794checksum = "265d751d31d6780a3f956bb5b8022feba2d94eeee5a84ba64f4212eedca42213"
785 795
786[[package]] 796[[package]]
787name = "libloading" 797name = "libloading"
@@ -1005,9 +1015,9 @@ checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4"
1005 1015
1006[[package]] 1016[[package]]
1007name = "once_cell" 1017name = "once_cell"
1008version = "1.7.0" 1018version = "1.7.1"
1009source = "registry+https://github.com/rust-lang/crates.io-index" 1019source = "registry+https://github.com/rust-lang/crates.io-index"
1010checksum = "10acf907b94fc1b1a152d08ef97e7759650268cf986bf127f387e602b02c7e5a" 1020checksum = "ea78b9742c52ac729753c1590e9adc5248ea9bdaf974597efd46c74cfaa5fb54"
1011 1021
1012[[package]] 1022[[package]]
1013name = "oorandom" 1023name = "oorandom"
@@ -1116,9 +1126,9 @@ dependencies = [
1116 1126
1117[[package]] 1127[[package]]
1118name = "pin-project-lite" 1128name = "pin-project-lite"
1119version = "0.2.4" 1129version = "0.2.5"
1120source = "registry+https://github.com/rust-lang/crates.io-index" 1130source = "registry+https://github.com/rust-lang/crates.io-index"
1121checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827" 1131checksum = "0cf491442e4b033ed1c722cb9f0df5fcfcf4de682466c46469c36bc47dc5548a"
1122 1132
1123[[package]] 1133[[package]]
1124name = "proc-macro-hack" 1134name = "proc-macro-hack"
diff --git a/crates/flycheck/Cargo.toml b/crates/flycheck/Cargo.toml
index 1d19c7886..2a1a21b28 100644
--- a/crates/flycheck/Cargo.toml
+++ b/crates/flycheck/Cargo.toml
@@ -12,9 +12,9 @@ doctest = false
12[dependencies] 12[dependencies]
13crossbeam-channel = "0.5.0" 13crossbeam-channel = "0.5.0"
14log = "0.4.8" 14log = "0.4.8"
15cargo_metadata = "0.12.2" 15cargo_metadata = "0.13"
16serde_json = "1.0.48" 16serde_json = "1.0.48"
17jod-thread = "0.1.1" 17jod-thread = "0.1.1"
18 18
19toolchain = { path = "../toolchain", version = "0.0.0" } 19toolchain = { path = "../toolchain", version = "0.0.0" }
20stdx = { path = "../stdx", version = "0.0.0" } 20stdx = { path = "../stdx", version = "0.0.0" }
diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs
index e04208006..e2a59497a 100644
--- a/crates/flycheck/src/lib.rs
+++ b/crates/flycheck/src/lib.rs
@@ -194,7 +194,7 @@ impl FlycheckActor {
194 cargo_metadata::Message::BuildScriptExecuted(_) 194 cargo_metadata::Message::BuildScriptExecuted(_)
195 | cargo_metadata::Message::BuildFinished(_) 195 | cargo_metadata::Message::BuildFinished(_)
196 | cargo_metadata::Message::TextLine(_) 196 | cargo_metadata::Message::TextLine(_)
197 | cargo_metadata::Message::Unknown => {} 197 | _ => {}
198 }, 198 },
199 } 199 }
200 } 200 }
@@ -329,8 +329,7 @@ impl CargoActor {
329 // Skip certain kinds of messages to only spend time on what's useful 329 // Skip certain kinds of messages to only spend time on what's useful
330 match &message { 330 match &message {
331 cargo_metadata::Message::CompilerArtifact(artifact) if artifact.fresh => (), 331 cargo_metadata::Message::CompilerArtifact(artifact) if artifact.fresh => (),
332 cargo_metadata::Message::BuildScriptExecuted(_) 332 cargo_metadata::Message::BuildScriptExecuted(_) => (),
333 | cargo_metadata::Message::Unknown => (),
334 _ => self.sender.send(message).unwrap(), 333 _ => self.sender.send(message).unwrap(),
335 } 334 }
336 } 335 }
diff --git a/crates/proc_macro_srv/Cargo.toml b/crates/proc_macro_srv/Cargo.toml
index 6c8c28980..4c1b3036a 100644
--- a/crates/proc_macro_srv/Cargo.toml
+++ b/crates/proc_macro_srv/Cargo.toml
@@ -20,7 +20,7 @@ proc_macro_api = { path = "../proc_macro_api", version = "0.0.0" }
20test_utils = { path = "../test_utils", version = "0.0.0" } 20test_utils = { path = "../test_utils", version = "0.0.0" }
21 21
22[dev-dependencies] 22[dev-dependencies]
23cargo_metadata = "0.12.2" 23cargo_metadata = "0.13"
24 24
25# used as proc macro test targets 25# used as proc macro test targets
26serde_derive = "1.0.106" 26serde_derive = "1.0.106"
diff --git a/crates/proc_macro_srv/src/tests/utils.rs b/crates/proc_macro_srv/src/tests/utils.rs
index 196abb8fc..22813052d 100644
--- a/crates/proc_macro_srv/src/tests/utils.rs
+++ b/crates/proc_macro_srv/src/tests/utils.rs
@@ -8,6 +8,7 @@ use test_utils::assert_eq_text;
8 8
9mod fixtures { 9mod fixtures {
10 use cargo_metadata::Message; 10 use cargo_metadata::Message;
11 use std::path::PathBuf;
11 use std::process::Command; 12 use std::process::Command;
12 13
13 // Use current project metadata to get the proc-macro dylib path 14 // Use current project metadata to get the proc-macro dylib path
@@ -24,7 +25,7 @@ mod fixtures {
24 if artifact.target.kind.contains(&"proc-macro".to_string()) { 25 if artifact.target.kind.contains(&"proc-macro".to_string()) {
25 let repr = format!("{} {}", crate_name, version); 26 let repr = format!("{} {}", crate_name, version);
26 if artifact.package_id.repr.starts_with(&repr) { 27 if artifact.package_id.repr.starts_with(&repr) {
27 return artifact.filenames[0].clone(); 28 return PathBuf::from(&artifact.filenames[0]);
28 } 29 }
29 } 30 }
30 } 31 }
diff --git a/crates/project_model/Cargo.toml b/crates/project_model/Cargo.toml
index 293cb5bfe..fe3258332 100644
--- a/crates/project_model/Cargo.toml
+++ b/crates/project_model/Cargo.toml
@@ -12,7 +12,7 @@ doctest = false
12[dependencies] 12[dependencies]
13log = "0.4.8" 13log = "0.4.8"
14rustc-hash = "1.1.0" 14rustc-hash = "1.1.0"
15cargo_metadata = "0.12.2" 15cargo_metadata = "0.13"
16serde = { version = "1.0.106", features = ["derive"] } 16serde = { version = "1.0.106", features = ["derive"] }
17serde_json = "1.0.48" 17serde_json = "1.0.48"
18anyhow = "1.0.26" 18anyhow = "1.0.26"
@@ -22,7 +22,7 @@ la-arena = { version = "0.2.0", path = "../../lib/arena" }
22cfg = { path = "../cfg", version = "0.0.0" } 22cfg = { path = "../cfg", version = "0.0.0" }
23base_db = { path = "../base_db", version = "0.0.0" } 23base_db = { path = "../base_db", version = "0.0.0" }
24toolchain = { path = "../toolchain", version = "0.0.0" } 24toolchain = { path = "../toolchain", version = "0.0.0" }
25proc_macro_api = { path = "../proc_macro_api", version = "0.0.0" } 25proc_macro_api = { path = "../proc_macro_api", version = "0.0.0" }
26paths = { path = "../paths", version = "0.0.0" } 26paths = { path = "../paths", version = "0.0.0" }
27stdx = { path = "../stdx", version = "0.0.0" } 27stdx = { path = "../stdx", version = "0.0.0" }
28profile = { path = "../profile", version = "0.0.0" } 28profile = { path = "../profile", version = "0.0.0" }
diff --git a/crates/project_model/src/build_data.rs b/crates/project_model/src/build_data.rs
index 295b5f8ef..728a258ea 100644
--- a/crates/project_model/src/build_data.rs
+++ b/crates/project_model/src/build_data.rs
@@ -1,14 +1,14 @@
1//! Handles build script specific information 1//! Handles build script specific information
2 2
3use std::{ 3use std::{
4 ffi::OsStr,
5 io::BufReader, 4 io::BufReader,
6 path::{Path, PathBuf}, 5 path::PathBuf,
7 process::{Command, Stdio}, 6 process::{Command, Stdio},
8 sync::Arc, 7 sync::Arc,
9}; 8};
10 9
11use anyhow::Result; 10use anyhow::Result;
11use cargo_metadata::camino::Utf8Path;
12use cargo_metadata::{BuildScript, Message}; 12use cargo_metadata::{BuildScript, Message};
13use itertools::Itertools; 13use itertools::Itertools;
14use paths::{AbsPath, AbsPathBuf}; 14use paths::{AbsPath, AbsPathBuf};
@@ -162,8 +162,8 @@ fn collect_from_workspace(
162 let res = res.entry(package_id.repr.clone()).or_default(); 162 let res = res.entry(package_id.repr.clone()).or_default();
163 // cargo_metadata crate returns default (empty) path for 163 // cargo_metadata crate returns default (empty) path for
164 // older cargos, which is not absolute, so work around that. 164 // older cargos, which is not absolute, so work around that.
165 if out_dir != PathBuf::default() { 165 if !out_dir.as_str().is_empty() {
166 let out_dir = AbsPathBuf::assert(out_dir); 166 let out_dir = AbsPathBuf::assert(PathBuf::from(out_dir.into_os_string()));
167 res.out_dir = Some(out_dir); 167 res.out_dir = Some(out_dir);
168 res.cfgs = cfgs; 168 res.cfgs = cfgs;
169 } 169 }
@@ -178,7 +178,7 @@ fn collect_from_workspace(
178 // Skip rmeta file 178 // Skip rmeta file
179 if let Some(filename) = message.filenames.iter().find(|name| is_dylib(name)) 179 if let Some(filename) = message.filenames.iter().find(|name| is_dylib(name))
180 { 180 {
181 let filename = AbsPathBuf::assert(filename.clone()); 181 let filename = AbsPathBuf::assert(PathBuf::from(&filename));
182 let res = res.entry(package_id.repr.clone()).or_default(); 182 let res = res.entry(package_id.repr.clone()).or_default();
183 res.proc_macro_dylib_path = Some(filename); 183 res.proc_macro_dylib_path = Some(filename);
184 } 184 }
@@ -187,9 +187,9 @@ fn collect_from_workspace(
187 Message::CompilerMessage(message) => { 187 Message::CompilerMessage(message) => {
188 progress(message.target.name.clone()); 188 progress(message.target.name.clone());
189 } 189 }
190 Message::Unknown => (),
191 Message::BuildFinished(_) => {} 190 Message::BuildFinished(_) => {}
192 Message::TextLine(_) => {} 191 Message::TextLine(_) => {}
192 _ => {}
193 } 193 }
194 } 194 }
195 } 195 }
@@ -209,8 +209,8 @@ fn collect_from_workspace(
209} 209}
210 210
211// FIXME: File a better way to know if it is a dylib 211// FIXME: File a better way to know if it is a dylib
212fn is_dylib(path: &Path) -> bool { 212fn is_dylib(path: &Utf8Path) -> bool {
213 match path.extension().and_then(OsStr::to_str).map(|it| it.to_string().to_lowercase()) { 213 match path.extension().map(|e| e.to_string().to_lowercase()) {
214 None => false, 214 None => false,
215 Some(ext) => matches!(ext.as_str(), "dll" | "dylib" | "so"), 215 Some(ext) => matches!(ext.as_str(), "dll" | "dylib" | "so"),
216 } 216 }
@@ -227,9 +227,7 @@ fn inject_cargo_env(package: &cargo_metadata::Package, build_data: &mut BuildDat
227 227
228 let mut manifest_dir = package.manifest_path.clone(); 228 let mut manifest_dir = package.manifest_path.clone();
229 manifest_dir.pop(); 229 manifest_dir.pop();
230 if let Some(cargo_manifest_dir) = manifest_dir.to_str() { 230 env.push(("CARGO_MANIFEST_DIR".into(), manifest_dir.into_string()));
231 env.push(("CARGO_MANIFEST_DIR".into(), cargo_manifest_dir.into()));
232 }
233 231
234 // Not always right, but works for common cases. 232 // Not always right, but works for common cases.
235 env.push(("CARGO".into(), "cargo".into())); 233 env.push(("CARGO".into(), "cargo".into()));
@@ -251,7 +249,6 @@ fn inject_cargo_env(package: &cargo_metadata::Package, build_data: &mut BuildDat
251 env.push(("CARGO_PKG_REPOSITORY".into(), package.repository.clone().unwrap_or_default())); 249 env.push(("CARGO_PKG_REPOSITORY".into(), package.repository.clone().unwrap_or_default()));
252 env.push(("CARGO_PKG_LICENSE".into(), package.license.clone().unwrap_or_default())); 250 env.push(("CARGO_PKG_LICENSE".into(), package.license.clone().unwrap_or_default()));
253 251
254 let license_file = 252 let license_file = package.license_file.as_ref().map(|buf| buf.to_string()).unwrap_or_default();
255 package.license_file.as_ref().map(|buf| buf.display().to_string()).unwrap_or_default();
256 env.push(("CARGO_PKG_LICENSE_FILE".into(), license_file)); 253 env.push(("CARGO_PKG_LICENSE_FILE".into(), license_file));
257} 254}
diff --git a/crates/project_model/src/cargo_workspace.rs b/crates/project_model/src/cargo_workspace.rs
index 1d8d34a0b..f7241b711 100644
--- a/crates/project_model/src/cargo_workspace.rs
+++ b/crates/project_model/src/cargo_workspace.rs
@@ -1,5 +1,6 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use std::path::PathBuf;
3use std::{convert::TryInto, ops, process::Command, sync::Arc}; 4use std::{convert::TryInto, ops, process::Command, sync::Arc};
4 5
5use anyhow::{Context, Result}; 6use anyhow::{Context, Result};
@@ -249,11 +250,12 @@ impl CargoWorkspace {
249 let edition = edition 250 let edition = edition
250 .parse::<Edition>() 251 .parse::<Edition>()
251 .with_context(|| format!("Failed to parse edition {}", edition))?; 252 .with_context(|| format!("Failed to parse edition {}", edition))?;
253
252 let pkg = packages.alloc(PackageData { 254 let pkg = packages.alloc(PackageData {
253 id: id.repr.clone(), 255 id: id.repr.clone(),
254 name: name.clone(), 256 name: name.clone(),
255 version: version.to_string(), 257 version: version.to_string(),
256 manifest: AbsPathBuf::assert(manifest_path.clone()), 258 manifest: AbsPathBuf::assert(PathBuf::from(&manifest_path)),
257 targets: Vec::new(), 259 targets: Vec::new(),
258 is_member, 260 is_member,
259 edition, 261 edition,
@@ -268,7 +270,7 @@ impl CargoWorkspace {
268 let tgt = targets.alloc(TargetData { 270 let tgt = targets.alloc(TargetData {
269 package: pkg, 271 package: pkg,
270 name: meta_tgt.name.clone(), 272 name: meta_tgt.name.clone(),
271 root: AbsPathBuf::assert(meta_tgt.src_path.clone()), 273 root: AbsPathBuf::assert(PathBuf::from(&meta_tgt.src_path)),
272 kind: TargetKind::new(meta_tgt.kind.as_slice()), 274 kind: TargetKind::new(meta_tgt.kind.as_slice()),
273 is_proc_macro, 275 is_proc_macro,
274 }); 276 });
@@ -305,7 +307,8 @@ impl CargoWorkspace {
305 packages[source].active_features.extend(node.features); 307 packages[source].active_features.extend(node.features);
306 } 308 }
307 309
308 let workspace_root = AbsPathBuf::assert(meta.workspace_root); 310 let workspace_root =
311 AbsPathBuf::assert(PathBuf::from(meta.workspace_root.into_os_string()));
309 let build_data_config = BuildDataConfig::new( 312 let build_data_config = BuildDataConfig::new(
310 cargo_toml.to_path_buf(), 313 cargo_toml.to_path_buf(),
311 config.clone(), 314 config.clone(),
diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs
index 0ed87fe3e..0ad832c0e 100644
--- a/crates/rust-analyzer/src/diagnostics/to_proto.rs
+++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs
@@ -29,7 +29,7 @@ fn diagnostic_severity(
29 }, 29 },
30 DiagnosticLevel::Note => lsp_types::DiagnosticSeverity::Information, 30 DiagnosticLevel::Note => lsp_types::DiagnosticSeverity::Information,
31 DiagnosticLevel::Help => lsp_types::DiagnosticSeverity::Hint, 31 DiagnosticLevel::Help => lsp_types::DiagnosticSeverity::Hint,
32 DiagnosticLevel::Unknown => return None, 32 _ => return None,
33 }; 33 };
34 Some(res) 34 Some(res)
35} 35}