Out of the 20 root regressions reported, the following are duds:
statistical-0.1.1
: Duplicate ofsimple_stats
.volatile-register-0.1.1
: Spurious failurechipmunk-sys-0.0.4
: Spurious failure.shout-sys-0.1.1
: Spurious failure.scrutch-0.0.4
: Spurious failure.signify-0.3.0
: Spurious failure.google-civicinfo2-cli-0.3.6+20160823
: Spurious failure.
There is one Deref
-related failure which is fixed now in the implementation (using the suggested
Deref
impl from the RFC):
juniper-0.5.1
: Deref coercion&String -> &str
stops working
The new B
parameter and constraints on or_insert
caused one failure. This is fixed in the implementation now by moving the B
parameter to the Entry
types instead:
multimap-0.3.0
: The newB
parameter and constraints oninsert
This means that, if we were to land the RFC right now, we'd have 11 regressions left. All of them have one-line fixes and they break down into the following categories:
- rustc bugs:
- A local
HashMap
with reference key type can't have its type inferred anymore (see test case A). This is expected and mentioned in the RFC:cargo-0.13.0
phf_macros-0.7.17
rustlex_fsa-0.3.3
simple_stats-0.1.1
- Calls to
string_map.entry(some_str.into())
are now ambiguous, since both conversions&str -> &str
and&str -> String
are valid.hiirc-0.4.0
helianto-0.1.0-beta1
rustful-0.9.0
cargo-script-0.1.5
timmy-0.3.0
Fix: Type annotation on local map.
Error:
--> src/cargo/core/package_id_spec.rs:156:35
|
156 | let mut version_cnt = HashMap::new();
| ^^^^^^^^^^^^ cannot infer type for `_`
|
= note: type annotations or generic parameter binding required
Simplified test case:
use std::collections::HashMap;
fn test(state: &u32) -> Vec<u32> {
let mut groups = Vec::new();
let mut group_of_action /* : HashMap<&u32, _> */ = HashMap::new();
groups.push(*group_of_action.entry(state).or_insert(0));
groups
}
fn main() {}
Fix: Add type annotation to local map.
Error:
--> src/lib.rs:340:23
|
340 | let mut strings = HashMap::new();
| ^^^^^^^^^^^^ cannot infer type for `_`
|
Simplified test case:
use std::collections::HashMap;
fn test(state: &u32) -> Vec<u32> {
let mut groups = Vec::new();
let mut group_of_action /* : HashMap<&u32, _> */ = HashMap::new();
groups.push(*group_of_action.entry(state).or_insert(0));
groups
}
fn main() {}
This is a problem with my implementation. We need to sort this out either by
adding the IntoOwned
trait, or by somehow making the constraints 'global' for
the Entry
. Or by giving VacantEntry
a function to produce a key.
Error:
error[E0277]: the trait bound `K: std::cmp::Eq` is not satisfied
--> src/entry.rs:86:25
|
86 | &mut self.inner.insert(vec![value])[0]
| ^^^^^^ trait `K: std::cmp::Eq` not satisfied
|
= help: consider adding a `where K: std::cmp::Eq` bound
error[E0277]: the trait bound `K: std::hash::Hash` is not satisfied
--> src/entry.rs:92:20
|
92 | self.inner.insert(values)
| ^^^^^^ trait `K: std::hash::Hash` not satisfied
|
= help: consider adding a `where K: std::hash::Hash` bound
error[E0277]: the trait bound `K: std::cmp::Eq` is not satisfied
--> src/entry.rs:92:20
|
92 | self.inner.insert(values)
| ^^^^^^ trait `K: std::cmp::Eq` not satisfied
|
= help: consider adding a `where K: std::cmp::Eq` bound
Simplified test case:
use std::collections::HashMap;
use std::collections::hash_map::VacantEntry;
fn insert<'a, K: 'a, V: 'a>(entry: VacantEntry<'a, K, V>, value: V) {
entry.insert(value);
}
fn main() {}
Fix: Add type annotation to local map.
Error:
--> dfa.rs:115:35
|
115 | let mut group_of_action = HashMap::new();
| ^^^^^^^^^^^^ cannot infer type for `_`
|
= note: type annotations or generic parameter binding required
Simplified test case:
use std::collections::HashMap;
fn test(state: &u32) -> Vec<u32> {
let mut groups = Vec::new();
let mut group_of_action /* : HashMap<&u32, _> */ = HashMap::new();
groups.push(*group_of_action.entry(state).or_insert(0));
groups
}
fn main() {}
Fix: Change .into()
to to_string()
/to_owned()
.
Error:
--> src/core.rs:332:39
|
332 | self.channels.lock().unwrap().entry(id.into()).or_insert(Arc::new(Channel::new(name)));
| ^^^^^ cannot infer type for `_`
|
= note: type annotations or generic parameter binding required
Simplified test case:
use std::collections::hashmap;
fn test() {
let mut deps: hashmap<string, string> = hashmap::new();
let name = "";
match deps.entry(name.into()) {
_ => {}
}
}
fn main() {}
Fix: Change .into()
to to_string()
/to_owned()
.
Error:
--> src/generators/index.rs:42:44
|
42 | Some(string) => string.into(),
| ^^^^ trait `(): std::convert::From<&str>` not satisfied
|
= note: required because of the requirements on the impl of `std::convert::Into<()>` for `&str`
error[E0277]: the trait bound `(): std::borrow::AsBorrowOf` is not satisfied
--> src/generators/index.rs:46:41
|
46 | let documents = indexes.entry(index_url).or_insert_with(Vec::new);
| ^^^^^ trait `(): std::borrow::AsBorrowOf` not satisfied
error[E0277]: the trait bound `(): std::borrow::AsBorrowOf` is not satisfied
--> src/generators/index.rs:46:58
|
46 | let documents = indexes.entry(index_url).or_insert_with(Vec::new);
| ^^^^^^^^^^^^^^ trait `(): std::borrow::AsBorrowOf` not satisfied
Simplified test case:
use std::collections::hashmap;
fn test() {
let mut deps: hashmap<string, string> = hashmap::new();
let name = "";
match deps.entry(name.into()) {
_ => {}
}
}
fn main() {}
Fix: use specialisation version in the RFC or change to key[..]
.
Error:
error[E0271]: type mismatch resolving `::Owned == &'a str`
--> src/validation/rules/unique_variable_names.rs:23:26
|
23 | match self.names.entry(&var_name.item) {
| ^^^^^ expected struct `std::string::String`, found reference
|
= note: expected type `std::string::String`
= note: found type `&'a str`
error[E0277]: the trait bound `&str: std::borrow::Borrow` is not satisfied
--> src/validation/rules/unique_variable_names.rs:30:19
|
30 | e.insert(var_name.start.clone());
| ^^^^^^ trait `&str: std::borrow::Borrow` not satisfied
error[E0271]: type mismatch resolving `::Owned == &str`
--> src/validation/rules/unique_variable_names.rs:30:19
|
30 | e.insert(var_name.start.clone());
| ^^^^^^ expected struct `std::string::String`, found &str
|
= note: expected type `std::string::String`
= note: found type `&str`
Simplified test case:
use std::collections::HashMap;
fn test<'a>(key: &'a String) {
let mut map: HashMap<&'a str, u32> = HashMap::new();
map.entry(key);
}
fn main() {}
difflib-0.1.0: rustc issue #37164
Fix:
- Fix rustc issue
- This fails due to an interaction between auto-deref and inference (it would
have failed today if it used
get
instead ofentry
). The solution is to deref element in the call:if (self.is_junk.unwrap())(*element)
.
Error:
--> src/sequencematcher.rs:149:55
|
149 | for (element, indexes) in second_sequence_elements.iter() {
| ^^^^
|
= note: the method `iter` exists but the following trait bounds were not satisfied: `str : std::marker::Sized`
error: no method named `remove` found for type `std::collections::HashMap>` in the current scope
--> src/sequencematcher.rs:155:30
|
155 | second_sequence_elements.remove(element);
| ^^^^^^
|
= note: the method `remove` exists but the following trait bounds were not satisfied: `str : std::marker::Sized`
error[E0308]: mismatched types
--> src/sequencematcher.rs:158:35
|
158 | self.second_sequence_elements = second_sequence_elements;
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found str
|
= note: expected type `std::collections::HashMap<&'a str, std::vec::Vec>`
= note: found type `std::collections::HashMap>`
Simplified test case:
use std::collections::HashMap;
fn is_junk(_: &str) -> bool { false }
fn chain_second_seq<'a>(x: &'a str) -> HashMap<&'a str, Vec<usize>> {
let mut second_sequence_elements = HashMap::new();
second_sequence_elements.entry(x);
if is_junk(second_sequence_elements.keys().next().unwrap()) {}
second_sequence_elements
}
fn main() {}
earth-0.0.2: rustc issue #37138
Fix:
- Fix rustc issue.
- Add the redundant constraint to workaround the bug
K: Borrow<K>
, in this case the mouthful:<<T as Entity>::Id as ToOwned>::Owned: Borrow<<<T as Entity>::Id as ToOwned>::Owned>
.
Error:
error[E0277]: the trait bound `::Id: std::cmp::Eq` is not satisfied
--> src/schema.rs:94:31
|
94 | match identifiers.entry(eid) {
| ^^^^^ trait `::Id: std::cmp::Eq` not satisfied
|
= help: consider adding a `where ::Id: std::cmp::Eq` bound
error[E0277]: the trait bound `::Id: std::marker::Sized` is not satisfied
--> src/schema.rs:94:31
|
94 | match identifiers.entry(eid) {
| ^^^^^ trait `::Id: std::marker::Sized` not satisfied
|
= help: consider adding a `where ::Id: std::marker::Sized` bound
error[E0277]: the trait bound `<::Id as std::borrow::ToOwned>::Owned: std::borrow::AsBorrowOf<<::Id as std::borrow::ToOwned>::Owned, ::Id>` is not satisfied
--> src/schema.rs:94:31
|
94 | match identifiers.entry(eid) {
| ^^^^^ trait `<::Id as std::borrow::ToOwned>::Owned: std::borrow::AsBorrowOf<<::Id as std::borrow::ToOwned>::Owned, ::Id>` not satisfied
|
= help: consider adding a `where <::Id as std::borrow::ToOwned>::Owned: std::borrow::AsBorrowOf<<::Id as std::borrow::ToOwned>::Owned, ::Id>` bound
error: aborting due to 4 previous errors
Simplified test case:
use std::collections::HashMap;
use std::hash::Hash;
use std::borrow::Cow;
// Remove the commented out constraint to fix (NB that T: Borrow<T>).
fn merge<T: ToOwned + ?Sized>(entity_id: Cow<T>)
where T::Owned: Hash + Eq /* + ::std::borrow::Borrow<T::Owned> */ {
let mut identifiers: HashMap<T::Owned, u32> = HashMap::new();
let eid = entity_id.into_owned();
match identifiers.entry(eid) {
_ => {}
}
}
fn main() {}
Fix: use From
instead of into
: MaybeUtf8Owned::from(key.to_owned())
.
Error:
--> src/router/tree_router.rs:72:38
|
72 | match self.static_routes.entry(key.to_owned().into()) {
| ^^^^^ cannot infer type for `_`
|
= note: type annotations or generic parameter binding required
Simplified test case:
use std::collections::HashMap;
use std::borrow::Cow;
fn find_or_insert_router<'a>(static_routes: HashMap<Cow<[u8]>, u32>, key: &[u8]) {
match static_routes.entry(key.to_owned().into()) {
_ => {},
}
}
fn main() {}
Fix: Add type annotation to local map.
Error:
error: the type of this value must be known in this context
--> src/univariate_.rs:73:33
|
73 | mode = Some(**val);
| ^^^^^
Simplified test case:
use std::collections::HashMap;
pub fn mode(v: &[u32]) -> Option<u32> {
let mut counter = HashMap::new();
let mut mode = None;
for x in v.iter() {
*counter.entry(x).or_insert(0) += 1;
}
for (val, _) in &counter {
mode = Some(**val);
}
mode
}
fn main() {}
Error:
--> src/main.rs:376:24
|
376 | match deps.entry(name.into()) {
| ^^^^^ cannot infer type for `_`
|
= note: type annotations or generic parameter binding required
Simplified test case:
use std::collections::HashMap;
fn test() {
let mut deps: HashMap<String, String> = HashMap::new();
let name = "";
match deps.entry(name.into()) {
_ => {}
}
}
fn main() {}
Error:
error[E0282]: unable to infer enough type information about `_`
--> src/main.rs:177:13
|
177 | let mut current_program = get_current_program().trim().into();
| ^^^^^^^^^^^^^^^^^^^ cannot infer type for `_`
|
= note: type annotations or generic parameter binding required
Simplified test case:
use std::collections::HashMap;
fn test() -> HashMap<String, i64> {
let mut map = HashMap::new();
let key = "".into();
map.entry(key);
map
}
fn main() {}