Skip to content

Commit

Permalink
Merge branch 'master' into xunilrj/fix-extract-type-parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaBatty authored Feb 28, 2025
2 parents 9f3fcbf + 597ecfb commit ae3eddb
Show file tree
Hide file tree
Showing 20 changed files with 457 additions and 527 deletions.
728 changes: 238 additions & 490 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ annotate-snippets = "0.10"
ansiterm = "0.12"
anyhow = "1.0"
assert-json-diff = "2.0"
assert_matches = "1.5.0"
async-trait = "0.1"
aws-config = "1.5"
aws-sdk-kms = "1.44"
Expand All @@ -127,20 +128,27 @@ cid = "0.11"
clap = "4.5"
clap_complete = "4.5"
clap_complete_fig = "4.5"
codspeed-criterion-compat = "2.6.0"
colored = "2.0"
completest-pty = "0.5.0"
comrak = "0.28"
criterion = "0.5"
crossbeam-channel = "0.5"
dap = "0.4.1-alpha"
dashmap = "6.1"
devault = "0.2"
dialoguer = "0.11"
dir_indexer = "0.0.2"
dirs = "5.0"
downcast-rs = "1.2"
duct = "0.13.7"
duplicate = "2.0"
either = "1.9"
escargot = "0.5.7"
ethabi = { package = "fuel-ethabi", version = "18.0" }
etk-asm = { package = "fuel-etk-asm", version = "0.3.1-dev" }
etk-ops = { package = "fuel-etk-ops", version = "0.3.1-dev" }
expect-test = "1.4.1"
extension-trait = "1.0"
fd-lock = "4.0"
filecheck = "0.5"
Expand Down Expand Up @@ -186,6 +194,7 @@ pest = "2.7"
pest_derive = "2.7"
petgraph = "0.6"
phf = "0.11"
portpicker = "0.1.1"
pretty_assertions = "1.4"
prettydiff = "0.7"
proc-macro2 = "1.0"
Expand All @@ -195,6 +204,7 @@ rayon = "1.7"
rayon-cond = "0.3"
regex = "1.10"
reqwest = "0.12"
rexpect = "0.6"
revm = "14.0"
ropey = "1.5"
rpassword = "7.2"
Expand All @@ -210,11 +220,14 @@ serial_test = "3.0"
sha1 = "0.10"
sha2 = "0.10"
sha3 = "0.10"
similar = "2.0"
slotmap = "1.0"
smallvec = "1.7"
strsim = "0.11"
strum = "0.26"
syn = "2.0"
sysinfo = "0.29"
tai64 = "4.0"
taplo = "0.13"
tar = "0.4"
tempfile = "3"
Expand All @@ -230,6 +243,7 @@ tower = { version = "0.5", default-features = false }
tower-lsp = "0.20"
tracing = "0.1"
tracing-subscriber = "0.3"
tracing-test = "0.2"
uint = "0.9"
unicode-bidi = "0.3"
unicode-xid = "0.2"
Expand All @@ -240,3 +254,4 @@ vec1 = "1.8"
vte = "0.13"
walkdir = "2.3"
whoami = "1.5"
wiremock = "0.6"
4 changes: 2 additions & 2 deletions forc-pkg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ vec1.workspace = true
walkdir.workspace = true

[dev-dependencies]
regex = "^1.10.2"
regex.workspace = true
tempfile.workspace = true

[target.'cfg(not(target_os = "macos"))'.dependencies]
sysinfo = "0.29"
sysinfo.workspace = true

8 changes: 4 additions & 4 deletions forc-plugins/forc-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ tracing.workspace = true
url.workspace = true

[dev-dependencies]
portpicker = "0.1.1"
pretty_assertions = "1.4.1"
rexpect = "0.5"
portpicker.workspace = true
pretty_assertions.workspace = true
rexpect.workspace = true

[build-dependencies]
regex = "1.5.4"
regex.workspace = true

