aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_parser/src/grammar/items.rs7
-rw-r--r--crates/ra_project_model/src/json_project.rs42
-rw-r--r--crates/ra_project_model/src/lib.rs6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast40
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rs3
5 files changed, 50 insertions, 48 deletions
diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs
index 9c14b954a..97642bc24 100644
--- a/crates/ra_parser/src/grammar/items.rs
+++ b/crates/ra_parser/src/grammar/items.rs
@@ -121,7 +121,12 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
121 T![unsafe] => { 121 T![unsafe] => {
122 // test default_unsafe_impl 122 // test default_unsafe_impl
123 // default unsafe impl Foo {} 123 // default unsafe impl Foo {}
124 if p.nth(2) == T![impl] { 124
125 // test default_unsafe_fn
126 // impl T for Foo {
127 // default unsafe fn foo() {}
128 // }
129 if p.nth(2) == T![impl] || p.nth(2) == T![fn] {
125 p.bump_remap(T![default]); 130 p.bump_remap(T![default]);
126 p.bump(T![unsafe]); 131 p.bump(T![unsafe]);
127 has_mods = true; 132 has_mods = true;
diff --git a/crates/ra_project_model/src/json_project.rs b/crates/ra_project_model/src/json_project.rs
index 09c06fef9..ee2de4c25 100644
--- a/crates/ra_project_model/src/json_project.rs
+++ b/crates/ra_project_model/src/json_project.rs
@@ -2,7 +2,7 @@
2 2
3use std::path::PathBuf; 3use std::path::PathBuf;
4 4
5use rustc_hash::{FxHashMap, FxHashSet}; 5use rustc_hash::FxHashSet;
6use serde::Deserialize; 6use serde::Deserialize;
7 7
8/// Roots and crates that compose this Rust project. 8/// Roots and crates that compose this Rust project.
@@ -28,16 +28,9 @@ pub struct Crate {
28 pub(crate) edition: Edition, 28 pub(crate) edition: Edition,
29 pub(crate) deps: Vec<Dep>, 29 pub(crate) deps: Vec<Dep>,
30 30
31 // This is the preferred method of providing cfg options.
32 #[serde(default)] 31 #[serde(default)]
33 pub(crate) cfg: FxHashSet<String>, 32 pub(crate) cfg: FxHashSet<String>,
34 33
35 // These two are here for transition only.
36 #[serde(default)]
37 pub(crate) atom_cfgs: FxHashSet<String>,
38 #[serde(default)]
39 pub(crate) key_value_cfgs: FxHashMap<String, String>,
40
41 pub(crate) out_dir: Option<PathBuf>, 34 pub(crate) out_dir: Option<PathBuf>,
42 pub(crate) proc_macro_dylib_path: Option<PathBuf>, 35 pub(crate) proc_macro_dylib_path: Option<PathBuf>,
43} 36}
@@ -99,37 +92,4 @@ mod tests {
99 assert!(krate.cfg.contains(&"feature=feature_2".to_string())); 92 assert!(krate.cfg.contains(&"feature=feature_2".to_string()));
100 assert!(krate.cfg.contains(&"other=value".to_string())); 93 assert!(krate.cfg.contains(&"other=value".to_string()));
101 } 94 }
102
103 #[test]
104 fn test_crate_deserialization_old_json() {
105 let raw_json = json!( {
106 "crate_id": 2,
107 "root_module": "this/is/a/file/path.rs",
108 "deps": [
109 {
110 "crate": 1,
111 "name": "some_dep_crate"
112 },
113 ],
114 "edition": "2015",
115 "atom_cfgs": [
116 "atom_1",
117 "atom_2",
118 ],
119 "key_value_cfgs": {
120 "feature": "feature_1",
121 "feature": "feature_2",
122 "other": "value",
123 },
124 });
125
126 let krate: Crate = serde_json::from_value(raw_json).unwrap();
127
128 assert!(krate.atom_cfgs.contains(&"atom_1".to_string()));
129 assert!(krate.atom_cfgs.contains(&"atom_2".to_string()));
130 assert!(krate.key_value_cfgs.contains_key(&"feature".to_string()));
131 assert_eq!(krate.key_value_cfgs.get("feature"), Some(&"feature_2".to_string()));
132 assert!(krate.key_value_cfgs.contains_key(&"other".to_string()));
133 assert_eq!(krate.key_value_cfgs.get("other"), Some(&"value".to_string()));
134 }
135} 95}
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs
index fe03b509e..47fa34ddf 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -280,12 +280,6 @@ impl ProjectWorkspace {
280 } 280 }
281 } 281 }
282 } 282 }
283 for name in &krate.atom_cfgs {
284 opts.insert_atom(name.into());
285 }
286 for (key, value) in &krate.key_value_cfgs {
287 opts.insert_key_value(key.into(), value.into());
288 }
289 opts 283 opts
290 }; 284 };
291 285
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast
new file mode 100644
index 000000000..adb6159f4
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast
@@ -0,0 +1,40 @@
1[email protected]
2 [email protected]
3 [email protected] "impl"
4 [email protected] " "
5 [email protected]
6 [email protected]
7 [email protected]
8 [email protected]
9 [email protected] "T"
10 [email protected] " "
11 [email protected] "for"
12 [email protected] " "
13 [email protected]
14 [email protected]
15 [email protected]
16 [email protected]
17 [email protected] "Foo"
18 [email protected] " "
19 [email protected]
20 [email protected] "{"
21 [email protected] "\n "
22 [email protected]
23 [email protected] "default"
24 [email protected] " "
25 [email protected] "unsafe"
26 [email protected] " "
27 [email protected] "fn"
28 [email protected] " "
29 [email protected]
30 [email protected] "foo"
31 [email protected]
32 [email protected] "("
33 [email protected] ")"
34 [email protected] " "
35 [email protected]
36 [email protected] "{"
37 [email protected] "}"
38 [email protected] "\n"
39 [email protected] "}"
40 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rs b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rs
new file mode 100644
index 000000000..12926cd8a
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rs
@@ -0,0 +1,3 @@
1impl T for Foo {
2 default unsafe fn foo() {}
3}