diff --git a/.vscode/settings.json b/.vscode/settings.json index c19c983237e..f6f1fb2d0d7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -20,4 +20,8 @@ "eslint.enable": false, "cSpell.allowCompoundWords": true, "cSpell.caseSensitive": true, + "rust-analyzer.checkOnSave.features": [ + // We use this to make IDE faster + "rust-analyzer" + ] } \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 29e5a07ad61..09cfc98c716 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3467,7 +3467,7 @@ dependencies = [ [[package]] name = "testing_macros" -version = "0.2.4" +version = "0.2.5" dependencies = [ "anyhow", "glob", diff --git a/crates/testing_macros/Cargo.toml b/crates/testing_macros/Cargo.toml index 5af53658109..1338e1116bd 100644 --- a/crates/testing_macros/Cargo.toml +++ b/crates/testing_macros/Cargo.toml @@ -6,7 +6,11 @@ edition = "2018" license = "Apache-2.0" name = "testing_macros" repository = "https://github.com/swc-project/swc.git" -version = "0.2.4" +version = "0.2.5" + +[features] +# Skip generating fixtures so the editor becomes faster again +rust-analyzer = [] [lib] proc-macro = true diff --git a/crates/testing_macros/src/lib.rs b/crates/testing_macros/src/lib.rs index 1d19e38162f..50ebb0d55c2 100644 --- a/crates/testing_macros/src/lib.rs +++ b/crates/testing_macros/src/lib.rs @@ -1,3 +1,4 @@ +use pmutil::q; use proc_macro::TokenStream; use quote::ToTokens; use syn::ItemFn; @@ -54,6 +55,15 @@ mod fixture; #[proc_macro_attribute] pub fn fixture(attr: TokenStream, item: TokenStream) -> TokenStream { let item: ItemFn = syn::parse(item).expect("failed to parse input as a function item"); + + if cfg!(feature = "rust-analyzer") { + return q!(Vars { item }, { + #[allow(unused)] + item + }) + .into(); + } + let config: self::fixture::Config = syn::parse(attr).expect("failed to parse input passed to #[fixture]");