[[bin]]
name = "forc-deploy"
Expand Down
2 changes: 1 addition & 1 deletion forc-plugins/forc-crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ tokio = { workspace = true, features = ["macros", "rt-multi-thread", "process"]
tracing.workspace = true

[dev-dependencies]
criterion = "0.5"
criterion.workspace = true
tempfile.workspace = true

[[bench]]
Expand Down
6 changes: 3 additions & 3 deletions forc-plugins/forc-debug/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ walkdir.workspace = true

[dev-dependencies]
dap = { version = "0.4.1-alpha1", features = ["client"] }
escargot = "0.5.7"
portpicker = "0.1.1"
rexpect = "0.4"
escargot.workspace = true
portpicker.workspace = true
rexpect.workspace = true
4 changes: 2 additions & 2 deletions forc-plugins/forc-doc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ sway-types.workspace = true
swayfmt.workspace = true

[dev-dependencies]
dir_indexer = "0.0.2"
expect-test = "1.4.1"
dir_indexer.workspace = true
expect-test.workspace = true
4 changes: 2 additions & 2 deletions forc-plugins/forc-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ termion.workspace = true
tokio = { workspace = true, features = ["macros", "signal", "rt-multi-thread"] }

[dev-dependencies]
portpicker = "0.1.1"
portpicker.workspace = true
reqwest = { workspace = true, features = ["json"] }
serde_json.workspace = true
tempfile.workspace = true
tokio = { workspace = true, features = ["full"] }
wiremock = "0.5"
wiremock.workspace = true

[lib]
path = "src/lib.rs"
Expand Down
2 changes: 1 addition & 1 deletion forc-plugins/forc-publish/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ uuid = { workspace = true, features = ["v4", "serde"] }
walkdir.workspace = true

[dev-dependencies]
wiremock = "0.6.2"
wiremock.workspace = true
2 changes: 1 addition & 1 deletion forc-tracing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ tracing.workspace = true
tracing-subscriber = { workspace = true, features = ["ansi", "env-filter", "json"] }

[dev-dependencies]
tracing-test = "0.2"
tracing-test.workspace = true
4 changes: 2 additions & 2 deletions forc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ util = []
profile = []

[dev-dependencies]
completest-pty = "0.5.0"
rexpect = "0.5"
completest-pty.workspace = true
rexpect.workspace = true
2 changes: 1 addition & 1 deletion sway-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ uint.workspace = true
vec1.workspace = true

[target.'cfg(not(target_os = "macos"))'.dependencies]
sysinfo = "0.29.0"
sysinfo.workspace = true

[lints.clippy]
iter_over_hash_type = "deny"
111 changes: 111 additions & 0 deletions sway-lib-std/src/bytes.sw
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use ::intrinsics::size_of_val;
use ::option::Option::{self, *};
use ::convert::{From, Into, *};
use ::clone::Clone;
use ::iterator::*;

struct RawBytes {
ptr: raw_ptr,
Expand Down Expand Up @@ -871,6 +872,86 @@ impl Bytes {

self.len = new_len;
}

/// Returns an [Iterator] to iterate over this `Bytes`.
///
/// # Returns
///
/// * [BytesIter] - The struct which can be iterated over.
///
/// # Examples
///
/// ```sway
/// fn foo() {
/// let mut bytes = Bytes::new();
/// bytes.push(5_u8);
/// bytes.push(10_u8);
/// bytes.push(15_u8);
///
/// // Get the iterator
/// let iter = bytes.iter();
///
/// assert_eq(5_u8, iter.next().unwrap());
/// assert_eq(10_u8, iter.next().unwrap());
/// assert_eq(15_u8, iter.next().unwrap());
///
/// for elem in bytes.iter() {
/// log(elem);
/// }
/// }
///
/// # Undefined Behavior
///
/// Modifying vector during iteration is a logical error and
/// results in undefined behavior. E.g.:
///
/// ```sway
/// fn foo() {
/// let mut bytes = Bytes::new();
/// bytes.push(5_u8);
/// bytes.push(10_u8);
/// bytes.push(15_u8);
///
/// for elem in bytes.iter() {
/// bytes.push(20_u8); // Modification causes undefined behavior.
/// }
/// }
/// ```
pub fn iter(self) -> BytesIter {
// WARNING: Be aware of caveats of this implementation
// if you take it as an example for implementing
// `Iterator` for other types.
//
// Due to the Sway's copy semantics, the `values` will
// actually contain **a copy of the original bytes
// `self`**. This is contrary to the iterator semantics
// which should iterate over the collection itself.
//
// Strictly speaking, we should take a reference to
// `self` here, but references as for now an experimental
// feature.
//
// However, this issue of copying gets compensated by
// another issue, which is the broken copy semantics
// for heap types like `Bytes`. Essentially, the original
// `self` and it's copy `values` will both point to
// the same elements on the heap, which gives us the
// desired behavior for the iterator.
//
// This fact makes the implementation of `next` very
// misleading in the part where the bytes length is
// checked (see comment in the `next` implementation
// below).
//
// Once we fix and formalize the copying of heap types
// this implementation will be changed, but for
// the time being, it is the most pragmatic one we can
// have now.
BytesIter {
values: self,
index: 0,
}
}
}

#[cfg(experimental_partial_eq = false)]
Expand Down Expand Up @@ -1091,3 +1172,33 @@ impl AbiDecode for Bytes {
raw_slice::abi_decode(buffer).into()
}
}

