Skip to content

Conversation

petrochenkov
Copy link
Contributor

@petrochenkov petrochenkov commented Aug 26, 2016

  1. Types for equal loan paths are not always equal, they can sometimes differ in lifetimes, making equal loan paths hash differently.

Example:

pub fn insert_next(&mut self, element: T) {
match self.head {
None => self.list.push_back(element),
Some(head) => unsafe {
let prev = match (**head).prev {
None => return self.list.push_front(element),
Some(prev) => prev,
};
let node = Some(Shared::new(Box::into_raw(box Node {
next: Some(head),
prev: Some(prev),
element: element,
})));
(**prev).next = node;
(**head).prev = node;
self.list.len += 1;
}
}
}

One of self.lists has type

&ReFree(CodeExtent(15013/CallSiteScope { fn_id: 18907, body_id: 18912 }), BrNamed(0:DefIndex(3066), 'a(397), WontChange)) mut linked_list::LinkedList<T>

and other has type

&ReScope(CodeExtent(15018/Remainder(BlockRemainder { block: 18912, first_statement_index: 0 }))) mut linked_list::LinkedList<T>

(... but I'm not sure it's not a bug actually.)

  1. Not hashing types is faster than hashing types.

r? @arielb1

@petrochenkov
Copy link
Contributor Author

cc @nikomatsakis
This is also included into #36016, but I wanted to give this issue some more visibility.

@arielb1
Copy link
Contributor

arielb1 commented Aug 26, 2016

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 26, 2016

📌 Commit 14b4d72 has been approved by arielb1

Manishearth added a commit to Manishearth/rust that referenced this pull request Aug 27, 2016
rustc_borrowck: Don't hash types in loan paths

1) Types for equal loan paths are not always equal, they can sometimes differ in lifetimes, making equal loan paths hash differently.

Example:
https://github.com/rust-lang/rust/blob/71bdeea561355ba5adbc9a1f44f4f866a75a15c4/src/libcollections/linked_list.rs#L835-L856

One of `self.list`s has type
```
&ReFree(CodeExtent(15013/CallSiteScope { fn_id: 18907, body_id: 18912 }), BrNamed(0:DefIndex(3066), 'a(397), WontChange)) mut linked_list::LinkedList<T>
```
and other has type
```
&ReScope(CodeExtent(15018/Remainder(BlockRemainder { block: 18912, first_statement_index: 0 }))) mut linked_list::LinkedList<T>
```
(... but I'm not sure it's not a bug actually.)

2) Not hashing types is faster than hashing types.

r? @arielb1
bors added a commit that referenced this pull request Aug 27, 2016
Rollup of 7 pull requests

- Successful merges: #35124, #35877, #35953, #36002, #36004, #36005, #36014
- Failed merges:
@bors bors merged commit 14b4d72 into rust-lang:master Aug 27, 2016
@petrochenkov petrochenkov deleted the hashloan branch September 21, 2016 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants