mirror of
https://github.com/fluencelabs/aquavm
synced 2025-06-18 09:21:21 +00:00
Make unstable clippy happy with clippy --fix
(#402)
Most of changes either move variables into `format!` templates or remove excessive clones.
This commit is contained in:
@ -121,7 +121,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_parse_garbage0() {
|
||||
let res = ServiceDefinition::from_str("garbage");
|
||||
assert!(res.is_err(), "{:?}", res);
|
||||
assert!(res.is_err(), "{}", "{res:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -270,13 +270,13 @@ mod tests {
|
||||
let other_id2: PeerId = "other2".into();
|
||||
let network = Network::empty();
|
||||
|
||||
let penv = PeerEnv::new(Peer::new(peer_id.clone(), Rc::from(vec![])), &network);
|
||||
let penv = PeerEnv::new(Peer::new(peer_id, Rc::from(vec![])), &network);
|
||||
// iter is empty
|
||||
assert!(penv.iter().next().is_none());
|
||||
|
||||
network.ensure_peer(other_id1.clone());
|
||||
network.ensure_peer(other_id2.clone());
|
||||
let expected_neighborhood = PeerSet::from([other_id1.clone(), other_id2.clone()]);
|
||||
let expected_neighborhood = PeerSet::from([other_id1, other_id2]);
|
||||
assert_eq!(penv.iter().collect::<PeerSet>(), expected_neighborhood);
|
||||
}
|
||||
|
||||
@ -286,14 +286,14 @@ mod tests {
|
||||
let peer_id: PeerId = "someone".into();
|
||||
let other_id1: PeerId = "other1".into();
|
||||
let other_id2: PeerId = "other2".into();
|
||||
let penv = PeerEnv::new(Peer::new(peer_id.clone(), Rc::from(vec![])), &network);
|
||||
let penv = PeerEnv::new(Peer::new(peer_id, Rc::from(vec![])), &network);
|
||||
|
||||
// iter is empty
|
||||
assert!(penv.iter().next().is_none());
|
||||
|
||||
network.ensure_peer(other_id1.clone());
|
||||
network.ensure_peer(other_id2.clone());
|
||||
let expected_neighborhood = PeerSet::from([other_id1.clone(), other_id2.clone()]);
|
||||
let expected_neighborhood = PeerSet::from([other_id1, other_id2]);
|
||||
assert_eq!(PeerSet::from_iter(penv.iter()), expected_neighborhood);
|
||||
}
|
||||
|
||||
@ -303,7 +303,7 @@ mod tests {
|
||||
let peer_id: PeerId = "someone".into();
|
||||
let other_id1: PeerId = "other1".into();
|
||||
let other_id2: PeerId = "other2".into();
|
||||
let mut penv = PeerEnv::new(Peer::new(peer_id.clone(), Rc::from(vec![])), &network);
|
||||
let mut penv = PeerEnv::new(Peer::new(peer_id, Rc::from(vec![])), &network);
|
||||
|
||||
// iter is empty
|
||||
assert!(penv.iter().next().is_none());
|
||||
@ -311,7 +311,7 @@ mod tests {
|
||||
nei.alter(other_id1.clone(), AlterState::Added);
|
||||
nei.alter(other_id2.clone(), AlterState::Added);
|
||||
|
||||
let expected_neighborhood = PeerSet::from([other_id1.clone(), other_id2.clone()]);
|
||||
let expected_neighborhood = PeerSet::from([other_id1, other_id2]);
|
||||
assert_eq!(PeerSet::from_iter(penv.iter()), expected_neighborhood);
|
||||
}
|
||||
|
||||
@ -320,7 +320,7 @@ mod tests {
|
||||
let network = Network::empty();
|
||||
let peer_id: PeerId = "someone".into();
|
||||
let other_id1: PeerId = "other1".into();
|
||||
let mut penv = PeerEnv::new(Peer::new(peer_id.clone(), Rc::from(vec![])), &network);
|
||||
let mut penv = PeerEnv::new(Peer::new(peer_id, Rc::from(vec![])), &network);
|
||||
|
||||
// iter is empty
|
||||
assert!(penv.iter().next().is_none());
|
||||
@ -337,7 +337,7 @@ mod tests {
|
||||
fn test_extend_neighborhood() {
|
||||
let network = Network::empty();
|
||||
let peer_id: PeerId = "someone".into();
|
||||
let mut penv = PeerEnv::new(Peer::new(peer_id.clone(), Rc::from(vec![])), &network);
|
||||
let mut penv = PeerEnv::new(Peer::new(peer_id, Rc::from(vec![])), &network);
|
||||
penv.get_neighborhood_mut()
|
||||
.alter(PeerId::from("zero"), AlterState::Added);
|
||||
penv.extend_neighborhood(IntoIterator::into_iter(["one", "two"]));
|
||||
@ -352,7 +352,7 @@ mod tests {
|
||||
fn test_remove_from_neiborhood() {
|
||||
let network = Network::empty();
|
||||
let peer_id: PeerId = "someone".into();
|
||||
let mut penv = PeerEnv::new(Peer::new(peer_id.clone(), Rc::from(vec![])), &network);
|
||||
let mut penv = PeerEnv::new(Peer::new(peer_id, Rc::from(vec![])), &network);
|
||||
penv.get_neighborhood_mut()
|
||||
.alter(PeerId::from("zero"), AlterState::Added);
|
||||
penv.extend_neighborhood(IntoIterator::into_iter(["one", "two"]));
|
||||
@ -370,7 +370,7 @@ mod tests {
|
||||
let network = Network::empty();
|
||||
let peer_id: PeerId = "someone".into();
|
||||
let other_id: PeerId = "other".into();
|
||||
let mut penv = PeerEnv::new(Peer::new(peer_id.clone(), Rc::from(vec![])), &network);
|
||||
let mut penv = PeerEnv::new(Peer::new(peer_id, Rc::from(vec![])), &network);
|
||||
|
||||
let nei = penv.get_neighborhood_mut();
|
||||
nei.alter(other_id.clone(), AlterState::Added);
|
||||
@ -386,7 +386,7 @@ mod tests {
|
||||
let network = Network::empty();
|
||||
let peer_id: PeerId = "someone".into();
|
||||
let other_id: PeerId = "other".into();
|
||||
let mut penv = PeerEnv::new(Peer::new(peer_id.clone(), Rc::from(vec![])), &network);
|
||||
let mut penv = PeerEnv::new(Peer::new(peer_id, Rc::from(vec![])), &network);
|
||||
|
||||
let nei = penv.get_neighborhood_mut();
|
||||
nei.alter(other_id.clone(), AlterState::Added);
|
||||
@ -407,7 +407,7 @@ mod tests {
|
||||
let network = Network::empty();
|
||||
let peer_id: PeerId = "someone".into();
|
||||
let other_id: PeerId = "other".into();
|
||||
let mut penv = PeerEnv::new(Peer::new(peer_id.clone(), Rc::from(vec![])), &network);
|
||||
let mut penv = PeerEnv::new(Peer::new(peer_id, Rc::from(vec![])), &network);
|
||||
|
||||
let nei = penv.get_neighborhood_mut();
|
||||
nei.alter(other_id.clone(), AlterState::Added);
|
||||
|
@ -511,7 +511,7 @@ mod tests {
|
||||
|
||||
let transformed2 = TransformedAirScript::new(
|
||||
&f!(r#"(call "{}" ("service" "function") []) ; ok = 24"#, peer),
|
||||
network.clone(),
|
||||
network,
|
||||
)
|
||||
.unwrap();
|
||||
let exectution2 = AirScriptExecutor::from_transformed_air_script(
|
||||
@ -559,7 +559,7 @@ mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let transformed2 = TransformedAirScript::new(&air_script, network.clone()).unwrap();
|
||||
let transformed2 = TransformedAirScript::new(&air_script, network).unwrap();
|
||||
let exectution2 = AirScriptExecutor::from_transformed_air_script(
|
||||
TestRunParameters::from_init_peer_id(peer),
|
||||
transformed2,
|
||||
|
@ -61,12 +61,10 @@ impl Sexp {
|
||||
None => Err("cannot attach a service definition an empty list".to_owned()),
|
||||
},
|
||||
Sexp::Symbol(s) => Err(format!(
|
||||
"cannot attach a service definition to a symbol {:?}",
|
||||
s
|
||||
"cannot attach a service definition to a symbol {s:?}"
|
||||
)),
|
||||
Sexp::String(ref s) => Err(format!(
|
||||
r#"cannot attach a service definition to a string: "{:?}""#,
|
||||
s
|
||||
r#"cannot attach a service definition to a string: "{s:?}""#
|
||||
)),
|
||||
}
|
||||
}
|
||||
@ -86,14 +84,14 @@ impl std::fmt::Display for Sexp {
|
||||
func = call.triplet.2,
|
||||
args = call.args.iter().format(" "),
|
||||
var = match &call.var {
|
||||
Some(var) => format!(" {}", var),
|
||||
Some(var) => format!(" {var}"),
|
||||
None => "".to_owned(),
|
||||
}
|
||||
)
|
||||
}
|
||||
Sexp::List(items) => write!(f, "({})", items.iter().format(" ")),
|
||||
Sexp::Symbol(symbol) => write!(f, "{}", symbol),
|
||||
Sexp::String(string) => write!(f, r#""{}""#, string),
|
||||
Sexp::Symbol(symbol) => write!(f, "{symbol}"),
|
||||
Sexp::String(string) => write!(f, r#""{string}""#),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -108,34 +106,34 @@ mod tests {
|
||||
fn test_parse_fmt_call() {
|
||||
let sexp_str = r#"(call "my_id" ("serv" "function") [other_peer_id "other_arg"])"#;
|
||||
let sexp = Sexp::from_str(sexp_str).unwrap();
|
||||
assert_eq!(format!("{}", sexp), sexp_str);
|
||||
assert_eq!(format!("{sexp}"), sexp_str);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_fmt_call_var() {
|
||||
let sexp_str = r#"(call "my_id" ("serv" "function") [other_peer_id "other_arg"] var)"#;
|
||||
let sexp = Sexp::from_str(sexp_str).unwrap();
|
||||
assert_eq!(format!("{}", sexp), sexp_str);
|
||||
assert_eq!(format!("{sexp}"), sexp_str);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_fmt_symbol() {
|
||||
let sexp_str = "symbol";
|
||||
let sexp = Sexp::from_str(sexp_str).unwrap();
|
||||
assert_eq!(format!("{}", sexp), sexp_str);
|
||||
assert_eq!(format!("{sexp}"), sexp_str);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_fmt_string() {
|
||||
let sexp_str = r#""my_id""#;
|
||||
let sexp = Sexp::from_str(sexp_str).unwrap();
|
||||
assert_eq!(format!("{}", sexp), sexp_str);
|
||||
assert_eq!(format!("{sexp}"), sexp_str);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_fmt_sexp() {
|
||||
let sexp_str = r#"(par (ap x y) (fold x y (next)))"#;
|
||||
let sexp = Sexp::from_str(sexp_str).unwrap();
|
||||
assert_eq!(format!("{}", sexp), sexp_str);
|
||||
assert_eq!(format!("{sexp}"), sexp_str);
|
||||
}
|
||||
}
|
||||
|
@ -580,7 +580,7 @@ mod tests {
|
||||
(call peerid ("serv" "func") [a b] var) ; ok=42
|
||||
(call peerid2 ("serv" "func") []))"#,
|
||||
);
|
||||
assert!(res.is_ok(), "{:?}", res);
|
||||
assert!(res.is_ok(), "{}", "{res:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -609,7 +609,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_trailing_error() {
|
||||
let res = Sexp::from_str("(null))");
|
||||
assert!(res.is_err(), "{:?}", res);
|
||||
assert!(res.is_err(), "{}", "{res:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -648,42 +648,42 @@ mod tests {
|
||||
fn test_parse_fmt_call() {
|
||||
let sexp_str = r#"(call "my_id" ("serv" "function") [other_peer_id "other_arg"])"#;
|
||||
let sexp = Sexp::from_str(sexp_str).unwrap();
|
||||
assert_eq!(format!("{}", sexp), sexp_str);
|
||||
assert_eq!(format!("{sexp}"), sexp_str);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_fmt_call_var() {
|
||||
let sexp_str = r#"(call "my_id" ("serv" "function") [other_peer_id "other_arg"] var)"#;
|
||||
let sexp = Sexp::from_str(sexp_str).unwrap();
|
||||
assert_eq!(format!("{}", sexp), sexp_str);
|
||||
assert_eq!(format!("{sexp}"), sexp_str);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_fmt_symbol() {
|
||||
let sexp_str = "symbol";
|
||||
let sexp = Sexp::from_str(sexp_str).unwrap();
|
||||
assert_eq!(format!("{}", sexp), sexp_str);
|
||||
assert_eq!(format!("{sexp}"), sexp_str);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_fmt_string() {
|
||||
let sexp_str = r#""my_id""#;
|
||||
let sexp = Sexp::from_str(sexp_str).unwrap();
|
||||
assert_eq!(format!("{}", sexp), sexp_str);
|
||||
assert_eq!(format!("{sexp}"), sexp_str);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_fmt_sexp() {
|
||||
let sexp_str = r#"(par (ap x y) (fold x y (next)))"#;
|
||||
let sexp = Sexp::from_str(sexp_str).unwrap();
|
||||
assert_eq!(format!("{}", sexp), sexp_str);
|
||||
assert_eq!(format!("{sexp}"), sexp_str);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_canon_syntax() {
|
||||
let sexp_str = r#"(seq (canon peer_id $stream #canon) (fold #canon i (next)))"#;
|
||||
let res = Sexp::from_str(sexp_str);
|
||||
assert!(res.is_ok(), "{:?}", res);
|
||||
assert!(res.is_ok(), "{}", "{res:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -726,7 +726,7 @@ mod tests {
|
||||
"0": null
|
||||
} |#"#;
|
||||
let res = parse_annotation_comment(multiline_annotation.into());
|
||||
assert!(res.is_ok(), "{:?}", res);
|
||||
assert!(res.is_ok(), "{}", "{res:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -94,7 +94,7 @@ impl Transformer<'_> {
|
||||
|
||||
match &mut call.triplet.1 {
|
||||
Sexp::String(ref mut value) => {
|
||||
write!(value, "..{}", call_id).unwrap();
|
||||
write!(value, "..{call_id}").unwrap();
|
||||
}
|
||||
_ => panic!("Incorrect script: non-string service string not supported"),
|
||||
}
|
||||
|
Reference in New Issue
Block a user