test_merged_tree: avoid a temporary lifetime extension
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
nix / flake check (push) Waiting to run
build / build (, macos-13) (push) Waiting to run
build / build (, macos-14) (push) Waiting to run
build / build (, ubuntu-latest) (push) Waiting to run
build / build (, windows-latest) (push) Waiting to run
build / build (--all-features, ubuntu-latest) (push) Waiting to run
build / Build jj-lib without Git support (push) Waiting to run
build / Check protos (push) Waiting to run
build / Check formatting (push) Waiting to run
build / Check that MkDocs can build the docs (push) Waiting to run
build / Check that MkDocs can build the docs with latest Python and uv (push) Waiting to run
build / cargo-deny (advisories) (push) Waiting to run
build / cargo-deny (bans licenses sources) (push) Waiting to run
build / Clippy check (push) Waiting to run
Codespell / Codespell (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-latest) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run

I think it's just clearer to assign the owned value to the variable
than to assign a reference to a temporary value.
This commit is contained in:
Martin von Zweigbergk 2024-11-27 14:59:04 -08:00 committed by Martin von Zweigbergk
parent 409be2e1c4
commit a5690beab5

View file

@ -157,11 +157,11 @@ fn test_from_legacy_tree() {
// dir1: directory without conflicts // dir1: directory without conflicts
let dir1_basename = RepoPathComponent::new("dir1"); let dir1_basename = RepoPathComponent::new("dir1");
let dir1_filename = &RepoPath::root() let dir1_filename = RepoPath::root()
.join(dir1_basename) .join(dir1_basename)
.join(RepoPathComponent::new("file")); .join(RepoPathComponent::new("file"));
let dir1_filename_id = write_file(store.as_ref(), dir1_filename, "file5_v2"); let dir1_filename_id = write_file(store.as_ref(), &dir1_filename, "file5_v2");
tree_builder.set(dir1_filename.to_owned(), file_value(&dir1_filename_id)); tree_builder.set(dir1_filename.clone(), file_value(&dir1_filename_id));
let tree_id = tree_builder.write_tree().unwrap(); let tree_id = tree_builder.write_tree().unwrap();
let tree = store.get_tree(RepoPathBuf::root(), &tree_id).unwrap(); let tree = store.get_tree(RepoPathBuf::root(), &tree_id).unwrap();
@ -269,7 +269,7 @@ fn test_from_legacy_tree() {
tree_builder.set_or_remove(file3_path.to_owned(), file3_conflict); tree_builder.set_or_remove(file3_path.to_owned(), file3_conflict);
tree_builder.set_or_remove(file4_path.to_owned(), file4_conflict); tree_builder.set_or_remove(file4_path.to_owned(), file4_conflict);
tree_builder.set_or_remove( tree_builder.set_or_remove(
dir1_filename.to_owned(), dir1_filename.clone(),
Merge::normal(file_value(&dir1_filename_id)), Merge::normal(file_value(&dir1_filename_id)),
); );
let recreated_merged_id = tree_builder.write_tree(store).unwrap(); let recreated_merged_id = tree_builder.write_tree(store).unwrap();