Skip to content

Commit 35a33f0

Browse files
authored
[ty] Merge ty_macros into ruff_macros (#19229)
1 parent f32f7a3 commit 35a33f0

File tree

8 files changed

+22
-62
lines changed

8 files changed

+22
-62
lines changed

Cargo.lock

Lines changed: 1 addition & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ ruff_workspace = { path = "crates/ruff_workspace" }
4141

4242
ty = { path = "crates/ty" }
4343
ty_ide = { path = "crates/ty_ide" }
44-
ty_macros = { path = "crates/ty_macros" }
4544
ty_project = { path = "crates/ty_project", default-features = false }
4645
ty_python_semantic = { path = "crates/ty_python_semantic" }
4746
ty_server = { path = "crates/ty_server" }
@@ -85,7 +84,7 @@ get-size2 = { version = "0.5.0", features = [
8584
"derive",
8685
"smallvec",
8786
"hashbrown",
88-
"compact-str"
87+
"compact-str",
8988
] }
9089
glob = { version = "0.3.1" }
9190
globset = { version = "0.4.14" }
@@ -175,7 +174,7 @@ tracing-subscriber = { version = "0.3.18", default-features = false, features =
175174
"env-filter",
176175
"fmt",
177176
"ansi",
178-
"smallvec"
177+
"smallvec",
179178
] }
180179
tryfn = { version = "0.2.1" }
181180
typed-arena = { version = "2.0.2" }
@@ -185,11 +184,7 @@ unicode-width = { version = "0.2.0" }
185184
unicode_names2 = { version = "1.2.2" }
186185
unicode-normalization = { version = "0.1.23" }
187186
url = { version = "2.5.0" }
188-
uuid = { version = "1.6.1", features = [
189-
"v4",
190-
"fast-rng",
191-
"macro-diagnostics",
192-
] }
187+
uuid = { version = "1.6.1", features = ["v4", "fast-rng", "macro-diagnostics"] }
193188
walkdir = { version = "2.3.2" }
194189
wasm-bindgen = { version = "0.2.92" }
195190
wasm-bindgen-test = { version = "0.3.42" }
@@ -224,8 +219,8 @@ must_use_candidate = "allow"
224219
similar_names = "allow"
225220
single_match_else = "allow"
226221
too_many_lines = "allow"
227-
needless_continue = "allow" # An explicit continue can be more readable, especially if the alternative is an empty block.
228-
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.
222+
needless_continue = "allow" # An explicit continue can be more readable, especially if the alternative is an empty block.
223+
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.
229224
# Without the hashes we run into a `rustfmt` bug in some snapshot tests, see #13250
230225
needless_raw_string_hashes = "allow"
231226
# Disallowed restriction lints
File renamed without changes.

crates/ruff_macros/src/lib.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! This crate implements internal macros for the `ruff` library.
1+
//! This crate implements internal macros for the `ruff` and `ty` libraries.
22
33
use crate::cache_key::derive_cache_key;
44
use crate::newtype_index::generate_newtype_index;
@@ -11,6 +11,7 @@ mod combine;
1111
mod combine_options;
1212
mod config;
1313
mod derive_message_formats;
14+
mod env_vars;
1415
mod kebab_case;
1516
mod map_codes;
1617
mod newtype_index;
@@ -144,3 +145,15 @@ pub fn newtype_index(_metadata: TokenStream, input: TokenStream) -> TokenStream
144145

145146
TokenStream::from(output)
146147
}
148+
149+
/// Generates metadata for environment variables declared in the impl block.
150+
///
151+
/// This attribute macro should be applied to an `impl EnvVars` block.
152+
/// It will generate a `metadata()` method that returns all non-hidden
153+
/// environment variables with their documentation.
154+
#[proc_macro_attribute]
155+
pub fn attribute_env_vars_metadata(_attr: TokenStream, item: TokenStream) -> TokenStream {
156+
let input = parse_macro_input!(item as syn::ItemImpl);
157+
158+
env_vars::attribute_env_vars_metadata(input).into()
159+
}

crates/ty_macros/Cargo.toml

Lines changed: 0 additions & 21 deletions
This file was deleted.

crates/ty_macros/src/lib.rs

Lines changed: 0 additions & 18 deletions
This file was deleted.

crates/ty_static/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ doctest = false
1616
workspace = true
1717

1818
[dependencies]
19-
ty_macros = { workspace = true }
19+
ruff_macros = { workspace = true }

crates/ty_static/src/env_vars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use ty_macros::attribute_env_vars_metadata;
1+
use ruff_macros::attribute_env_vars_metadata;
22

33
/// Declares all environment variable used throughout `ty` and its crates.
44
pub struct EnvVars;

0 commit comments

Comments
 (0)