Skip to content

Commit

Permalink
Remove unnecessary .into_iter() and raw string (hyperledger#1456)
Browse files Browse the repository at this point in the history
These are clippies in the next rust version.

Signed-off-by: Sean Young <sean@mess.org>
  • Loading branch information
seanyoung committed Jul 25, 2023
1 parent 21b160e commit 1693d29
Show file tree
Hide file tree
Showing 23 changed files with 226 additions and 263 deletions.
4 changes: 2 additions & 2 deletions src/bin/doc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ pub fn generate_docs(outdir: &OsString, files: &[ast::Namespace], verbose: bool)

reg.register_template_string(
"soldoc",
r##"<!doctype html><head><title>soldoc</title><meta charset="utf-8"></head><body>
r#"<!doctype html><head><title>soldoc</title><meta charset="utf-8"></head><body>
<h2>Contracts</h2>
{{#each contracts}}
<h3>{{ty}} {{name}}</h3>
Expand Down Expand Up @@ -470,7 +470,7 @@ Fields:<dl>
{{#if author}}Author: {{author}}<p>{{/if}}
Values: {{field}}
{{/each}}
</body></html>"##,
</body></html>"#,
)
.expect("template should be good");

Expand Down
2 changes: 1 addition & 1 deletion src/codegen/statements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ fn returns(
let cast_values = func
.returns
.iter()
.zip(uncast_values.into_iter())
.zip(uncast_values)
.map(|(left, right)| try_load_and_cast(&right.loc(), &right, &left.ty, ns, cfg, vartab))
.collect();

Expand Down
4 changes: 2 additions & 2 deletions src/sema/expression/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ use crate::sema::expression::strings::unescape;

#[test]
fn test_unescape() {
let s = r#"\u00f3"#;
let s = r"\u00f3";
let mut vec = Diagnostics::default();
let res = unescape(s, 0, 0, &mut vec);
assert!(vec.is_empty());
assert_eq!(res, vec![0xc3, 0xb3]);
let s = r#"\xff"#;
let s = r"\xff";
let res = unescape(s, 0, 0, &mut vec);
assert!(vec.is_empty());
assert_eq!(res, vec![255]);
Expand Down
2 changes: 1 addition & 1 deletion src/sema/yul/tests/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ fn resolve_string_literal() {
StringLiteral {
loc,
unicode: false,
string: r#"ab\xffa\u00e0g"#.to_string(),
string: r"ab\xffa\u00e0g".to_string(),
},
Some(Identifier {
loc,
Expand Down
15 changes: 6 additions & 9 deletions tests/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn address() {
#[test]
fn try_catch() {
let ns = test_solidity(
r##"
r#"
contract b {
int32 x;
Expand Down Expand Up @@ -85,7 +85,7 @@ fn try_catch() {
return state;
}
}"##,
}"#,
);

assert!(!ns.diagnostics.any_errors());
Expand Down Expand Up @@ -179,13 +179,10 @@ fn ethereum_solidity_tests() {
.join("testdata/solidity/test/libsolidity/semanticTests"),
)
.into_iter()
.chain(
WalkDir::new(
Path::new(env!("CARGO_MANIFEST_DIR"))
.join("testdata/solidity/test/libsolidity/syntaxTests"),
)
.into_iter(),
);
.chain(WalkDir::new(
Path::new(env!("CARGO_MANIFEST_DIR"))
.join("testdata/solidity/test/libsolidity/syntaxTests"),
));

let errors: usize = entries
.par_bridge()
Expand Down
4 changes: 2 additions & 2 deletions tests/polkadot_tests/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::sync::Mutex;

/// Partially mimicking the ink! "mother" integration test.
static MOTHER: Lazy<Mutex<(InkProject, InkProject)>> = Lazy::new(|| {
let src = r##"
let src = r#"
import "polkadot";
contract Mother {
Expand All @@ -32,7 +32,7 @@ contract Mother {
function echo_auction(Auction _auction) public pure returns (Auction) {
return _auction;
}
}"##;
}"#;

let solang_abi = load_abi(&build_wasm(src, false, false)[0].1);
let ink_str = std::fs::read_to_string("testdata/ink/mother.json").unwrap();
Expand Down
8 changes: 4 additions & 4 deletions tests/polkadot_tests/arrays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,7 @@ fn alloc_size_from_storage() {
#[test]
fn fixed_bytes() {
let mut runtime = build_solidity(
r##"
r#"
contract Storage {
bytes32[] data;
constructor() {
Expand All @@ -1470,7 +1470,7 @@ fn fixed_bytes() {
return(data[j][i]);
}
}
"##,
"#,
);

runtime.constructor(0, vec![]);
Expand All @@ -1484,7 +1484,7 @@ fn fixed_bytes() {
}

let mut runtime = build_solidity(
r##"
r#"
contract Memory {
constructor() {
}
Expand All @@ -1495,7 +1495,7 @@ fn fixed_bytes() {
return(data[j][i]);
}
}
"##,
"#,
);

runtime.constructor(0, vec![]);
Expand Down
52 changes: 26 additions & 26 deletions tests/polkadot_tests/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ use crate::build_solidity;
#[test]
fn abi_decode() {
let mut runtime = build_solidity(
r##"
r#"
contract bar {
function test() public {
(int16 a, bool b) = abi.decode(hex"7f0001", (int16, bool));
assert(a == 127);
assert(b == true);
}
}"##,
}"#,
);

runtime.function("test", Vec::new());

let mut runtime = build_solidity(
r##"
r#"
contract bar {
function test() public {
uint8 a = abi.decode(hex"40", (uint8));
assert(a == 64);
}
}"##,
}"#,
);

runtime.function("test", Vec::new());
Expand All @@ -37,7 +37,7 @@ fn abi_decode() {
#[test]
fn abi_encode() {
let mut runtime = build_solidity(
r##"
r#"
struct s {
int32 f1;
uint8 f2;
Expand Down Expand Up @@ -65,7 +65,7 @@ fn abi_encode() {
assert(abi.encode(x) == hex"ff010000f71874657374696504000500");
}
}"##,
}"#,
);

runtime.function("test", Vec::new());
Expand All @@ -81,7 +81,7 @@ fn abi_encode() {
#[test]
fn abi_encode_packed() {
let mut runtime = build_solidity(
r##"
r#"
struct s {
int32 f1;
uint8 f2;
Expand Down Expand Up @@ -110,7 +110,7 @@ fn abi_encode_packed() {
assert(abi.encodePacked(x) == hex"ff010000f774657374696504000500");
}
}"##,
}"#,
);

runtime.function("test", Vec::new());
Expand All @@ -123,7 +123,7 @@ fn abi_encode_packed() {
#[test]
fn abi_encode_with_selector() {
let mut runtime = build_solidity(
r##"
r#"
contract bar {
function test1() public {
uint16 a = 0xfd01;
Expand All @@ -143,7 +143,7 @@ fn abi_encode_with_selector() {
assert(abi.encodeWithSelector(hex"01020304", arr) == hex"010203040cfefcf8");
}
}"##,
}"#,
);

runtime.function("test1", Vec::new());
Expand All @@ -154,7 +154,7 @@ fn abi_encode_with_selector() {
#[test]
fn abi_encode_with_signature() {
let mut runtime = build_solidity(
r##"
r#"
contract bar {
string bla = "Hello, World!";
Expand All @@ -174,7 +174,7 @@ fn abi_encode_with_signature() {
assert(abi.encodeWithSelector(hex"01020304", arr) == hex"010203040cfefcf8");
}
}"##,
}"#,
);

runtime.constructor(0, Vec::new());
Expand All @@ -185,7 +185,7 @@ fn abi_encode_with_signature() {
#[test]
fn call() {
let mut runtime = build_solidity(
r##"
r#"
contract superior {
function test1() public {
inferior i = new inferior();
Expand Down Expand Up @@ -228,15 +228,15 @@ fn call() {
function test2(uint64 x) public returns (uint64) {
return x ^ 1;
}
}"##,
}"#,
);

runtime.constructor(0, Vec::new());
runtime.function("test1", Vec::new());
runtime.function("test2", Vec::new());

let mut runtime = build_solidity(
r##"
r#"
contract superior {
function test1() public {
inferior i = new inferior();
Expand Down Expand Up @@ -287,7 +287,7 @@ fn call() {
function test2(uint64 x) public returns (uint64) {
return x ^ 1;
}
}"##,
}"#,
);

runtime.constructor(0, Vec::new());
Expand Down Expand Up @@ -430,7 +430,7 @@ fn data() {
struct String(Vec<u8>);

let mut runtime = build_solidity(
r##"
r#"
contract bar {
constructor(string memory s) public {
assert(msg.data == hex"98dd1bb318666f6f626172");
Expand All @@ -441,7 +441,7 @@ fn data() {
assert(msg.data == hex"e3cff634addeadde");
assert(msg.sig == hex"e3cf_f634");
}
}"##,
}"#,
);

runtime.constructor(0, String(b"foobar".to_vec()).encode());
Expand Down Expand Up @@ -713,7 +713,7 @@ fn my_token() {
#[test]
fn hash() {
let mut runtime = build_solidity(
r##"
r#"
import "polkadot";
contract Foo {
Expand All @@ -735,7 +735,7 @@ fn hash() {
assert(abi.encode(current2) == abi.encode(h));
}
}
"##,
"#,
);

#[derive(Encode)]
Expand All @@ -759,14 +759,14 @@ fn hash() {
#[test]
fn call_chain_extension() {
let mut runtime = build_solidity(
r##"
r#"
import {chain_extension as ChainExtension} from "polkadot";
contract Foo {
function chain_extension(bytes input) public returns (uint32, bytes) {
return ChainExtension(123, input);
}
}"##,
}"#,
);

let data = 0xdeadbeefu32.to_be_bytes().to_vec();
Expand All @@ -779,13 +779,13 @@ fn call_chain_extension() {
#[test]
fn is_contract() {
let mut runtime = build_solidity(
r##"
r#"
import "polkadot";
contract Foo {
function test(address _a) public view returns (bool) {
return is_contract(_a);
}
}"##,
}"#,
);

runtime.function("test", runtime.0.data().accounts[0].address.to_vec());
Expand All @@ -798,7 +798,7 @@ fn is_contract() {
#[test]
fn set_code_hash() {
let mut runtime = build_solidity(
r##"
r#"
import "polkadot";
abstract contract SetCode {
Expand All @@ -821,7 +821,7 @@ fn set_code_hash() {
function inc() external {
count -= 1;
}
}"##,
}"#,
);

runtime.function("inc", vec![]);
Expand Down
Loading

0 comments on commit 1693d29

Please sign in to comment.