Skip to content

Commit cbe4e8c

Browse files
committed
Make parser location optional
1 parent aabc96d commit cbe4e8c

File tree

9 files changed

+18
-14
lines changed

9 files changed

+18
-14
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ jobs:
3737

3838
- uses: Swatinem/rust-cache@v2
3939

40+
- name: run tests with default features
41+
run: cargo test --all
4042
- name: run tests with embedded parser
4143
run: cargo test --all --no-default-features
4244
- name: run tests with generated parser

Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ members = [
1616
]
1717

1818
[workspace.dependencies]
19-
rustpython-ast = { path = "ast", version = "0.2.0" }
20-
rustpython-parser-core = { path = "core", version = "0.2.0" }
19+
rustpython-ast = { path = "ast", version = "0.2.0", default-features = false }
20+
rustpython-parser-core = { path = "core", version = "0.2.0", default-features = false }
2121
rustpython-literal = { path = "literal", version = "0.2.0" }
22-
ruff_text_size = { path = "ruff_text_size" }
23-
ruff_source_location = { path = "ruff_source_location" }
2422

2523
ahash = "0.7.6"
2624
anyhow = "1.0.45"

ast/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ repository = "https://github.com/RustPython/RustPython"
88
license = "MIT"
99

1010
[features]
11-
default = ["constant-optimization", "fold", "source-code"]
11+
default = ["location"]
1212
constant-optimization = ["fold"]
13-
source-code = ["fold"]
13+
location = ["fold", "rustpython-parser-core/location"]
1414
fold = []
1515
unparse = ["rustpython-literal"]
1616
visitor = []

ast/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mod generic {
88
include!("gen/generic.rs");
99
}
1010
mod impls;
11-
#[cfg(feature = "source-code")]
11+
#[cfg(feature = "location")]
1212
mod source_locator;
1313
#[cfg(feature = "unparse")]
1414
mod unparse;
@@ -32,11 +32,12 @@ mod visitor {
3232
include!("gen/visitor.rs");
3333
}
3434

35-
#[cfg(feature = "source-code")]
35+
#[cfg(feature = "location")]
3636
pub mod located {
3737
include!("gen/located.rs");
3838
}
3939

40+
#[cfg(feature = "location")]
4041
pub use rustpython_parser_core::source_code;
4142
#[cfg(feature = "visitor")]
4243
pub use visitor::Visitor;

core/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ serde = { version = "1.0.133", optional = true, default-features = false, featur
2020
lz4_flex = "0.9.2"
2121

2222
[features]
23-
default = ["source-code"]
24-
source-code = ["ruff_source_location"]
23+
default = []
24+
location = ["ruff_source_location"]

core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
mod error;
55
mod format;
66
pub mod mode;
7-
#[cfg(feature = "source-code")]
7+
#[cfg(feature = "location")]
88
pub mod source_code;
99

1010
pub use error::BaseError;

parser/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ license = "MIT"
99
edition = "2021"
1010

1111
[features]
12-
default = []
12+
default = ["location"]
13+
location = ["rustpython-ast/location"]
1314
serde = ["dep:serde", "rustpython-parser-core/serde"]
1415

1516
[build-dependencies]

parser/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@
113113
#![doc(html_root_url = "https://docs.rs/rustpython-parser/")]
114114

115115
pub use rustpython_ast as ast;
116-
pub use rustpython_parser_core::{source_code, text_size, Mode};
116+
#[cfg(feature = "location")]
117+
pub use rustpython_parser_core::source_code;
118+
pub use rustpython_parser_core::{text_size, Mode};
117119

118120
mod function;
119121
// Skip flattening lexer to distinguish from full parser

ruff_source_location/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ rust-version = { workspace = true }
1111
[lib]
1212

1313
[dependencies]
14-
ruff_text_size = { workspace = true, features = ["serde"] }
14+
ruff_text_size = { path = "../ruff_text_size" }
1515

1616
memchr = "2.5.0"
1717
once_cell = { workspace = true }

0 commit comments

Comments
 (0)