Skip to content

Commit e6e029a

Browse files
authored
Update salsa (astral-sh#19258)
## Summary Pulls in salsa-rs/salsa#934.
1 parent 64f9481 commit e6e029a

File tree

7 files changed

+69
-26
lines changed

7 files changed

+69
-26
lines changed

Cargo.lock

Lines changed: 13 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ regex-automata = { version = "0.4.9" }
138138
rustc-hash = { version = "2.0.0" }
139139
rustc-stable-hash = { version = "0.1.2" }
140140
# When updating salsa, make sure to also update the revision in `fuzz/Cargo.toml`
141-
salsa = { git = "https://github.com/salsa-rs/salsa", rev = "fc00eba89e5dcaa5edba51c41aa5f309b5cb126b" }
141+
salsa = { git = "https://github.com/salsa-rs/salsa", rev = "dba66f1a37acca014c2402f231ed5b361bd7d8fe" }
142142
schemars = { version = "0.8.16" }
143143
seahash = { version = "4.1.0" }
144144
serde = { version = "1.0.197", features = ["derive"] }

crates/ruff_wasm/src/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,31 @@ struct ExpandedEdit {
7777
content: Option<String>,
7878
}
7979

80+
/// Perform global constructor initialization.
81+
#[cfg(target_family = "wasm")]
82+
#[expect(unsafe_code)]
83+
pub fn before_main() {
84+
unsafe extern "C" {
85+
fn __wasm_call_ctors();
86+
}
87+
88+
// Salsa uses the `inventory` crate, which registers global constructors that may need to be
89+
// called explicitly on WASM. See <https://github.com/dtolnay/inventory/blob/master/src/lib.rs#L105>
90+
// for details.
91+
unsafe {
92+
__wasm_call_ctors();
93+
}
94+
}
95+
96+
#[cfg(not(target_family = "wasm"))]
97+
pub fn before_main() {}
98+
8099
#[wasm_bindgen(start)]
81100
pub fn run() {
82101
use log::Level;
83102

103+
before_main();
104+
84105
// When the `console_error_panic_hook` feature is enabled, we can call the
85106
// `set_panic_hook` function at least once during initialization, and then
86107
// we will get better error messages if our code ever panics.

crates/ruff_wasm/tests/api.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ macro_rules! check {
2121

2222
#[wasm_bindgen_test]
2323
fn empty_config() {
24+
ruff_wasm::before_main();
25+
2426
check!(
2527
"if (1, 2):\n pass",
2628
r#"{}"#,
@@ -42,6 +44,8 @@ fn empty_config() {
4244

4345
#[wasm_bindgen_test]
4446
fn syntax_error() {
47+
ruff_wasm::before_main();
48+
4549
check!(
4650
"x =\ny = 1\n",
4751
r#"{}"#,
@@ -63,6 +67,8 @@ fn syntax_error() {
6367

6468
#[wasm_bindgen_test]
6569
fn unsupported_syntax_error() {
70+
ruff_wasm::before_main();
71+
6672
check!(
6773
"match 2:\n case 1: ...",
6874
r#"{"target-version": "py39"}"#,
@@ -84,11 +90,15 @@ fn unsupported_syntax_error() {
8490

8591
#[wasm_bindgen_test]
8692
fn partial_config() {
93+
ruff_wasm::before_main();
94+
8795
check!("if (1, 2):\n pass", r#"{"ignore": ["F"]}"#, []);
8896
}
8997

9098
#[wasm_bindgen_test]
9199
fn partial_nested_config() {
100+
ruff_wasm::before_main();
101+
92102
let config = r#"{
93103
"select": ["Q"],
94104
"flake8-quotes": {

crates/ty_wasm/src/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,31 @@ pub fn version() -> String {
3232
.to_string()
3333
}
3434

35+
/// Perform global constructor initialization.
36+
#[cfg(target_family = "wasm")]
37+
#[expect(unsafe_code)]
38+
pub fn before_main() {
39+
unsafe extern "C" {
40+
fn __wasm_call_ctors();
41+
}
42+
43+
// Salsa uses the `inventory` crate, which registers global constructors that may need to be
44+
// called explicitly on WASM. See <https://github.com/dtolnay/inventory/blob/master/src/lib.rs#L105>
45+
// for details.
46+
unsafe {
47+
__wasm_call_ctors();
48+
}
49+
}
50+
51+
#[cfg(not(target_family = "wasm"))]
52+
pub fn before_main() {}
53+
3554
#[wasm_bindgen(start)]
3655
pub fn run() {
3756
use log::Level;
3857

58+
before_main();
59+
3960
ruff_db::set_program_version(version()).unwrap();
4061

4162
// When the `console_error_panic_hook` feature is enabled, we can call the

crates/ty_wasm/tests/api.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ use wasm_bindgen_test::wasm_bindgen_test;
55

66
#[wasm_bindgen_test]
77
fn check() {
8+
ty_wasm::before_main();
9+
810
let mut workspace = Workspace::new(
911
"/",
1012
PositionEncoding::Utf32,

fuzz/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ ty_python_semantic = { path = "../crates/ty_python_semantic" }
3030
ty_vendored = { path = "../crates/ty_vendored" }
3131

3232
libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer", default-features = false }
33-
salsa = { git = "https://github.com/salsa-rs/salsa", rev = "fc00eba89e5dcaa5edba51c41aa5f309b5cb126b" }
33+
salsa = { git = "https://github.com/salsa-rs/salsa", rev = "dba66f1a37acca014c2402f231ed5b361bd7d8fe" }
3434
similar = { version = "2.5.0" }
3535
tracing = { version = "0.1.40" }
3636

0 commit comments

Comments
 (0)