diff --git a/Cargo.lock b/Cargo.lock index 0748e715b6..9b51b5b6cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4189,15 +4189,6 @@ dependencies = [ "ty_vendored", ] -[[package]] -name = "ty_macros" -version = "0.0.0" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "ty_project" version = "0.0.0" @@ -4316,7 +4307,7 @@ dependencies = [ name = "ty_static" version = "0.0.1" dependencies = [ - "ty_macros", + "ruff_macros", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 6f66d2b334..4be307b42a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,6 @@ ruff_workspace = { path = "crates/ruff_workspace" } ty = { path = "crates/ty" } ty_ide = { path = "crates/ty_ide" } -ty_macros = { path = "crates/ty_macros" } ty_project = { path = "crates/ty_project", default-features = false } ty_python_semantic = { path = "crates/ty_python_semantic" } ty_server = { path = "crates/ty_server" } @@ -85,7 +84,7 @@ get-size2 = { version = "0.5.0", features = [ "derive", "smallvec", "hashbrown", - "compact-str" + "compact-str", ] } glob = { version = "0.3.1" } globset = { version = "0.4.14" } @@ -175,7 +174,7 @@ tracing-subscriber = { version = "0.3.18", default-features = false, features = "env-filter", "fmt", "ansi", - "smallvec" + "smallvec", ] } tryfn = { version = "0.2.1" } typed-arena = { version = "2.0.2" } @@ -185,11 +184,7 @@ unicode-width = { version = "0.2.0" } unicode_names2 = { version = "1.2.2" } unicode-normalization = { version = "0.1.23" } url = { version = "2.5.0" } -uuid = { version = "1.6.1", features = [ - "v4", - "fast-rng", - "macro-diagnostics", -] } +uuid = { version = "1.6.1", features = ["v4", "fast-rng", "macro-diagnostics"] } walkdir = { version = "2.3.2" } wasm-bindgen = { version = "0.2.92" } wasm-bindgen-test = { version = "0.3.42" } @@ -224,8 +219,8 @@ must_use_candidate = "allow" similar_names = "allow" single_match_else = "allow" too_many_lines = "allow" -needless_continue = "allow" # An explicit continue can be more readable, especially if the alternative is an empty block. -unnecessary_debug_formatting = "allow" # too many instances, the display also doesn't quote the path which is often desired in logs where we use them the most often. +needless_continue = "allow" # An explicit continue can be more readable, especially if the alternative is an empty block. +unnecessary_debug_formatting = "allow" # too many instances, the display also doesn't quote the path which is often desired in logs where we use them the most often. # Without the hashes we run into a `rustfmt` bug in some snapshot tests, see #13250 needless_raw_string_hashes = "allow" # Disallowed restriction lints diff --git a/crates/ty_macros/src/env_vars.rs b/crates/ruff_macros/src/env_vars.rs similarity index 100% rename from crates/ty_macros/src/env_vars.rs rename to crates/ruff_macros/src/env_vars.rs diff --git a/crates/ruff_macros/src/lib.rs b/crates/ruff_macros/src/lib.rs index 858b5db567..ef72240409 100644 --- a/crates/ruff_macros/src/lib.rs +++ b/crates/ruff_macros/src/lib.rs @@ -1,4 +1,4 @@ -//! This crate implements internal macros for the `ruff` library. +//! This crate implements internal macros for the `ruff` and `ty` libraries. use crate::cache_key::derive_cache_key; use crate::newtype_index::generate_newtype_index; @@ -11,6 +11,7 @@ mod combine; mod combine_options; mod config; mod derive_message_formats; +mod env_vars; mod kebab_case; mod map_codes; mod newtype_index; @@ -144,3 +145,15 @@ pub fn newtype_index(_metadata: TokenStream, input: TokenStream) -> TokenStream TokenStream::from(output) } + +/// Generates metadata for environment variables declared in the impl block. +/// +/// This attribute macro should be applied to an `impl EnvVars` block. +/// It will generate a `metadata()` method that returns all non-hidden +/// environment variables with their documentation. +#[proc_macro_attribute] +pub fn attribute_env_vars_metadata(_attr: TokenStream, item: TokenStream) -> TokenStream { + let input = parse_macro_input!(item as syn::ItemImpl); + + env_vars::attribute_env_vars_metadata(input).into() +} diff --git a/crates/ty_macros/Cargo.toml b/crates/ty_macros/Cargo.toml deleted file mode 100644 index 036262285d..0000000000 --- a/crates/ty_macros/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "ty_macros" -version = "0.0.0" -edition = { workspace = true } -rust-version = { workspace = true } -homepage = { workspace = true } -documentation = { workspace = true } -repository = { workspace = true } -authors = { workspace = true } -license = { workspace = true } - -[lib] -proc-macro = true - -[lints] -workspace = true - -[dependencies] -proc-macro2 = { workspace = true } -quote = { workspace = true } -syn = { workspace = true } diff --git a/crates/ty_macros/src/lib.rs b/crates/ty_macros/src/lib.rs deleted file mode 100644 index 219228a2db..0000000000 --- a/crates/ty_macros/src/lib.rs +++ /dev/null @@ -1,18 +0,0 @@ -//! This crate implements internal macros for the `ty` library. - -use proc_macro::TokenStream; -use syn::parse_macro_input; - -mod env_vars; - -/// Generates metadata for environment variables declared in the impl block. -/// -/// This attribute macro should be applied to an `impl EnvVars` block. -/// It will generate a `metadata()` method that returns all non-hidden -/// environment variables with their documentation. -#[proc_macro_attribute] -pub fn attribute_env_vars_metadata(_attr: TokenStream, item: TokenStream) -> TokenStream { - let input = parse_macro_input!(item as syn::ItemImpl); - - env_vars::attribute_env_vars_metadata(input).into() -} diff --git a/crates/ty_static/Cargo.toml b/crates/ty_static/Cargo.toml index 0fc33e8360..178df9282f 100644 --- a/crates/ty_static/Cargo.toml +++ b/crates/ty_static/Cargo.toml @@ -16,4 +16,4 @@ doctest = false workspace = true [dependencies] -ty_macros = { workspace = true } +ruff_macros = { workspace = true } diff --git a/crates/ty_static/src/env_vars.rs b/crates/ty_static/src/env_vars.rs index 399f3fd78a..486a01a187 100644 --- a/crates/ty_static/src/env_vars.rs +++ b/crates/ty_static/src/env_vars.rs @@ -1,4 +1,4 @@ -use ty_macros::attribute_env_vars_metadata; +use ruff_macros::attribute_env_vars_metadata; /// Declares all environment variable used throughout `ty` and its crates. pub struct EnvVars;