mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-01 11:49:01 +00:00
tree: remove useless pinning of Tree object
Since Tree is Unpin, Pin<Box<Tree>> can be moved and it's basically the same as Box<Tree>. I heard using Box<T> still violates strict aliasing rule, but Pin wouldn't give any additional guarantee. https://morestina.net/blog/1868/self-referential-types-for-fun-and-profit
This commit is contained in:
parent
0eddf7c80d
commit
da3c03206c
1 changed files with 6 additions and 7 deletions
|
@ -17,7 +17,6 @@ use std::fmt::{Debug, Error, Formatter};
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::iter::Peekable;
|
use std::iter::Peekable;
|
||||||
use std::pin::Pin;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
@ -241,12 +240,12 @@ pub struct TreeEntriesIterator<'matcher> {
|
||||||
struct TreeEntriesDirItem {
|
struct TreeEntriesDirItem {
|
||||||
entry_iterator: TreeEntriesNonRecursiveIterator<'static>,
|
entry_iterator: TreeEntriesNonRecursiveIterator<'static>,
|
||||||
// On drop, tree must outlive entry_iterator
|
// On drop, tree must outlive entry_iterator
|
||||||
tree: Pin<Box<Tree>>,
|
tree: Box<Tree>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TreeEntriesDirItem {
|
impl TreeEntriesDirItem {
|
||||||
fn new(tree: Tree) -> Self {
|
fn new(tree: Tree) -> Self {
|
||||||
let tree = Box::pin(tree);
|
let tree = Box::new(tree);
|
||||||
let entry_iterator = tree.entries_non_recursive();
|
let entry_iterator = tree.entries_non_recursive();
|
||||||
let entry_iterator: TreeEntriesNonRecursiveIterator<'static> =
|
let entry_iterator: TreeEntriesNonRecursiveIterator<'static> =
|
||||||
unsafe { std::mem::transmute(entry_iterator) };
|
unsafe { std::mem::transmute(entry_iterator) };
|
||||||
|
@ -410,8 +409,8 @@ struct TreeDiffDirItem {
|
||||||
// Iterator over the diffs between tree1 and tree2
|
// Iterator over the diffs between tree1 and tree2
|
||||||
entry_iterator: TreeEntryDiffIterator<'static>,
|
entry_iterator: TreeEntryDiffIterator<'static>,
|
||||||
// On drop, tree1 and tree2 must outlive entry_iterator
|
// On drop, tree1 and tree2 must outlive entry_iterator
|
||||||
tree1: Pin<Box<Tree>>,
|
tree1: Box<Tree>,
|
||||||
tree2: Pin<Box<Tree>>,
|
tree2: Box<Tree>,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum TreeDiffItem {
|
enum TreeDiffItem {
|
||||||
|
@ -434,8 +433,8 @@ impl<'matcher> TreeDiffIterator<'matcher> {
|
||||||
|
|
||||||
impl TreeDiffDirItem {
|
impl TreeDiffDirItem {
|
||||||
fn new(path: RepoPath, tree1: Tree, tree2: Tree) -> Self {
|
fn new(path: RepoPath, tree1: Tree, tree2: Tree) -> Self {
|
||||||
let tree1 = Box::pin(tree1);
|
let tree1 = Box::new(tree1);
|
||||||
let tree2 = Box::pin(tree2);
|
let tree2 = Box::new(tree2);
|
||||||
let iter: TreeEntryDiffIterator = diff_entries(&tree1, &tree2);
|
let iter: TreeEntryDiffIterator = diff_entries(&tree1, &tree2);
|
||||||
let iter: TreeEntryDiffIterator<'static> = unsafe { std::mem::transmute(iter) };
|
let iter: TreeEntryDiffIterator<'static> = unsafe { std::mem::transmute(iter) };
|
||||||
Self {
|
Self {
|
||||||
|
|
Loading…
Reference in a new issue