aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/src/mock.rs19
-rw-r--r--crates/ra_hir/src/nameres/tests.rs13
-rw-r--r--crates/ra_hir/src/ty/tests.rs7
3 files changed, 23 insertions, 16 deletions
diff --git a/crates/ra_hir/src/mock.rs b/crates/ra_hir/src/mock.rs
index f750986b8..827424983 100644
--- a/crates/ra_hir/src/mock.rs
+++ b/crates/ra_hir/src/mock.rs
@@ -278,7 +278,10 @@ macro_rules! crate_graph {
278 $crate_path:literal, 278 $crate_path:literal,
279 $($edition:literal,)? 279 $($edition:literal,)?
280 [$($dep:literal),*] 280 [$($dep:literal),*]
281 $(,$cfg:expr)? 281 $(, cfg = {
282 $($key:literal $(= $value:literal)?),*
283 $(,)?
284 })?
282 ), 285 ),
283 )*) => {{ 286 )*) => {{
284 let mut res = $crate::mock::CrateGraphFixture::default(); 287 let mut res = $crate::mock::CrateGraphFixture::default();
@@ -286,7 +289,19 @@ macro_rules! crate_graph {
286 #[allow(unused_mut, unused_assignments)] 289 #[allow(unused_mut, unused_assignments)]
287 let mut edition = ra_db::Edition::Edition2018; 290 let mut edition = ra_db::Edition::Edition2018;
288 $(edition = ra_db::Edition::from_string($edition);)? 291 $(edition = ra_db::Edition::from_string($edition);)?
289 let cfg_options = { ::ra_cfg::CfgOptions::default() $(; $cfg)? }; 292 let cfg_options = {
293 #[allow(unused_mut)]
294 let mut cfg = ::ra_cfg::CfgOptions::default();
295 $(
296 $(
297 if 0 == 0 $(+ { drop($value); 1})? {
298 cfg.insert_atom($key.into());
299 }
300 $(cfg.insert_key_value($key.into(), $value.into());)?
301 )*
302 )?
303 cfg
304 };
290 res.0.push(( 305 res.0.push((
291 $crate_name.to_string(), 306 $crate_name.to_string(),
292 ($crate_path.to_string(), edition, cfg_options, vec![$($dep.to_string()),*]) 307 ($crate_path.to_string(), edition, cfg_options, vec![$($dep.to_string()),*])
diff --git a/crates/ra_hir/src/nameres/tests.rs b/crates/ra_hir/src/nameres/tests.rs
index 208c2f16f..8c6b40aaf 100644
--- a/crates/ra_hir/src/nameres/tests.rs
+++ b/crates/ra_hir/src/nameres/tests.rs
@@ -7,7 +7,6 @@ mod mod_resolution;
7use std::sync::Arc; 7use std::sync::Arc;
8 8
9use insta::assert_snapshot; 9use insta::assert_snapshot;
10use ra_cfg::CfgOptions;
11use ra_db::SourceDatabase; 10use ra_db::SourceDatabase;
12use test_utils::covers; 11use test_utils::covers;
13 12
@@ -561,13 +560,11 @@ fn cfg_test() {
561 "#, 560 "#,
562 crate_graph! { 561 crate_graph! {
563 "main": ("/main.rs", ["std"]), 562 "main": ("/main.rs", ["std"]),
564 "std": ("/lib.rs", [], { 563 "std": ("/lib.rs", [], cfg = {
565 let mut opts = CfgOptions::default(); 564 "test",
566 opts.insert_atom("test".into()); 565 "feature" = "foo",
567 opts.insert_key_value("feature".into(), "foo".into()); 566 "feature" = "bar",
568 opts.insert_key_value("feature".into(), "bar".into()); 567 "opt" = "42",
569 opts.insert_key_value("opt".into(), "42".into());
570 opts
571 }), 568 }),
572 }, 569 },
573 ); 570 );
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index b16b48258..263b61a59 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -3,7 +3,6 @@ use std::sync::Arc;
3 3
4use insta::assert_snapshot; 4use insta::assert_snapshot;
5 5
6use ra_cfg::CfgOptions;
7use ra_db::{salsa::Database, FilePosition, SourceDatabase}; 6use ra_db::{salsa::Database, FilePosition, SourceDatabase};
8use ra_syntax::{ 7use ra_syntax::{
9 algo, 8 algo,
@@ -62,11 +61,7 @@ impl S {
62"#, 61"#,
63 ); 62 );
64 db.set_crate_graph_from_fixture(crate_graph! { 63 db.set_crate_graph_from_fixture(crate_graph! {
65 "main": ("/main.rs", ["foo"], { 64 "main": ("/main.rs", ["foo"], cfg = { "test" }),
66 let mut opts = CfgOptions::default();
67 opts.insert_atom("test".into());
68 opts
69 }),
70 "foo": ("/foo.rs", []), 65 "foo": ("/foo.rs", []),
71 }); 66 });
72 assert_eq!("(i32, {unknown}, i32, {unknown})", type_at_pos(&db, pos)); 67 assert_eq!("(i32, {unknown}, i32, {unknown})", type_at_pos(&db, pos));