Skip to content

Commit 961c189

Browse files
committed
rust 2024 edition; lots of ifs merged and imports rearranged
1 parent cf5c5e6 commit 961c189

File tree

155 files changed

+693
-666
lines changed

Some content is hidden

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

155 files changed

+693
-666
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
members = ["crates/*"]
33
resolver = "2"
44

5+
[workspace.package]
6+
edition = "2024"
7+
58
[workspace.dependencies]
69
common = { path = "crates/common", package = "fe-common" }
710
driver = { path = "crates/driver", package = "fe-driver" }

crates/bench/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "fe-bench"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition.workspace = true
55

66
[dev-dependencies]
77
criterion = "0.5"

crates/bench/benches/analysis.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use camino::{Utf8Path, Utf8PathBuf};
2-
use common::{core::HasBuiltinCore, InputDb};
3-
use criterion::{criterion_group, criterion_main, Criterion, SamplingMode};
2+
use common::{InputDb, core::HasBuiltinCore};
3+
use criterion::{Criterion, SamplingMode, criterion_group, criterion_main};
44
use driver::DriverDataBase;
55
use url::Url;
66
use walkdir::WalkDir;

crates/common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "fe-common"
33
version = "0.26.0"
4-
edition = "2021"
4+
edition.workspace = true
55
license = "Apache-2.0"
66
repository = "https://github.com/ethereum/fe"
77
description = "Provides HIR definition and lowering for Fe lang."

crates/common/src/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use rust_embed::Embed;
33
use url::Url;
44

55
use crate::{
6-
ingot::{Ingot, IngotBaseUrl},
76
InputDb,
7+
ingot::{Ingot, IngotBaseUrl},
88
};
99

1010
pub static BUILTIN_CORE_BASE_URL: &str = "builtin-core:///";

crates/common/src/file/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use camino::Utf8PathBuf;
44
use url::Url;
55
pub use workspace::Workspace;
66

7-
use crate::{ingot::Ingot, InputDb};
7+
use crate::{InputDb, ingot::Ingot};
88

99
#[salsa::input(constructor = __new_impl)]
1010
#[derive(Debug)]

crates/common/src/file/workspace.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ impl Workspace {
3131
) -> Result<File, InputIndexError> {
3232
// Check if the file is already associated with another URL
3333
let paths = self.paths(db);
34-
if let Some(existing_url) = paths.get(&file) {
35-
if existing_url != &url {
36-
return Err(InputIndexError::CannotReuseInput);
37-
}
34+
if let Some(existing_url) = paths.get(&file)
35+
&& existing_url != &url
36+
{
37+
return Err(InputIndexError::CannotReuseInput);
3838
}
3939

4040
let files = self.files(db);

crates/common/src/graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use smol_str::SmolStr;
55
use std::collections::HashMap;
66
use url::Url;
77

8-
use crate::{config::DependencyArguments, InputDb};
8+
use crate::{InputDb, config::DependencyArguments};
99

1010
#[salsa::input]
1111
#[derive(Debug)]

crates/common/src/indexmap.rs

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -80,30 +80,32 @@ where
8080
V: Update,
8181
{
8282
unsafe fn maybe_update(old_pointer: *mut Self, new_map: Self) -> bool {
83-
let old_map = unsafe { &mut *old_pointer };
84-
85-
// Check if the keys in both maps are the same w.r.t the key order.
86-
let is_key_same = old_map.len() == new_map.len()
87-
&& old_map
88-
.keys()
89-
.zip(new_map.keys())
90-
.all(|(old, new)| old == new);
91-
92-
// If the keys are different, update entire map.
93-
if !is_key_same {
94-
old_map.clear();
95-
old_map.0.extend(new_map.0);
96-
return true;
83+
unsafe {
84+
let old_map = &mut *old_pointer;
85+
86+
// Check if the keys in both maps are the same w.r.t the key order.
87+
let is_key_same = old_map.len() == new_map.len()
88+
&& old_map
89+
.keys()
90+
.zip(new_map.keys())
91+
.all(|(old, new)| old == new);
92+
93+
// If the keys are different, update entire map.
94+
if !is_key_same {
95+
old_map.clear();
96+
old_map.0.extend(new_map.0);
97+
return true;
98+
}
99+
100+
// Update values if it's different.
101+
let mut changed = false;
102+
for (i, new_value) in new_map.0.into_values().enumerate() {
103+
let old_value = &mut old_map[i];
104+
changed |= V::maybe_update(old_value, new_value);
105+
}
106+
107+
changed
97108
}
98-
99-
// Update values if it's different.
100-
let mut changed = false;
101-
for (i, new_value) in new_map.0.into_values().enumerate() {
102-
let old_value = &mut old_map[i];
103-
changed |= V::maybe_update(old_value, new_value);
104-
}
105-
106-
changed
107109
}
108110
}
109111

crates/common/src/ingot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ pub use radix_immutable::StringPrefixView;
55
use smol_str::SmolStr;
66
use url::Url;
77

8+
use crate::InputDb;
89
use crate::config::{Config, ConfigDiagnostic};
910
use crate::core::BUILTIN_CORE_BASE_URL;
1011
use crate::file::{File, Workspace};
1112
use crate::urlext::UrlExt;
12-
use crate::InputDb;
1313

1414
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1515
pub enum IngotKind {

0 commit comments

Comments
 (0)