Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
members = ["crates/*"]
resolver = "2"

[workspace.package]
edition = "2024"

[workspace.dependencies]
common = { path = "crates/common", package = "fe-common" }
driver = { path = "crates/driver", package = "fe-driver" }
Expand Down
2 changes: 1 addition & 1 deletion crates/bench/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "fe-bench"
version = "0.1.0"
edition = "2021"
edition.workspace = true

[dev-dependencies]
criterion = "0.5"
Expand Down
4 changes: 2 additions & 2 deletions crates/bench/benches/analysis.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use camino::{Utf8Path, Utf8PathBuf};
use common::{core::HasBuiltinCore, InputDb};
use criterion::{criterion_group, criterion_main, Criterion, SamplingMode};
use common::{InputDb, core::HasBuiltinCore};
use criterion::{Criterion, SamplingMode, criterion_group, criterion_main};
use driver::DriverDataBase;
use url::Url;
use walkdir::WalkDir;
Expand Down
2 changes: 1 addition & 1 deletion crates/common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "fe-common"
version = "0.26.0"
edition = "2021"
edition.workspace = true
license = "Apache-2.0"
repository = "https://github.com/ethereum/fe"
description = "Provides HIR definition and lowering for Fe lang."
Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use rust_embed::Embed;
use url::Url;

use crate::{
ingot::{Ingot, IngotBaseUrl},
InputDb,
ingot::{Ingot, IngotBaseUrl},
};

pub static BUILTIN_CORE_BASE_URL: &str = "builtin-core:///";
Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use camino::Utf8PathBuf;
use url::Url;
pub use workspace::Workspace;

use crate::{ingot::Ingot, InputDb};
use crate::{InputDb, ingot::Ingot};

