diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:11:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:13:23 +0000 |
commit | 20431706a863f92cb37dc512fef6e48d192aaf2c (patch) | |
tree | 2867f13f5fd5437ba628c67d7f87309ccadcd286 /src/tools/rust-analyzer/crates/proc-macro-srv | |
parent | Releasing progress-linux version 1.65.0+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-20431706a863f92cb37dc512fef6e48d192aaf2c.tar.xz rustc-20431706a863f92cb37dc512fef6e48d192aaf2c.zip |
Merging upstream version 1.66.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/rust-analyzer/crates/proc-macro-srv')
5 files changed, 23 insertions, 22 deletions
diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/abis/abi_sysroot/mod.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/abis/abi_sysroot/mod.rs index 44712f419..243972b04 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/abis/abi_sysroot/mod.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/abis/abi_sysroot/mod.rs @@ -11,6 +11,8 @@ use proc_macro_api::ProcMacroKind; use super::PanicMessage; +pub use ra_server::TokenStream; + pub(crate) struct Abi { exported_macros: Vec<proc_macro::bridge::client::ProcMacro>, } diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/abis/mod.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/abis/mod.rs index f7d3a3091..2f854bc15 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/abis/mod.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/abis/mod.rs @@ -32,8 +32,8 @@ mod abi_sysroot; include!(concat!(env!("OUT_DIR"), "/rustc_version.rs")); // Used by `test/utils.rs` -#[cfg(test)] -pub(crate) use abi_1_63::TokenStream as TestTokenStream; +#[cfg(all(test, feature = "sysroot-abi"))] +pub(crate) use abi_sysroot::TokenStream as TestTokenStream; use super::dylib::LoadProcMacroDylibError; pub(crate) use abi_1_58::Abi as Abi_1_58; @@ -144,3 +144,10 @@ impl Abi { } } } + +#[test] +fn test_version_check() { + let path = paths::AbsPathBuf::assert(crate::proc_macro_test_dylib_path()); + let info = proc_macro_api::read_dylib_info(&path).unwrap(); + assert!(info.version.1 >= 50); +} diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/lib.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/lib.rs index 3679bfc43..72a2dfe72 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/lib.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/lib.rs @@ -20,6 +20,8 @@ mod dylib; mod abis; +pub mod cli; + use std::{ collections::{hash_map::Entry, HashMap}, env, @@ -149,7 +151,10 @@ impl EnvSnapshot { } } -pub mod cli; +#[cfg(all(feature = "sysroot-abi", test))] +mod tests; #[cfg(test)] -mod tests; +pub fn proc_macro_test_dylib_path() -> std::path::PathBuf { + proc_macro_test::PROC_MACRO_TEST_LOCATION.into() +} diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/tests/mod.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/tests/mod.rs index 6339d56d0..b46cdddcf 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/tests/mod.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/tests/mod.rs @@ -2,10 +2,10 @@ #[macro_use] mod utils; -use expect_test::expect; -use paths::AbsPathBuf; use utils::*; +use expect_test::expect; + #[test] fn test_derive_empty() { assert_expand("DeriveEmpty", r#"struct S;"#, expect![[r#"SUBTREE $"#]]); @@ -157,10 +157,3 @@ fn list_test_macros() { DeriveError [CustomDerive]"#]] .assert_eq(&res); } - -#[test] -fn test_version_check() { - let path = AbsPathBuf::assert(fixtures::proc_macro_test_dylib_path()); - let info = proc_macro_api::read_dylib_info(&path).unwrap(); - assert!(info.version.1 >= 50); -} diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/tests/utils.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/tests/utils.rs index f881fe868..44b1b6588 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/tests/utils.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/tests/utils.rs @@ -1,15 +1,9 @@ //! utils used in proc-macro tests -use crate::dylib; -use crate::ProcMacroSrv; use expect_test::Expect; use std::str::FromStr; -pub mod fixtures { - pub fn proc_macro_test_dylib_path() -> std::path::PathBuf { - proc_macro_test::PROC_MACRO_TEST_LOCATION.into() - } -} +use crate::{dylib, proc_macro_test_dylib_path, ProcMacroSrv}; fn parse_string(code: &str) -> Option<crate::abis::TestTokenStream> { // This is a bit strange. We need to parse a string into a token stream into @@ -30,7 +24,7 @@ pub fn assert_expand_attr(macro_name: &str, ra_fixture: &str, attr_args: &str, e } fn assert_expand_impl(macro_name: &str, input: &str, attr: Option<&str>, expect: Expect) { - let path = fixtures::proc_macro_test_dylib_path(); + let path = proc_macro_test_dylib_path(); let expander = dylib::Expander::new(&path).unwrap(); let fixture = parse_string(input).unwrap(); let attr = attr.map(|attr| parse_string(attr).unwrap().into_subtree()); @@ -40,7 +34,7 @@ fn assert_expand_impl(macro_name: &str, input: &str, attr: Option<&str>, expect: } pub(crate) fn list() -> Vec<String> { - let dylib_path = fixtures::proc_macro_test_dylib_path(); + let dylib_path = proc_macro_test_dylib_path(); let mut srv = ProcMacroSrv::default(); let res = srv.list_macros(&dylib_path).unwrap(); res.into_iter().map(|(name, kind)| format!("{} [{:?}]", name, kind)).collect() |