diff --git a/Cargo.lock b/Cargo.lock index 76924df5..88abe086 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,8 +187,8 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "cairo-lang-casm" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "cairo-lang-utils", "indoc", @@ -200,8 +200,8 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "anyhow", "cairo-lang-defs", @@ -225,16 +225,16 @@ dependencies = [ [[package]] name = "cairo-lang-debug" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -249,8 +249,8 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -260,8 +260,8 @@ dependencies = [ [[package]] name = "cairo-lang-eq-solver" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "cairo-lang-utils", "good_lp", @@ -269,8 +269,8 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -284,8 +284,8 @@ dependencies = [ [[package]] name = "cairo-lang-formatter" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "anyhow", "cairo-lang-diagnostics", @@ -298,14 +298,13 @@ dependencies = [ "itertools 0.12.1", "rust-analyzer-salsa", "serde", - "smol_str", "thiserror", ] [[package]] name = "cairo-lang-lowering" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -320,6 +319,7 @@ dependencies = [ "itertools 0.12.1", "log", "num-bigint", + "num-integer", "num-traits", "rust-analyzer-salsa", "smol_str", @@ -327,8 +327,8 @@ dependencies = [ [[package]] name = "cairo-lang-parser" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -346,8 +346,8 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -362,10 +362,15 @@ dependencies = [ "smol_str", ] +[[package]] +name = "cairo-lang-primitive-token" +version = "1.0.0" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" + [[package]] name = "cairo-lang-proc-macros" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "cairo-lang-debug", "quote", @@ -374,21 +379,20 @@ dependencies = [ [[package]] name = "cairo-lang-project" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", "serde", - "smol_str", "thiserror", "toml", ] [[package]] name = "cairo-lang-semantic" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -406,14 +410,15 @@ dependencies = [ "num-bigint", "num-traits", "rust-analyzer-salsa", + "sha3", "smol_str", "toml", ] [[package]] name = "cairo-lang-sierra" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "anyhow", "cairo-lang-utils", @@ -438,8 +443,8 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -453,8 +458,8 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -468,8 +473,8 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -491,8 +496,8 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "assert_matches", "cairo-lang-casm", @@ -511,8 +516,8 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -520,8 +525,8 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -549,8 +554,8 @@ dependencies = [ [[package]] name = "cairo-lang-starknet-classes" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "cairo-lang-casm", "cairo-lang-sierra", @@ -571,11 +576,12 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", + "cairo-lang-primitive-token", "cairo-lang-utils", "num-bigint", "num-traits", @@ -586,8 +592,8 @@ dependencies = [ [[package]] name = "cairo-lang-syntax-codegen" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "genco", "xshell", @@ -595,8 +601,8 @@ dependencies = [ [[package]] name = "cairo-lang-test-plugin" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -621,8 +627,8 @@ dependencies = [ [[package]] name = "cairo-lang-test-utils" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "cairo-lang-formatter", "cairo-lang-utils", @@ -633,8 +639,8 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.8.2" -source = "git+https://github.com/starkware-libs/cairo?rev=ca2dceb#ca2dcebc0a32e39b66a289994d8d454202e6923b" +version = "2.9.2" +source = "git+https://github.com/starkware-libs/cairo?rev=3848dce8591446f9bbcc036fef391927d13dccc6#3848dce8591446f9bbcc036fef391927d13dccc6" dependencies = [ "hashbrown 0.14.5", "indexmap 2.7.0", @@ -1757,8 +1763,9 @@ dependencies = [ [[package]] name = "scarb-metadata" -version = "1.12.0" -source = "git+https://github.com/software-mansion/scarb?rev=0366ff08f58e5b554aed840b952cc3f7637347a3#0366ff08f58e5b554aed840b952cc3f7637347a3" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a8b71f63999dbb6d269fbc6fd61310016ab3a160fb13e52a6511a2b904359f0" dependencies = [ "camino", "semver", @@ -1770,7 +1777,8 @@ dependencies = [ [[package]] name = "scarb-ui" version = "0.1.5" -source = "git+https://github.com/software-mansion/scarb?rev=0366ff08f58e5b554aed840b952cc3f7637347a3#0366ff08f58e5b554aed840b952cc3f7637347a3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19e63037ffa17459b3c07e385498d48fbf9b329e43a93f6c4a751845441fee33" dependencies = [ "anyhow", "camino", diff --git a/Cargo.toml b/Cargo.toml index 8575e3a9..393c5317 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,13 +58,13 @@ if_chain = "1.0.2" # on some of them directly. # This ensures no duplicate instances of Cairo crates are pulled in by mistake. [patch.crates-io] -cairo-lang-compiler = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" } -cairo-lang-utils = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" } -cairo-lang-semantic = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" } -cairo-lang-filesystem = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" } -cairo-lang-diagnostics = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" } -cairo-lang-test-plugin = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" } -cairo-lang-syntax = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" } -cairo-lang-defs = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" } -cairo-lang-starknet = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" } -cairo-lang-test-utils = { git = "https://github.com/starkware-libs/cairo", rev = "ca2dceb" } +cairo-lang-compiler = { git = "https://github.com/starkware-libs/cairo", rev = "3848dce8591446f9bbcc036fef391927d13dccc6" } +cairo-lang-utils = { git = "https://github.com/starkware-libs/cairo", rev = "3848dce8591446f9bbcc036fef391927d13dccc6" } +cairo-lang-semantic = { git = "https://github.com/starkware-libs/cairo", rev = "3848dce8591446f9bbcc036fef391927d13dccc6" } +cairo-lang-filesystem = { git = "https://github.com/starkware-libs/cairo", rev = "3848dce8591446f9bbcc036fef391927d13dccc6" } +cairo-lang-diagnostics = { git = "https://github.com/starkware-libs/cairo", rev = "3848dce8591446f9bbcc036fef391927d13dccc6" } +cairo-lang-test-plugin = { git = "https://github.com/starkware-libs/cairo", rev = "3848dce8591446f9bbcc036fef391927d13dccc6" } +cairo-lang-syntax = { git = "https://github.com/starkware-libs/cairo", rev = "3848dce8591446f9bbcc036fef391927d13dccc6" } +cairo-lang-defs = { git = "https://github.com/starkware-libs/cairo", rev = "3848dce8591446f9bbcc036fef391927d13dccc6" } +cairo-lang-starknet = { git = "https://github.com/starkware-libs/cairo", rev = "3848dce8591446f9bbcc036fef391927d13dccc6" } +cairo-lang-test-utils = { git = "https://github.com/starkware-libs/cairo", rev = "3848dce8591446f9bbcc036fef391927d13dccc6" } diff --git a/crates/cairo-lint-cli/Cargo.toml b/crates/cairo-lint-cli/Cargo.toml index aa583d93..477d9aa4 100644 --- a/crates/cairo-lint-cli/Cargo.toml +++ b/crates/cairo-lint-cli/Cargo.toml @@ -20,9 +20,9 @@ cairo-lang-test-plugin.workspace = true cairo-lang-defs.workspace = true cairo-lang-starknet.workspace = true clap = { workspace = true, features = ["derive"] } -scarb-ui = { git = "https://github.com/software-mansion/scarb", rev = "0366ff08f58e5b554aed840b952cc3f7637347a3"} +scarb-ui = "0.1.5" anyhow.workspace = true -scarb-metadata = { git = "https://github.com/software-mansion/scarb", rev = "0366ff08f58e5b554aed840b952cc3f7637347a3"} +scarb-metadata = "1.13.0" cairo-lint-core = { path = "../cairo-lint-core" } semver = "1.0.24" # scarb = { git = "https://github.com/software-mansion/scarb", branch = "main" } diff --git a/crates/cairo-lint-cli/src/helpers.rs b/crates/cairo-lint-cli/src/helpers.rs index da1828c8..122aa3e0 100644 --- a/crates/cairo-lint-cli/src/helpers.rs +++ b/crates/cairo-lint-cli/src/helpers.rs @@ -5,13 +5,12 @@ use anyhow::{anyhow, Result}; use cairo_lang_compiler::project::{AllCratesConfig, ProjectConfig, ProjectConfigContent}; use cairo_lang_filesystem::cfg::{Cfg as CompilerCfg, CfgSet}; use cairo_lang_filesystem::db::{ - CrateSettings, DependencySettings, Edition, ExperimentalFeaturesConfig, + CrateIdentifier, CrateSettings, DependencySettings, Edition, ExperimentalFeaturesConfig, }; -use cairo_lang_filesystem::ids::Directory; use cairo_lang_utils::ordered_hash_map::OrderedHashMap; use scarb_metadata::{Cfg as ScarbCfg, CompilationUnitMetadata, PackageId, PackageMetadata}; use semver::Version; -use smol_str::{SmolStr, ToSmolStr}; +use smol_str::ToSmolStr; /// Different targets for cairo. pub mod targets { @@ -64,7 +63,6 @@ pub fn to_cairo_edition(edition: &str) -> Result { pub fn build_project_config( compilation_unit: &CompilationUnitMetadata, corelib_id: &PackageId, - corelib: PathBuf, package_path: PathBuf, edition: Edition, version: &Version, @@ -74,17 +72,22 @@ pub fn build_project_config( .components .iter() .filter(|component| &component.package != corelib_id) - .map(|component| (component.name.to_smolstr(), component.source_root().into())) + .map(|component| { + ( + CrateIdentifier::from(&component.name), + component.source_root().into(), + ) + }) .collect(); - let crates_config: OrderedHashMap = compilation_unit + let crates_config: OrderedHashMap = compilation_unit .components .iter() .map(|component| { - let cfg_set = component.cfg.as_ref().map(|cfgs| to_cairo_cfg(cfgs)); - let (package_ed, dependencies) = if let Some(pack) = packages + let package = packages .iter() - .find(|package| package.id == component.package) - { + .find(|package| package.id == component.package); + let cfg_set = component.cfg.as_ref().map(|cfgs| to_cairo_cfg(cfgs)); + let (package_ed, dependencies) = if let Some(pack) = package { let mut dependencies: BTreeMap = pack .dependencies .iter() @@ -96,13 +99,15 @@ pub fn build_project_config( compilation_unit_metadata_component.name == dependency.name }) .map(|compilation_unit_metadata_component| { - let version = packages - .iter() - .find(|package| { - package.name == compilation_unit_metadata_component.name - }) - .map(|package| package.version.clone()); - (dependency.name.clone(), DependencySettings { version }) + ( + dependency.name.clone(), + DependencySettings { + discriminator: compilation_unit_metadata_component + .discriminator + .as_ref() + .map(ToSmolStr::to_smolstr), + }, + ) }) }) .collect(); @@ -110,7 +115,7 @@ pub fn build_project_config( dependencies.insert( pack.name.clone(), DependencySettings { - version: Some(pack.version.clone()), + discriminator: component.discriminator.as_ref().map(ToSmolStr::to_smolstr), }, ); ( @@ -123,14 +128,34 @@ pub fn build_project_config( (edition, BTreeMap::default()) }; ( - component.name.to_smolstr(), + CrateIdentifier::from(&component.name), CrateSettings { + name: Some(component.name.to_smolstr()), edition: package_ed, cfg_set, dependencies, experimental_features: ExperimentalFeaturesConfig { - negative_impls: false, - coupons: false, + negative_impls: package + .map(|package| { + package + .experimental_features + .contains(&String::from("negative_impls")) + }) + .unwrap_or(false), + coupons: package + .map(|package| { + package + .experimental_features + .contains(&String::from("coupons")) + }) + .unwrap_or(false), + associated_item_constraints: package + .map(|package| { + package + .experimental_features + .contains(&String::from("associated_item_constraints")) + }) + .unwrap_or(false), }, version: Some(version.clone()), }, @@ -148,7 +173,6 @@ pub fn build_project_config( let project_config = ProjectConfig { base_path: package_path, - corelib: Some(Directory::Real(corelib)), content, }; Ok(project_config) diff --git a/crates/cairo-lint-cli/src/main.rs b/crates/cairo-lint-cli/src/main.rs index ceda9e51..e4b7017f 100644 --- a/crates/cairo-lint-cli/src/main.rs +++ b/crates/cairo-lint-cli/src/main.rs @@ -31,7 +31,7 @@ use scarb_metadata::{MetadataCommand, PackageMetadata, TargetMetadata}; use scarb_ui::args::{PackagesFilter, VerbositySpec}; use scarb_ui::components::Status; use scarb_ui::{OutputFormat, Ui}; -use smol_str::SmolStr; +use smol_str::{SmolStr, ToSmolStr}; #[derive(Parser, Debug)] struct Args { @@ -144,16 +144,25 @@ fn main_inner(ui: &Ui, args: Args) -> Result<()> { let config = build_project_config( compilation_unit, corelib_id, - corelib.clone(), package_path, edition, &package.version, &metadata.packages, )?; + + let main_component = compilation_unit + .components + .iter() + .find(|component| component.package == compilation_unit.package) + .expect("main component is guaranteed to exist in compilation unit"); + update_crate_roots_from_project_config(&mut db, &config); let crate_id = db.intern_crate(CrateLongId::Real { name: SmolStr::new(&compilation_unit.target.name), - version: Some(package.version.clone()), + discriminator: main_component + .discriminator + .as_ref() + .map(ToSmolStr::to_smolstr), }); // Get all the diagnostics let mut diags = Vec::new(); diff --git a/crates/cairo-lint-core/src/lints/panic.rs b/crates/cairo-lint-core/src/lints/panic.rs index 95a2816f..f92c2f79 100644 --- a/crates/cairo-lint-core/src/lints/panic.rs +++ b/crates/cairo-lint-core/src/lints/panic.rs @@ -49,6 +49,7 @@ pub fn check_panic_usage( .lookup(db.upcast()) .as_syntax_node() .span(db.upcast()), + None, ); // If the panic comes from a real file (macros generate code in new virtual files) if initial_file_id == file_id { diff --git a/crates/cairo-lint-core/tests/tests.rs b/crates/cairo-lint-core/tests/tests.rs index 4b758c2e..3b197966 100644 --- a/crates/cairo-lint-core/tests/tests.rs +++ b/crates/cairo-lint-core/tests/tests.rs @@ -31,6 +31,7 @@ edition = "2024_07" [experimental_features] negative_impls = true coupons = true +associated_item_constraints = true "#; test_file!(