chore: Make rust-analyzer faster (#2962)

This commit is contained in:
Donny/강동윤 2021-12-03 23:14:33 +09:00 committed by GitHub
parent c346f12b32
commit 02322aaa99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 2 deletions

View File

@ -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"
]
}

2
Cargo.lock generated
View File

@ -3467,7 +3467,7 @@ dependencies = [
[[package]]
name = "testing_macros"
version = "0.2.4"
version = "0.2.5"
dependencies = [
"anyhow",
"glob",

View File

@ -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

View File

@ -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]");