Inconsistency between &HashMap and &BTreeMap implementation of IntoIterator #74034
Labels
A-collections
Area: `std::collections`
A-lifetimes
Area: Lifetimes / regions
C-bug
Category: This is a bug.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
The implementation of
IntoIterator
for&'a BTreeMap<K, V>
and&'a HashMap<K, V, S>
differ in the lifetime bounds ofK
andV
I believe those additional bounds should be unnecessary since they're implied by the fact that exists a reference of lifetime
'a
to the whole map. However, quite interestingly, they appear to change how the compiler resolves trait bounds in some cases. For example in the following code:I would expect it to compile, or at least throw the same error for both the
BTreeMap
andHashMap
implementation.However it throws errors only for the
BTreeMap
implementation.Also note that error E0311 isn't even present in the Rust Compiler Error Index.
Playground link
The text was updated successfully, but these errors were encountered: