From 182568a8dab8d925ffc7a0fac9f694b82d8f5f44 Mon Sep 17 00:00:00 2001 From: Yann Hamdaoui Date: Mon, 28 Aug 2023 13:01:43 +0200 Subject: [PATCH] flake.lock: Update (#1545) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * flake.lock: Update Flake lock file updates: • Updated input 'crane': 'github:ipetkov/crane/7809d369710abb17767b624f9e72b500373580bc' (2023-08-12) → 'github:ipetkov/crane/ef5d11e3c2e5b3924eb0309dba2e1fea2d9062ae' (2023-08-23) • Updated input 'flake-utils': 'github:numtide/flake-utils/919d646de7be200f3bf08cb76ae1f09402b6f9b4' (2023-07-11) → 'github:numtide/flake-utils/f9e7cf818399d17d347f847525c5a5a8032e4e44' (2023-08-23) • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/d680ded26da5cf104dd2735a51e88d2d8f487b4d' (2023-08-19) → 'github:NixOS/nixpkgs/5690c4271f2998c304a45c91a0aeb8fb69feaea7' (2023-08-25) • Updated input 'rust-overlay': 'github:oxalica/rust-overlay/598b2f04ed252eb5808b108d7a10084c0c548753' (2023-08-19) → 'github:oxalica/rust-overlay/e90223633068a44f0fb62374e0fa360ccc987292' (2023-08-26) • Updated input 'topiary': 'github:tweag/topiary/e30432a29b6d3bb606cbb09b022a5ad0598810dc' (2023-07-31) → 'github:tweag/topiary/577fe940aa0b9dae478b463bddd1238e20f86e3a' (2023-08-24) * Run `cargo fmt` * Fix new clippy lints --------- Co-authored-by: github-actions[bot] Co-authored-by: Viktor Kleen --- cli/tests/integration/main.rs | 4 +- core/src/cache.rs | 2 +- core/src/eval/merge.rs | 8 +-- core/src/eval/mod.rs | 2 +- core/src/eval/operation.rs | 76 +++++++++++++++++++++----- core/src/parser/tests.rs | 2 +- core/src/parser/utils.rs | 21 +------ core/src/serialize.rs | 4 +- core/src/term/mod.rs | 4 +- core/src/term/string.rs | 2 +- core/src/typecheck/destructuring.rs | 24 ++++++-- core/src/typecheck/unif.rs | 2 +- flake.lock | 30 +++++----- lsp/nls/src/linearization/completed.rs | 2 +- lsp/nls/src/linearization/mod.rs | 4 +- lsp/nls/src/requests/completion.rs | 16 +++--- lsp/nls/src/requests/goto.rs | 2 +- 17 files changed, 123 insertions(+), 82 deletions(-) diff --git a/cli/tests/integration/main.rs b/cli/tests/integration/main.rs index 204f98ea39..a993c1de01 100644 --- a/cli/tests/integration/main.rs +++ b/cli/tests/integration/main.rs @@ -19,8 +19,8 @@ fn test_creates_output_files(command: &[&str]) { .spawn() .expect("Nickel should be runnable"); let Some(mut stdin) = nickel.stdin.take() else { - panic!("couldn't retrieve stdin handle to Nickel") - }; + panic!("couldn't retrieve stdin handle to Nickel") + }; stdin .write_all(b"{foo=1}") .expect("writing into Nickel stdin should work"); diff --git a/core/src/cache.rs b/core/src/cache.rs index 59a8dfcc4a..913e18cb62 100644 --- a/core/src/cache.rs +++ b/core/src/cache.rs @@ -962,7 +962,7 @@ impl Cache { /// Returns true if a particular file id represents a Nickel standard library file, false otherwise. pub fn is_stdlib_module(&self, file: FileId) -> bool { let Some(table) = &self.stdlib_ids else { - return false + return false; }; table.values().any(|stdlib_file| *stdlib_file == file) } diff --git a/core/src/eval/merge.rs b/core/src/eval/merge.rs index 41c2d22c6a..182fe5750d 100644 --- a/core/src/eval/merge.rs +++ b/core/src/eval/merge.rs @@ -405,11 +405,7 @@ fn merge_fields<'a, C: Cache, I: DoubleEndedIterator + Clon }; let mut pending_contracts = pending_contracts1.revert_closurize(cache, env_final, env1.clone()); - pending_contracts.extend( - pending_contracts2 - .revert_closurize(cache, env_final, env2.clone()) - .into_iter(), - ); + pending_contracts.extend(pending_contracts2.revert_closurize(cache, env_final, env2.clone())); // Annotation aren't used anymore at runtime. We still accumulate them to answer metadata // queries, but we don't need to e.g. closurize or revert them. @@ -429,7 +425,7 @@ fn merge_fields<'a, C: Cache, I: DoubleEndedIterator + Clon let contracts: Vec<_> = annot1 .contracts .into_iter() - .chain(annot2.contracts.into_iter()) + .chain(annot2.contracts) .collect(); let metadata = FieldMetadata { diff --git a/core/src/eval/mod.rs b/core/src/eval/mod.rs index 7f39b3969f..2bfbb7060f 100644 --- a/core/src/eval/mod.rs +++ b/core/src/eval/mod.rs @@ -237,7 +237,7 @@ impl VirtualMachine { let mut path = path.0.into_iter().peekable(); let Some(mut prev_id) = path.peek().cloned() else { - return Ok(field) + return Ok(field); }; for id in path { diff --git a/core/src/eval/operation.rs b/core/src/eval/operation.rs index 4b95a36c74..ba760867f7 100644 --- a/core/src/eval/operation.rs +++ b/core/src/eval/operation.rs @@ -563,7 +563,7 @@ impl VirtualMachine { .ok_or_else(|| EvalError::NotEnoughArgs(2, String::from("generate"), pos_op))?; let Term::Num(ref n) = *t else { - return Err(mk_type_error!("generate", "Number")) + return Err(mk_type_error!("generate", "Number")); }; if n < &Number::ZERO { @@ -576,12 +576,12 @@ impl VirtualMachine { } let Ok(n_int) = u32::try_from(n) else { - return Err(EvalError::Other( + return Err(EvalError::Other( format!( "generate expects its first argument to be an integer smaller than {}, got {n}", u32::MAX, ), pos_op, - )) + )); }; let mut shared_env = Environment::new(); @@ -1268,11 +1268,11 @@ impl VirtualMachine { } BinaryOp::Modulo() => { let Term::Num(ref n1) = *t1 else { - return Err(mk_type_error!("(%)", "Number", 1, t1, pos1)) + return Err(mk_type_error!("(%)", "Number", 1, t1, pos1)); }; let Term::Num(ref n2) = *t2 else { - return Err(mk_type_error!("(%)", "Number", 2, t2, pos2)) + return Err(mk_type_error!("(%)", "Number", 2, t2, pos2)); }; if n2 == &Number::ZERO { @@ -1779,7 +1779,7 @@ impl VirtualMachine { BinaryOp::ArrayElemAt() => match (&*t1, &*t2) { (Term::Array(ts, attrs), Term::Num(n)) => { let Ok(n_as_usize) = usize::try_from(n) else { - return Err(EvalError::Other(format!("elem_at expects its second argument to be a positive integer smaller than {}, got {n}", usize::MAX), pos_op)) + return Err(EvalError::Other(format!("elem_at expects its second argument to be a positive integer smaller than {}, got {n}", usize::MAX), pos_op)); }; if n_as_usize >= ts.len() { @@ -2078,11 +2078,23 @@ impl VirtualMachine { let t2 = t2.into_owned(); let Term::Str(message) = t1 else { - return Err(mk_type_error!("label_with_message", "String", 1, t1.into(), pos1)) + return Err(mk_type_error!( + "label_with_message", + "String", + 1, + t1.into(), + pos1 + )); }; let Term::Lbl(label) = t2 else { - return Err(mk_type_error!("label_with_message", "String", 2, t2.into(), pos2)) + return Err(mk_type_error!( + "label_with_message", + "String", + 2, + t2.into(), + pos2 + )); }; Ok(Closure::atomic_closure(RichTerm::new( @@ -2108,7 +2120,13 @@ impl VirtualMachine { let t1 = t1_subst.term.into_owned(); let Term::Array(array, _) = t1 else { - return Err(mk_type_error!("label_with_notes", "Array String", 1, t1.into(), pos1)); + return Err(mk_type_error!( + "label_with_notes", + "Array String", + 1, + t1.into(), + pos1 + )); }; let notes = array @@ -2131,7 +2149,13 @@ impl VirtualMachine { .collect::, _>>()?; let Term::Lbl(label) = t2 else { - return Err(mk_type_error!("label_with_notes", "Label", 2, t2.into(), pos2)) + return Err(mk_type_error!( + "label_with_notes", + "Label", + 2, + t2.into(), + pos2 + )); }; Ok(Closure::atomic_closure(RichTerm::new( @@ -2144,11 +2168,23 @@ impl VirtualMachine { let t2 = t2.into_owned(); let Term::Str(note) = t1 else { - return Err(mk_type_error!("label_append_note", "String", 1, t1.into(), pos1)); + return Err(mk_type_error!( + "label_append_note", + "String", + 1, + t1.into(), + pos1 + )); }; let Term::Lbl(label) = t2 else { - return Err(mk_type_error!("label_append_note", "Label", 2, t2.into(), pos2)); + return Err(mk_type_error!( + "label_append_note", + "Label", + 2, + t2.into(), + pos2 + )); }; Ok(Closure::atomic_closure(RichTerm::new( @@ -2161,11 +2197,23 @@ impl VirtualMachine { let t2 = t2.into_owned(); let Term::SealingKey(key) = t1 else { - return Err(mk_type_error!("lookup_type_variable", "SealingKey", 1, t1.into(), pos1)); + return Err(mk_type_error!( + "lookup_type_variable", + "SealingKey", + 1, + t1.into(), + pos1 + )); }; let Term::Lbl(label) = t2 else { - return Err(mk_type_error!("lookup_type_variable", "Label", 2, t2.into(), pos2)); + return Err(mk_type_error!( + "lookup_type_variable", + "Label", + 2, + t2.into(), + pos2 + )); }; Ok(Closure::atomic_closure(RichTerm::new( diff --git a/core/src/parser/tests.rs b/core/src/parser/tests.rs index abafdb8de9..b7980fb1dd 100644 --- a/core/src/parser/tests.rs +++ b/core/src/parser/tests.rs @@ -513,7 +513,7 @@ fn ascii_escape() { #[test] fn multiline_str_escape() { assert_eq!( - parse_without_pos(r##"m%"%Hel%%lo%%%"%"##), + parse_without_pos(r#"m%"%Hel%%lo%%%"%"#), mk_single_chunk("%Hel%%lo%%%"), ); } diff --git a/core/src/parser/utils.rs b/core/src/parser/utils.rs index 26b26a1131..95d3433320 100644 --- a/core/src/parser/utils.rs +++ b/core/src/parser/utils.rs @@ -345,8 +345,8 @@ impl Combine for TypeAnnotation { let contracts = left .contracts .into_iter() - .chain(leftover.into_iter()) - .chain(right.contracts.into_iter()) + .chain(leftover) + .chain(right.contracts) .collect(); TypeAnnotation { typ, contracts } @@ -451,22 +451,7 @@ impl From for FieldExtAnnot { /// Turn dynamic accesses using literal chunks only into static accesses pub fn mk_access(access: RichTerm, root: RichTerm) -> RichTerm { - let label = match *access.term { - Term::StrChunks(ref chunks) => { - chunks - .iter() - .fold(Some(String::new()), |acc, next| match (acc, next) { - (Some(mut acc), StrChunk::Literal(lit)) => { - acc.push_str(lit); - Some(acc) - } - _ => None, - }) - } - _ => None, - }; - - if let Some(label) = label { + if let Some(label) = access.as_ref().try_str_chunk_as_static_str() { mk_term::op1( UnaryOp::StaticAccess(LocIdent::new_with_pos(label, access.pos)), root, diff --git a/core/src/serialize.rs b/core/src/serialize.rs index 2708503561..b97e55c57e 100644 --- a/core/src/serialize.rs +++ b/core/src/serialize.rs @@ -341,7 +341,7 @@ mod tests { assert_json_eq("null", null); assert_json_eq("if true then false else true", false); - assert_json_eq(r##""Hello, %{"world"}!""##, "Hello, world!"); + assert_json_eq(r#""Hello, %{"world"}!""#, "Hello, world!"); assert_json_eq("'foo", "foo"); } @@ -350,7 +350,7 @@ mod tests { assert_json_eq("[]", json!([])); assert_json_eq("[null, (1+1), (2+2), (3+3)]", json!([null, 2, 4, 6])); assert_json_eq( - r##"['a, ("b" ++ "c"), "d%{"e"}f", "g"]"##, + r#"['a, ("b" ++ "c"), "d%{"e"}f", "g"]"#, json!(["a", "bc", "def", "g"]), ); assert_json_eq( diff --git a/core/src/term/mod.rs b/core/src/term/mod.rs index 481c1c77c7..90df39d241 100644 --- a/core/src/term/mod.rs +++ b/core/src/term/mod.rs @@ -818,8 +818,8 @@ impl Term { Term::StrChunks(chunks) => { chunks .iter() - .fold(Some(String::new()), |acc, next| match (acc, next) { - (Some(mut acc), StrChunk::Literal(lit)) => { + .try_fold(String::new(), |mut acc, next| match next { + StrChunk::Literal(lit) => { acc.push_str(lit); Some(acc) } diff --git a/core/src/term/string.rs b/core/src/term/string.rs index f40a7ee0c1..24535f89a8 100644 --- a/core/src/term/string.rs +++ b/core/src/term/string.rs @@ -127,7 +127,7 @@ impl NickelString { } }); - Array::from_iter(result.into_iter()) + Array::from_iter(result) } } diff --git a/core/src/typecheck/destructuring.rs b/core/src/typecheck/destructuring.rs index 7bd9bd166e..9011871ed9 100644 --- a/core/src/typecheck/destructuring.rs +++ b/core/src/typecheck/destructuring.rs @@ -170,10 +170,16 @@ pub fn inject_pattern_variables( // ``` // // As such, we don't need to add it to the environment. - let UnifType::Concrete { typ: TypeF::Record(rs), .. } = ty else { - unreachable!("since this is a destructured record, \ + let UnifType::Concrete { + typ: TypeF::Record(rs), + .. + } = ty + else { + unreachable!( + "since this is a destructured record, \ its type was constructed by build_pattern_ty, \ - which means it must be a concrete record type") + which means it must be a concrete record type" + ) }; inject_pattern_variables(state, env, pat, rs) } @@ -182,10 +188,16 @@ pub fn inject_pattern_variables( env.insert(alias.ident(), ty.clone()); - let UnifType::Concrete{ typ: TypeF::Record(rs), .. } = ty else { - unreachable!("since this is a destructured record, \ + let UnifType::Concrete { + typ: TypeF::Record(rs), + .. + } = ty + else { + unreachable!( + "since this is a destructured record, \ its type was constructed by build_pattern_ty, \ - which means it must be a concrete record type") + which means it must be a concrete record type" + ) }; inject_pattern_variables(state, env, pattern, rs) } diff --git a/core/src/typecheck/unif.rs b/core/src/typecheck/unif.rs index 772180a39f..bf20a96d4e 100644 --- a/core/src/typecheck/unif.rs +++ b/core/src/typecheck/unif.rs @@ -930,7 +930,7 @@ pub fn constr_unify_rrows( } => constr_unify_rrows(constr, var_id, tail), UnifRecordRows::UnifVar { id, .. } if *id != var_id => { if let Some(u_constr) = constr.get_mut(id) { - u_constr.extend(p_constr.into_iter()); + u_constr.extend(p_constr); } else { constr.insert(*id, p_constr); } diff --git a/flake.lock b/flake.lock index d7599cc32f..3b07a038b5 100644 --- a/flake.lock +++ b/flake.lock @@ -26,11 +26,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1691803597, - "narHash": "sha256-khWW1Owzselq5o816Lb7x624d6QGnv+kpronK3ndkr4=", + "lastModified": 1692750383, + "narHash": "sha256-n5P5HOXuu23UB1h9PuayldnRRVQuXJLpoO+xqtMO3ws=", "owner": "ipetkov", "repo": "crane", - "rev": "7809d369710abb17767b624f9e72b500373580bc", + "rev": "ef5d11e3c2e5b3924eb0309dba2e1fea2d9062ae", "type": "github" }, "original": { @@ -134,11 +134,11 @@ "systems": "systems_2" }, "locked": { - "lastModified": 1689068808, - "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "lastModified": 1692799911, + "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", "owner": "numtide", "repo": "flake-utils", - "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", "type": "github" }, "original": { @@ -239,11 +239,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1692447944, - "narHash": "sha256-fkJGNjEmTPvqBs215EQU4r9ivecV5Qge5cF/QDLVn3U=", + "lastModified": 1693003285, + "narHash": "sha256-5nm4yrEHKupjn62MibENtfqlP6pWcRTuSKrMiH9bLkc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "d680ded26da5cf104dd2735a51e88d2d8f487b4d", + "rev": "5690c4271f2998c304a45c91a0aeb8fb69feaea7", "type": "github" }, "original": { @@ -355,11 +355,11 @@ ] }, "locked": { - "lastModified": 1692410823, - "narHash": "sha256-YM1QCenpghNqgleUmoCJUArTuMEBqScyQuhepA6JZaI=", + "lastModified": 1693015707, + "narHash": "sha256-SFr93DYn502sVT9nB5U8/cKg1INyEk/jCeq8tHioz7Y=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "598b2f04ed252eb5808b108d7a10084c0c548753", + "rev": "e90223633068a44f0fb62374e0fa360ccc987292", "type": "github" }, "original": { @@ -501,11 +501,11 @@ "rust-overlay": "rust-overlay_4" }, "locked": { - "lastModified": 1690785895, - "narHash": "sha256-xigE+pgdUXyz3x6TMUMnJqEUtnl73HMLC6qC4Aff5XM=", + "lastModified": 1692863481, + "narHash": "sha256-DVtBD72proHmrcCXQWkfyecTYX9ugbd9cV8SD6VZoxk=", "owner": "tweag", "repo": "topiary", - "rev": "e30432a29b6d3bb606cbb09b022a5ad0598810dc", + "rev": "577fe940aa0b9dae478b463bddd1238e20f86e3a", "type": "github" }, "original": { diff --git a/lsp/nls/src/linearization/completed.rs b/lsp/nls/src/linearization/completed.rs index 43ea9f86a7..254965bccc 100644 --- a/lsp/nls/src/linearization/completed.rs +++ b/lsp/nls/src/linearization/completed.rs @@ -60,7 +60,7 @@ impl Completed { Option<&LinearizationItem>, ) { let Some(index) = self.id_to_index.get(&id).copied() else { - return (None, None) + return (None, None); }; let (left_index, right_index) = (index - 1, index + 1); let left = self.linearization.get(left_index); diff --git a/lsp/nls/src/linearization/mod.rs b/lsp/nls/src/linearization/mod.rs index b4e0bf6d1b..04d2b1edbb 100644 --- a/lsp/nls/src/linearization/mod.rs +++ b/lsp/nls/src/linearization/mod.rs @@ -493,7 +493,7 @@ impl<'a> Linearizer for AnalysisHost<'a> { } let Some(linearization) = lin.lin_registry.map.get(file) else { - return + return; }; // This is safe because the import file is resolved before we linearize the @@ -505,7 +505,7 @@ impl<'a> Linearizer for AnalysisHost<'a> { // happens if the `RichTerm` has been transformed or evaluated. None of these // happen before linearization. let Some(term_id) = linearization.item_at(position.unwrap().start_pos()) else { - return + return; }; let term_id = term_id.id; diff --git a/lsp/nls/src/requests/completion.rs b/lsp/nls/src/requests/completion.rs index 56dabad22d..d2febc93e2 100644 --- a/lsp/nls/src/requests/completion.rs +++ b/lsp/nls/src/requests/completion.rs @@ -130,7 +130,7 @@ fn find_fields_from_term_kind( }: ComplCtx<'_>, ) -> Vec { let Some(item) = linearization.get_item_with_reg(id, lin_registry) else { - return Vec::new() + return Vec::new(); }; let mut path_clone = path.clone(); let contract_result = find_fields_from_contract(item.id, &mut path_clone, info); @@ -205,7 +205,7 @@ fn find_fields_from_contract( }: ComplCtx<'_>, ) -> Vec { let Some(item) = linearization.get_item_with_reg(id, lin_cache) else { - return Vec::new() + return Vec::new(); }; match &item.metadata { Some(metadata) => find_fields_from_contracts(&metadata.annotation, path, info), @@ -316,7 +316,7 @@ fn find_fields_from_term_with_annot( let mut info_from_metadata = find_fields_from_contracts(annot, path, info); if let Some(value) = value { - info_from_metadata.extend(find_fields_from_term(value, path, info).into_iter()); + info_from_metadata.extend(find_fields_from_term(value, path, info)); } info_from_metadata @@ -555,7 +555,7 @@ fn get_completion_identifiers( path: &mut Vec, ) -> Vec { let Some(item_id) = item.env.get(&name.ident()) else { - return Vec::new() + return Vec::new(); }; let lin = server.lin_cache_get(&item_id.file_id).unwrap(); collect_record_info(lin, *item_id, path, &server.lin_registry) @@ -596,7 +596,7 @@ fn get_completion_identifiers( Some(server::DOT_COMPL_TRIGGER) => { // Record completion let Some(path) = get_identifier_path(source) else { - return Ok(Vec::new()) + return Ok(Vec::new()); }; let mut path: Vec<_> = path.iter().rev().cloned().map(LocIdent::from).collect(); @@ -846,13 +846,13 @@ mod tests { ), ( "Record binding with unicode string names for fields", - r##"let x = {"fo京o" = {bar = 42}} in x."fo京o".foo"##, + r#"let x = {"fo京o" = {bar = 42}} in x."fo京o".foo"#, Some(vec!["x", "fo京o", "foo"]), ), ( "Typed record binding with nested record indexing", - r##"let me : _ = { name = "foo", time = 1800, a.b.c.d = 10 } in - me.ca.cb"##, + r#"let me : _ = { name = "foo", time = 1800, a.b.c.d = 10 } in + me.ca.cb"#, Some(vec!["me", "ca", "cb"]), ), ("Single quote", "\"", None), diff --git a/lsp/nls/src/requests/goto.rs b/lsp/nls/src/requests/goto.rs index 7e13972563..c73d74e6ea 100644 --- a/lsp/nls/src/requests/goto.rs +++ b/lsp/nls/src/requests/goto.rs @@ -29,7 +29,7 @@ pub fn handle_to_definition( let Some(item) = linearization.item_at(pos) else { server.reply(Response::new_ok(id, Value::Null)); - return Ok(()) + return Ok(()); }; debug!("found referencing item: {:?}", item);