diff options
Diffstat (limited to 'crates/ra_proc_macro_srv')
-rw-r--r-- | crates/ra_proc_macro_srv/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_proc_macro_srv/src/dylib.rs | 2 | ||||
-rw-r--r-- | crates/ra_proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt | 2 | ||||
-rw-r--r-- | crates/ra_proc_macro_srv/src/tests/mod.rs | 6 | ||||
-rw-r--r-- | crates/ra_proc_macro_srv/src/tests/utils.rs | 7 |
5 files changed, 9 insertions, 10 deletions
diff --git a/crates/ra_proc_macro_srv/Cargo.toml b/crates/ra_proc_macro_srv/Cargo.toml index bb3003278..12ce497f8 100644 --- a/crates/ra_proc_macro_srv/Cargo.toml +++ b/crates/ra_proc_macro_srv/Cargo.toml | |||
@@ -4,6 +4,7 @@ name = "ra_proc_macro_srv" | |||
4 | version = "0.1.0" | 4 | version = "0.1.0" |
5 | authors = ["rust-analyzer developers"] | 5 | authors = ["rust-analyzer developers"] |
6 | publish = false | 6 | publish = false |
7 | license = "MIT OR Apache-2.0" | ||
7 | 8 | ||
8 | [lib] | 9 | [lib] |
9 | doctest = false | 10 | doctest = false |
@@ -22,3 +23,4 @@ cargo_metadata = "0.10.0" | |||
22 | difference = "2.0.0" | 23 | difference = "2.0.0" |
23 | # used as proc macro test target | 24 | # used as proc macro test target |
24 | serde_derive = "1.0.106" | 25 | serde_derive = "1.0.106" |
26 | ra_toolchain = { path = "../ra_toolchain" } | ||
diff --git a/crates/ra_proc_macro_srv/src/dylib.rs b/crates/ra_proc_macro_srv/src/dylib.rs index aa84e951c..1addbbd54 100644 --- a/crates/ra_proc_macro_srv/src/dylib.rs +++ b/crates/ra_proc_macro_srv/src/dylib.rs | |||
@@ -45,7 +45,7 @@ fn find_registrar_symbol(file: &Path) -> io::Result<Option<String>> { | |||
45 | // https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dlsym.3.html | 45 | // https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dlsym.3.html |
46 | // Unlike other dyld API's, the symbol name passed to dlsym() must NOT be | 46 | // Unlike other dyld API's, the symbol name passed to dlsym() must NOT be |
47 | // prepended with an underscore. | 47 | // prepended with an underscore. |
48 | if s.name.starts_with("_") { | 48 | if s.name.starts_with('_') { |
49 | &s.name[1..] | 49 | &s.name[1..] |
50 | } else { | 50 | } else { |
51 | &s.name | 51 | &s.name |
diff --git a/crates/ra_proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt b/crates/ra_proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt index bc010cfe9..e6fd21610 100644 --- a/crates/ra_proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt +++ b/crates/ra_proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt | |||
@@ -14,7 +14,7 @@ SUBTREE $ | |||
14 | PUNCH , [alone] 4294967295 | 14 | PUNCH , [alone] 4294967295 |
15 | IDENT unused_qualifications 4294967295 | 15 | IDENT unused_qualifications 4294967295 |
16 | IDENT const 4294967295 | 16 | IDENT const 4294967295 |
17 | IDENT _IMPL_SERIALIZE_FOR_Foo 4294967295 | 17 | IDENT _ 4294967295 |
18 | PUNCH : [alone] 4294967295 | 18 | PUNCH : [alone] 4294967295 |
19 | SUBTREE () 4294967295 | 19 | SUBTREE () 4294967295 |
20 | PUNCH = [alone] 4294967295 | 20 | PUNCH = [alone] 4294967295 |
diff --git a/crates/ra_proc_macro_srv/src/tests/mod.rs b/crates/ra_proc_macro_srv/src/tests/mod.rs index 82cefbb29..8e6f28abd 100644 --- a/crates/ra_proc_macro_srv/src/tests/mod.rs +++ b/crates/ra_proc_macro_srv/src/tests/mod.rs | |||
@@ -11,7 +11,7 @@ fn test_derive_serialize_proc_macro() { | |||
11 | "serde_derive", | 11 | "serde_derive", |
12 | "Serialize", | 12 | "Serialize", |
13 | "1.0", | 13 | "1.0", |
14 | r##"struct Foo {}"##, | 14 | r"struct Foo {}", |
15 | include_str!("fixtures/test_serialize_proc_macro.txt"), | 15 | include_str!("fixtures/test_serialize_proc_macro.txt"), |
16 | ); | 16 | ); |
17 | } | 17 | } |
@@ -22,9 +22,7 @@ fn test_derive_serialize_proc_macro_failed() { | |||
22 | "serde_derive", | 22 | "serde_derive", |
23 | "Serialize", | 23 | "Serialize", |
24 | "1.0", | 24 | "1.0", |
25 | r##" | 25 | r"struct {}", |
26 | struct {} | ||
27 | "##, | ||
28 | r##" | 26 | r##" |
29 | SUBTREE $ | 27 | SUBTREE $ |
30 | IDENT compile_error 4294967295 | 28 | IDENT compile_error 4294967295 |
diff --git a/crates/ra_proc_macro_srv/src/tests/utils.rs b/crates/ra_proc_macro_srv/src/tests/utils.rs index 84348b5de..dcb00671f 100644 --- a/crates/ra_proc_macro_srv/src/tests/utils.rs +++ b/crates/ra_proc_macro_srv/src/tests/utils.rs | |||
@@ -2,7 +2,6 @@ | |||
2 | 2 | ||
3 | use crate::dylib; | 3 | use crate::dylib; |
4 | use crate::ProcMacroSrv; | 4 | use crate::ProcMacroSrv; |
5 | pub use difference::Changeset as __Changeset; | ||
6 | use ra_proc_macro::ListMacrosTask; | 5 | use ra_proc_macro::ListMacrosTask; |
7 | use std::str::FromStr; | 6 | use std::str::FromStr; |
8 | use test_utils::assert_eq_text; | 7 | use test_utils::assert_eq_text; |
@@ -13,7 +12,7 @@ mod fixtures { | |||
13 | 12 | ||
14 | // Use current project metadata to get the proc-macro dylib path | 13 | // Use current project metadata to get the proc-macro dylib path |
15 | pub fn dylib_path(crate_name: &str, version: &str) -> std::path::PathBuf { | 14 | pub fn dylib_path(crate_name: &str, version: &str) -> std::path::PathBuf { |
16 | let command = Command::new("cargo") | 15 | let command = Command::new(ra_toolchain::cargo()) |
17 | .args(&["check", "--message-format", "json"]) | 16 | .args(&["check", "--message-format", "json"]) |
18 | .output() | 17 | .output() |
19 | .unwrap() | 18 | .unwrap() |
@@ -45,12 +44,12 @@ pub fn assert_expand( | |||
45 | crate_name: &str, | 44 | crate_name: &str, |
46 | macro_name: &str, | 45 | macro_name: &str, |
47 | version: &str, | 46 | version: &str, |
48 | fixture: &str, | 47 | ra_fixture: &str, |
49 | expect: &str, | 48 | expect: &str, |
50 | ) { | 49 | ) { |
51 | let path = fixtures::dylib_path(crate_name, version); | 50 | let path = fixtures::dylib_path(crate_name, version); |
52 | let expander = dylib::Expander::new(&path).unwrap(); | 51 | let expander = dylib::Expander::new(&path).unwrap(); |
53 | let fixture = parse_string(fixture).unwrap(); | 52 | let fixture = parse_string(ra_fixture).unwrap(); |
54 | 53 | ||
55 | let res = expander.expand(macro_name, &fixture.subtree, None).unwrap(); | 54 | let res = expander.expand(macro_name, &fixture.subtree, None).unwrap(); |
56 | assert_eq_text!(&format!("{:?}", res), &expect.trim()); | 55 | assert_eq_text!(&format!("{:?}", res), &expect.trim()); |