pub struct BytesIter {
values: Bytes,
index: u64,
}

impl Iterator for BytesIter {
type Item = u8;
fn next(ref mut self) -> Option<Self::Item> {
// BEWARE: `self.values` keeps **the copy** of the `Bytes`
// we iterate over. The below check checks against
// the length of that copy, taken when the iterator
// was created, and not the original vector.
//
// If the original vector gets modified during the iteration
// (e.g., elements are removed), this modification will not
// be reflected in `self.values.len()`.
//
// But since modifying the vector during iteration is
// considered undefined behavior, this implementation,
// that always checks against the length at the time
// the iterator got created is perfectly valid.
if self.index >= self.values.len() {
return None
}

self.index += 1;
self.values.get(self.index - 1)
}
}
20 changes: 10 additions & 10 deletions sway-lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,20 @@ tracing.workspace = true
urlencoding.workspace = true

[dev-dependencies]
assert-json-diff = "2.0"
codspeed-criterion-compat = "2.6.0"
criterion = "0.5"
dirs = "4.0"
futures = { version = "0.3", default-features = false, features = [
assert-json-diff.workspace = true
codspeed-criterion-compat.workspace = true
criterion.workspace = true
dirs.workspace = true
futures = { workspace = true, default-features = false, features = [
"std",
"async-await",
] }
pretty_assertions = "1.4.0"
rand = "0.8"
regex = "^1.10.2"
pretty_assertions.workspace = true
rand.workspace = true
regex.workspace = true
sway-lsp-test-utils = { path = "tests/utils" }
tikv-jemallocator = "0.6"
tower = { version = "0.4.12", default-features = false, features = ["util"] }
tikv-jemallocator.workspace = true
tower = { workspace = true, default-features = false, features = ["util"] }

[[bench]]
name = "bench_main"
Expand Down
4 changes: 2 additions & 2 deletions sway-parse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ unicode-bidi.workspace = true
unicode-xid.workspace = true

[dev-dependencies]
assert_matches = "1.5.0"
insta = { version = "1.28.0", features = ["ron"] }
assert_matches.workspace = true
insta = { workspace = true, features = ["ron"] }

[lints.clippy]
iter_over_hash_type = "deny"
6 changes: 3 additions & 3 deletions swayfmt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ thiserror.workspace = true
toml = { workspace = true, features = ["parse"] }

[dev-dependencies]
paste = "1.0"
prettydiff = "0.7"
similar = "2.0"
paste.workspace = true
prettydiff.workspace = true
similar.workspace = true
test-macros = { path = "test_macros" }
4 changes: 2 additions & 2 deletions swayfmt/test_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ repository.workspace = true
[dependencies]

[dev-dependencies]
paste = "1.0"
prettydiff = "0.7"
paste.workspace = true
prettydiff.workspace = true

[package.metadata.cargo-udeps.ignore]
development = ["paste", "prettydiff"]
2 changes: 1 addition & 1 deletion test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ anyhow.workspace = true
bytes.workspace = true
clap = { workspace = true, features = ["derive", "env"] }
colored.workspace = true
duct = "0.13.7"
duct.workspace = true
filecheck.workspace = true
forc = { workspace = true, features = ["test"] }
forc-client.workspace = true
Expand Down
Loading

0 comments on commit ae3eddb

Please sign in to comment.