aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_db/src/fixture.rs3
-rw-r--r--crates/ra_db/src/input.rs12
-rw-r--r--crates/ra_project_model/src/cargo_workspace.rs7
3 files changed, 14 insertions, 8 deletions
diff --git a/crates/ra_db/src/fixture.rs b/crates/ra_db/src/fixture.rs
index f5dd59f84..ee883b615 100644
--- a/crates/ra_db/src/fixture.rs
+++ b/crates/ra_db/src/fixture.rs
@@ -1,5 +1,6 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use std::str::FromStr;
3use std::sync::Arc; 4use std::sync::Arc;
4 5
5use ra_cfg::CfgOptions; 6use ra_cfg::CfgOptions;
@@ -164,7 +165,7 @@ fn parse_meta(meta: &str) -> ParsedMeta {
164 match key { 165 match key {
165 "crate" => krate = Some(value.to_string()), 166 "crate" => krate = Some(value.to_string()),
166 "deps" => deps = value.split(',').map(|it| it.to_string()).collect(), 167 "deps" => deps = value.split(',').map(|it| it.to_string()).collect(),
167 "edition" => edition = Edition::from_string(&value), 168 "edition" => edition = Edition::from_str(&value).unwrap(),
168 "cfg" => { 169 "cfg" => {
169 for key in value.split(',') { 170 for key in value.split(',') {
170 match split1(key, '=') { 171 match split1(key, '=') {
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs
index 60f7dc881..fb9a3297a 100644
--- a/crates/ra_db/src/input.rs
+++ b/crates/ra_db/src/input.rs
@@ -13,6 +13,7 @@ use ra_syntax::SmolStr;
13use rustc_hash::FxHashSet; 13use rustc_hash::FxHashSet;
14 14
15use crate::{RelativePath, RelativePathBuf}; 15use crate::{RelativePath, RelativePathBuf};
16use std::str::FromStr;
16 17
17/// `FileId` is an integer which uniquely identifies a file. File paths are 18/// `FileId` is an integer which uniquely identifies a file. File paths are
18/// messy and system-dependent, so most of the code should work directly with 19/// messy and system-dependent, so most of the code should work directly with
@@ -97,12 +98,13 @@ pub enum Edition {
97 Edition2015, 98 Edition2015,
98} 99}
99 100
100impl Edition { 101impl FromStr for Edition {
101 //FIXME: replace with FromStr with proper error handling 102 type Err = String;
102 pub fn from_string(s: &str) -> Edition { 103 fn from_str(s: &str) -> Result<Self, Self::Err> {
103 match s { 104 match s {
104 "2015" => Edition::Edition2015, 105 "2015" => Ok(Edition::Edition2015),
105 "2018" | _ => Edition::Edition2018, 106 "2018" => Ok(Edition::Edition2018),
107 _ => Err(format! {"unknown edition: {}" , s}),
106 } 108 }
107 } 109 }
108} 110}
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs
index 28dadea9d..ff96bf904 100644
--- a/crates/ra_project_model/src/cargo_workspace.rs
+++ b/crates/ra_project_model/src/cargo_workspace.rs
@@ -1,6 +1,7 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use std::path::{Path, PathBuf}; 3use std::path::{Path, PathBuf};
4use std::str::FromStr;
4 5
5use cargo_metadata::{CargoOpt, MetadataCommand}; 6use cargo_metadata::{CargoOpt, MetadataCommand};
6use ra_arena::{impl_arena_id, Arena, RawId}; 7use ra_arena::{impl_arena_id, Arena, RawId};
@@ -141,12 +142,14 @@ impl CargoWorkspace {
141 142
142 for meta_pkg in meta.packages { 143 for meta_pkg in meta.packages {
143 let is_member = ws_members.contains(&meta_pkg.id); 144 let is_member = ws_members.contains(&meta_pkg.id);
145 let name = meta_pkg.name;
144 let pkg = packages.alloc(PackageData { 146 let pkg = packages.alloc(PackageData {
145 name: meta_pkg.name, 147 name: name.clone(),
146 manifest: meta_pkg.manifest_path.clone(), 148 manifest: meta_pkg.manifest_path.clone(),
147 targets: Vec::new(), 149 targets: Vec::new(),
148 is_member, 150 is_member,
149 edition: Edition::from_string(&meta_pkg.edition), 151 edition: Edition::from_str(&meta_pkg.edition)
152 .unwrap_or_else(|e| panic!("unknown edition {} for package {:?}", e, &name)),
150 dependencies: Vec::new(), 153 dependencies: Vec::new(),
151 features: Vec::new(), 154 features: Vec::new(),
152 }); 155 });