Skip to content

Commit ec2ddd7

Browse files
Moving to new Salsa version using query-group repo (DRAFT)
This is a WIP * Using an updated version of query-group to better support lifetimes. * Embedded query-group in cairo-lang-proc-macros. * cairo-lang-proc-macro's derive debug with db now supprots generics better. * Using salsa::Update on non salsa structs to get the db to work correctly. * Moved some SmolStr and Arc<str> to use be interned for salsa::Update support. * Implemented Ord for SmolStrId to have BTreeMap's salsa::Update work. * Removing upcasting and 'static where applicable * Adding alot of <'_> for a happy clippy. * Debug with db now supports lifetimes. Fixed implementations across the codebase. * Debug with db now has an associated type for the db for better support of upcasting. * Upgraded cairo-lang-debug by: 1. saying Db has the salsa::Database trait 2. making Dummy in test not use shortid 3. Debug with Db can make some trouble but using .long where needed fixes it. * cairo-lang-utils: 1 .The short_id macro is not really needed so I gutted it and have short_id double interned 1.1. I made short_id have a single long field that is returned by ref. 2. Implemented salsa::Update for OrderedHashMap. 3. Implemented salsa::Update for OrderedHashSet. 4. Added an as_intern_id and from_intern_id using asid and fromid 5. No need for upcast to be static * cairo-lang-filesystem 1. Removed all interned valued from input. 2. Updated code with lifetimes to better support <'db> interned values. 3. Tests needed updating as set methods are a bit more tricky now with lifetimes. 4. Added utility function for setting input values with using lifetimed objects. 5. Added macro_rules! to set_crate_config and override_file_content so they still accept a short id. * cairo-lang-syntax: + Updated all code to use lifetimes. + Updated all code to use the new query-group. + Updated codegen. + Updated ast. * cairo-lang-diagnostics: + Updated all code to use lifetimes. + Updated all code to use the new query-group. + Added lifetime to DiagnosticEntry and DiagnosticBuilder as it was necessary by plugin tests. * cairo-lang-parser: + Updated all code to use lifetimes. + Updated all code to use the new query-group. + Removed the references to empty data structs as they are no longer needed. + Using long to turn StrId into a ref for the parser. * cairo-lang-sierra + No need for internkey (as query group will use #[salsa::interned] instead) * cairo-lang-defs + Added lifetime to db + Added lifetime to diagnostic_utils + Added lifetime to ids + Fixing macros in ids to support lifetimes + Using self.long(db) instead of lookup_intern to get a ref with a 'db lifetime + Change from Arc<[T]> to Arc<Vec<T>> which allows for salsa::Update. + Tests to use macro_rules! to get lifetimes right. + Updated tests to work with all the changes + Fixed debug print formatting. * cairo-lang-plugins: + Updated all code to use lifetimes. Added preparation for semantic db. Debug lifetime fixes. Cycle support for queries More salsa::Update support. More lifetimes. Update for unordered_hash_map and unordered_hash_set. Deque wrapper and Update for it. Some rewriter macro support. Moved priv queries back to salsa db - using update on FunctionBodyData - Update assumes that ExprId and PatternId are from the FunctionBody in the struct. AI helped a bit: Core Upgrade Migrated to a new Salsa version with better lifetime support by embedding an updated query-group implementation directly into cairo-lang-proc-macros Added comprehensive lifetime annotations (<'db>, <'_>) throughout the codebase to support the new Salsa architecture Key Technical Changes Salsa Integration Improvements: Implemented salsa::Update trait for non-Salsa structs (OrderedHashMap, OrderedHashSet, Deque wrapper) Converted SmolStr and Arc<str> to interned values for Salsa compatibility Added Ord implementation for SmolStrId to support BTreeMap's salsa::Update Database & Query System: Removed static lifetime requirements and upcasting where possible Added cycle support for queries Improved generic support in proc-macro's derive debug with db Major Crate Updates: cairo-lang-proc-macros: Added 11 new test files and embedded query-group functionality cairo-lang-utils: Gutted short_id macro, added Deque wrapper, intern conversion utilities cairo-lang-filesystem: Removed interned values from input, added utility functions for lifetime-aware inputs All syntax/parser/semantic crates: Updated to use explicit lifetimes throughout New Functionality Added preparation for semantic database Improved macro support for lifetimes in test utilities Changed from Arc<[T]> to Arc<Vec<T>> for salsa::Update compatibility This is a foundational change that modernizes the entire Cairo compiler's incremental computation infrastructure to better handle borrowed data and lifetimes. commit-id:9e4ac020
1 parent 6e25f63 commit ec2ddd7

