From 2d81cf91560ce891d3150e90227442d6dbdf449e Mon Sep 17 00:00:00 2001 From: Alexander Potashev Date: Tue, 15 Aug 2023 00:21:03 +0200 Subject: [PATCH] Fix build when `bstr` is also imported. Add type annotation to `vec` to avoid the following build error if you additionally import `bstr`: ``` ~/jj> cargo test Compiling jj-lib v0.8.0 (/home/aspotashev/jj/lib) warning: unused import: `bstr` --> lib/src/default_index_store.rs:30:5 | 30 | use bstr; | ^^^^ | = note: `#[warn(unused_imports)]` on by default error[E0282]: type annotations needed --> lib/src/default_index_store.rs:564:14 | 564 | .as_mut() | ^^^^^^ 565 | .write_u32::(parent_overflow.len() as u32) | --------- type must be known at this point | help: try using a fully qualified path to specify the expected types | 563 | <[u8] as AsMut>::as_mut(&mut buf[parent_overflow_offset..parent_overflow_offset + 4]) | +++++++++++++++++++++++++++++++ ~ For more information about this error, try `rustc --explain E0282`. warning: `jj-lib` (lib) generated 1 warning error: could not compile `jj-lib` (lib) due to previous error; 1 warning emitted ``` Reason to support `bstr` being imported: in a Bazel environment where crates are imported with certain features enabled, jj-lib may pull in bstr as part of the following dependency chain: jj-lib -> insta -> similar -> bstr. --- lib/src/default_index_store.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/src/default_index_store.rs b/lib/src/default_index_store.rs index c179f1b88..1bc70aab5 100644 --- a/lib/src/default_index_store.rs +++ b/lib/src/default_index_store.rs @@ -560,8 +560,7 @@ impl MutableIndexImpl { buf.write_u32::(pos.0).unwrap(); } - buf[parent_overflow_offset..parent_overflow_offset + 4] - .as_mut() + (&mut buf[parent_overflow_offset..parent_overflow_offset + 4]) .write_u32::(parent_overflow.len() as u32) .unwrap(); for parent_pos in parent_overflow {