Uh oh!
There was an error while loading. Please reload this page.
Make IntoIterator lifetime bounds of &BTreeMap match with &HashMap - #75203
Conversation
nbdd0121
commented
Aug 6, 2020
I don't quite understand the reason why |
canova
commented
Aug 6, 2020
Yeah, |
nbdd0121
commented
Aug 6, 2020
What I am suggesting is that this may be an issue with the compiler and we might want to fix that instead. |
canova
commented
Aug 6, 2020
Well, yes, we can investigate more if we think this is a bug, but I don't think so really. I'm looking all the use cases of |
dtolnay
commented
Aug 6, 2020
@bors r+ |
bors
commented
Aug 6, 2020
📌 Commit cedf96c has been approved by |
nbdd0121
commented
Aug 7, 2020
This is certainly a bug. If you look at the minimal example in the original issue: fnfoo<'a,K,V,I:'a + IntoIterator<Item = (&'aK,&'aV)>>(i:I){}fnbar(){let map = HashMap::<u32,u32>::new();foo(&map);let map = BTreeMap::<u32,u32>::new();foo(&map);}This code is rejected in Rust 2015 for both HashMap and BTreeMap, suggesting that |
…arth Rollup of 4 pull requests Successful merges: - rust-lang#74774 (adds [*mut|*const] ptr::set_ptr_value) - rust-lang#75079 (Disallow linking to items with a mismatched disambiguator) - rust-lang#75203 (Make `IntoIterator` lifetime bounds of `&BTreeMap` match with `&HashMap` ) - rust-lang#75227 (Fix ICE when using asm! on an unsupported architecture) Failed merges: r? @ghost
canova
commented
Aug 7, 2020
Hm, this minimal example also fails for |
This is a pretty small change on the lifetime bounds of
IntoIteratorimplementations of both&BTreeMapand&mut BTreeMap. This is loosening the lifetime bounds, so more code should be accepted with this PR. This is lifetime bounds will still be implicit since we havetype Item = (&'a K, &'a V);in the implementation. This change will make the HashMap and BTreeMap share the same signature, so we can share the same function/trait with both HashMap and BTreeMap in the code.Fixes#74034.
r? @dtolnay hey, I was touching this file on my previous PR and wanted to fix this on the way. Would you mind taking a look at this, or redirecting it if you are busy?