File tree

170 files changed

+26627
-22642
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+26627
-22642
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ opt-level = 3
1818
[profile.ci-dev.package."bimap"]
1919

2020
opt-level = 3
21-
[profile.ci-dev.package."rust-analyzer-salsa"]
21+
[profile.ci-dev.package."salsa"]
2222
opt-level = 3
2323

2424
[workspace]
@@ -101,7 +101,9 @@ derivative = "2.2.0"
101101
diffy = "0.4.2"
102102
env_logger = "0.11.6"
103103
genco = "0.17.10"
104-
good_lp = { version = "1.11.0", features = ["minilp"], default-features = false }
104+
good_lp = { version = "1.11.0", features = [
105+
"minilp",
106+
], default-features = false }
105107
hashbrown = "0.15.2"
106108
id-arena = "2.2.1"
107109
ignore = "0.4.23"
@@ -125,10 +127,13 @@ quote = "1.0.38"
125127
rand = "0.9.0"
126128
rayon = "1.10.0"
127129
rstest = "0.25.0"
128-
salsa = { package = "rust-analyzer-salsa", version = "0.17.0-pre.6" }
130+
salsa = "0.22.0"
129131
schemars = { version = "0.8.21", features = ["preserve_order"] }
130132
semver = { version = "1.0.25", features = ["serde"] }
131-
serde = { version = "1.0.217", default-features = false, features = ["derive","rc"] }
133+
serde = { version = "1.0.217", default-features = false, features = [
134+
"derive",
135+
"rc",
136+
] }
132137
serde_json = "1.0.138"
133138
typetag = "0.2"
134139
sha2 = "0.10.8"

crates/cairo-lang-compiler/src/db.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,37 +256,37 @@ pub fn validate_corelib(db: &(dyn FilesGroup + 'static)) -> Result<()> {
256256
}
257257

258258
impl Upcast<dyn FilesGroup> for RootDatabase {
259-
fn upcast(&self) -> &(dyn FilesGroup + 'static) {
259+
fn upcast(&self) -> &(dyn FilesGroup) {
260260
self
261261
}
262262
}
263263
impl Upcast<dyn SyntaxGroup> for RootDatabase {
264-
fn upcast(&self) -> &(dyn SyntaxGroup + 'static) {
264+
fn upcast(&self) -> &(dyn SyntaxGroup) {
265265
self
266266
}
267267
}
268268
impl Upcast<dyn DefsGroup> for RootDatabase {
269-
fn upcast(&self) -> &(dyn DefsGroup + 'static) {
269+
fn upcast(&self) -> &(dyn DefsGroup) {
270270
self
271271
}
272272
}
273273
impl Upcast<dyn SemanticGroup> for RootDatabase {
274-
fn upcast(&self) -> &(dyn SemanticGroup + 'static) {
274+
fn upcast(&self) -> &(dyn SemanticGroup) {
275275
self
276276
}
277277
}
278278
impl Upcast<dyn LoweringGroup> for RootDatabase {
279-
fn upcast(&self) -> &(dyn LoweringGroup + 'static) {
279+
fn upcast(&self) -> &(dyn LoweringGroup) {
280280
self
281281
}
282282
}
283283
impl Upcast<dyn SierraGenGroup> for RootDatabase {
284-
fn upcast(&self) -> &(dyn SierraGenGroup + 'static) {
284+
fn upcast(&self) -> &(dyn SierraGenGroup) {
285285
self
286286
}
287287
}
288288
impl Upcast<dyn ParserGroup> for RootDatabase {
289-
fn upcast(&self) -> &(dyn ParserGroup + 'static) {
289+
fn upcast(&self) -> &(dyn ParserGroup) {
290290
self
291291
}
292292
}

crates/cairo-lang-debug/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ description = "Debug utilities for query objects."
88

99
[dependencies]
1010
cairo-lang-utils = { path = "../cairo-lang-utils", version = "~2.11.4" }
11+
id-arena.workspace = true
12+
salsa.workspace = true
1113

1214
[dev-dependencies]
13-
cairo-lang-proc-macros = { path = "../cairo-lang-proc-macros"}
15+
cairo-lang-proc-macros = { path = "../cairo-lang-proc-macros" }
1416
env_logger.workspace = true
15-
salsa.workspace = true
1617
test-log.workspace = true

0 commit comments

Comments
 (0)