#[salsa::input(constructor = __new_impl)]
#[derive(Debug)]
Expand Down
8 changes: 4 additions & 4 deletions crates/common/src/file/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ impl Workspace {
) -> Result<File, InputIndexError> {
// Check if the file is already associated with another URL
let paths = self.paths(db);
if let Some(existing_url) = paths.get(&file) {
if existing_url != &url {
return Err(InputIndexError::CannotReuseInput);
}
if let Some(existing_url) = paths.get(&file)
&& existing_url != &url
{
return Err(InputIndexError::CannotReuseInput);
}

let files = self.files(db);
Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use smol_str::SmolStr;
use std::collections::HashMap;
use url::Url;

use crate::{config::DependencyArguments, InputDb};
use crate::{InputDb, config::DependencyArguments};

#[salsa::input]
#[derive(Debug)]
Expand Down
48 changes: 25 additions & 23 deletions crates/common/src/indexmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,30 +80,32 @@ where
V: Update,
{
unsafe fn maybe_update(old_pointer: *mut Self, new_map: Self) -> bool {
let old_map = unsafe { &mut *old_pointer };

// Check if the keys in both maps are the same w.r.t the key order.
let is_key_same = old_map.len() == new_map.len()
&& old_map
.keys()
.zip(new_map.keys())
.all(|(old, new)| old == new);

// If the keys are different, update entire map.
if !is_key_same {
old_map.clear();
old_map.0.extend(new_map.0);
return true;
unsafe {
let old_map = &mut *old_pointer;

// Check if the keys in both maps are the same w.r.t the key order.
let is_key_same = old_map.len() == new_map.len()
&& old_map
.keys()
.zip(new_map.keys())
.all(|(old, new)| old == new);

// If the keys are different, update entire map.
if !is_key_same {
old_map.clear();
old_map.0.extend(new_map.0);
return true;
}

// Update values if it's different.
let mut changed = false;
for (i, new_value) in new_map.0.into_values().enumerate() {
let old_value = &mut old_map[i];
changed |= V::maybe_update(old_value, new_value);
}

changed
}

// Update values if it's different.
let mut changed = false;
for (i, new_value) in new_map.0.into_values().enumerate() {
let old_value = &mut old_map[i];
changed |= V::maybe_update(old_value, new_value);
}

changed
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/ingot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ pub use radix_immutable::StringPrefixView;
use smol_str::SmolStr;
use url::Url;

use crate::InputDb;
use crate::config::{Config, ConfigDiagnostic};
use crate::core::BUILTIN_CORE_BASE_URL;
use crate::file::{File, Workspace};
use crate::urlext::UrlExt;
use crate::InputDb;

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum IngotKind {
Expand Down
2 changes: 1 addition & 1 deletion crates/driver/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "fe-driver"
version = "0.26.0"
edition = "2021"
edition.workspace = true
license = "Apache-2.0"
repository = "https://github.com/ethereum/fe"
description = "Provides Fe driver"
Expand Down
2 changes: 1 addition & 1 deletion crates/driver/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use codespan_reporting::term::{
use common::file::File;
use common::{define_input_db, diagnostics::CompleteDiagnostic};
use hir::{
Ingot,
hir_def::TopLevelMod,
lower::{map_file_to_mod, module_tree},
Ingot,
};
use hir_analysis::{
analysis_pass::{AnalysisPassManager, ParsingPass},
Expand Down
2 changes: 1 addition & 1 deletion crates/driver/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use std::ops::Range;
use camino::Utf8Path;
use codespan_reporting as cs;
use common::{
InputDb,
diagnostics::{LabelStyle, Severity},
file::File,
InputDb,
};
use cs::{diagnostic as cs_diag, files as cs_files};
use hir_analysis::diagnostics::{DiagnosticVoucher, SpannedHirAnalysisDb};
Expand Down
20 changes: 12 additions & 8 deletions crates/driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ pub mod files;
use std::{collections::HashMap, mem::take};

use common::{
InputDb,
graph::{EdgeWeight, JoinEdge},
tree::display_dependency_tree,
InputDb,
};
pub use db::DriverDataBase;

use common::config::Config;
use hir::hir_def::TopLevelMod;
use resolver::{
ResolutionHandler, Resolver,
files::{FilesResolutionDiagnostic, FilesResolutionError, FilesResolver, FilesResource},
graph::{DiGraph, GraphResolutionHandler, GraphResolver, GraphResolverImpl},
ResolutionHandler, Resolver,
};
use url::Url;

Expand All @@ -42,7 +42,9 @@ pub fn init_ingot(db: &mut DriverDataBase, ingot_url: &Url) -> Vec<IngotInitDiag
// Root ingot resolution should never fail since directory existence is validated earlier.
// If it fails, it indicates a bug in the resolver or an unexpected system condition.
if let Err(err) = ingot_graph_resolver.graph_resolve(&mut handler, ingot_url) {
panic!("Unexpected failure resolving root ingot at {ingot_url}: {err:?}. This indicates a bug in the resolver since directory existence is validated before calling init_ingot.");
panic!(
"Unexpected failure resolving root ingot at {ingot_url}: {err:?}. This indicates a bug in the resolver since directory existence is validated before calling init_ingot."
);
}

// Collect diagnostics from all sources
Expand Down Expand Up @@ -80,10 +82,10 @@ pub fn init_ingot(db: &mut DriverDataBase, ingot_url: &Url) -> Vec<IngotInitDiag
let mut configs = HashMap::new();
for node_idx in cyclic_subgraph.node_indices() {
let url = &cyclic_subgraph[node_idx];
if let Some(ingot) = db.workspace().containing_ingot(db, url.clone()) {
if let Some(config) = ingot.config(db) {
configs.insert(url.clone(), config);
}
if let Some(ingot) = db.workspace().containing_ingot(db, url.clone())
&& let Some(config) = ingot.config(db)
{
configs.insert(url.clone(), config);
}
}

Expand All @@ -92,7 +94,9 @@ pub fn init_ingot(db: &mut DriverDataBase, ingot_url: &Url) -> Vec<IngotInitDiag
.node_indices()
.any(|idx| cyclic_subgraph[idx] == *ingot_url)
{
panic!("Root ingot {ingot_url} not found in cyclic subgraph. This indicates a bug in cycle detection logic.");
panic!(
"Root ingot {ingot_url} not found in cyclic subgraph. This indicates a bug in cycle detection logic."
);
}
let tree_root = ingot_url.clone();

Expand Down
2 changes: 1 addition & 1 deletion crates/fe/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "fe"
version = "0.26.0"
edition = "2021"
edition.workspace = true

[dependencies]
clap.workspace = true
Expand Down
1 change: 1 addition & 0 deletions crates/fe/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::print_stderr, clippy::print_stdout)]
mod check;
mod tree;

Expand Down
2 changes: 1 addition & 1 deletion crates/fe/src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use std::collections::HashMap;
use camino::Utf8PathBuf;
use common::{config::Config, graph::EdgeWeight, tree::display_dependency_tree};
use resolver::{
ResolutionHandler, Resolver,
files::{FilesResolver, FilesResource},
graph::{DiGraph, GraphResolutionHandler, GraphResolver},
ResolutionHandler, Resolver,
};
use url::Url;

Expand Down
2 changes: 1 addition & 1 deletion crates/fe/tests/cli_output.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use dir_test::{dir_test, Fixture};
use dir_test::{Fixture, dir_test};
use std::process::Command;
use test_utils::snap_test;

Expand Down
3 changes: 1 addition & 2 deletions crates/hir-analysis/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "fe-hir-analysis"
version = "0.26.0"
edition = "2021"
edition.workspace = true
license = "Apache-2.0"
repository = "https://github.com/ethereum/fe"
description = "Provides HIR semantic analysis for Fe lang"
Expand All @@ -15,7 +15,6 @@ cranelift-entity = "0.115"
derive_more.workspace = true
either = "1.13"
ena = { version = "0.14", features = ["persistent"] }
if_chain = "1.0"
indexmap = "2.0"
itertools = "0.14"
num-bigint.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/hir-analysis/src/analysis_pass.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::{diagnostics::DiagnosticVoucher, HirAnalysisDb};
use crate::{HirAnalysisDb, diagnostics::DiagnosticVoucher};
use hir::{
ParserError,
hir_def::{ModuleTree, TopLevelMod},
lower::parse_file_impl,
ParserError,
};

/// All analysis passes that run analysis on the HIR top level module
Expand Down
Loading