-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityMedium priority
Milestone
Description
use std::collections::HashMap;
fn main(){
let mut map = HashMap::new();
map.insert("foo".to_string(), "bar".to_string());
// Oh hey I can use borrow to do lookup with a string literal!
println!("{}", map["foo"]);
}
// <anon>:5:20: 5:30 error: the trait `collections::borrow::Borrow<&str>`
// is not implemented for the type `collections::string::String` [E0277]
// <anon>:5 println!("{}", map["foo"]);
// ^~~~~~~~~~
:(
use std::collections::HashMap;
fn main(){
let mut map = HashMap::new();
map.insert("foo".to_string(), "bar".to_string());
// Ok, maybe I can deref to cancel out the autoref?
println!("{}", map[*"foo"]);
}
// error: internal compiler error: trying to take the
// sizing type of str, an unsized type
:((((((
These two conveniences are basically cancelling each-other out for the super-natural case of doing lookup with a string literal. Is there something that can be done about this?
Metadata
Metadata
Assignees
Labels
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityMedium priority