-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Indexing Autoref + Borrow = :( #22826
Comments
CC @aturon |
The ICE is definitely a bug, which I may have introduced: 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?
let key = "foo";
println!("{}", map[*key]);
} |
Yeah, that was my work-around, but I think we can all agree that that's pretty awful. |
triage: I-nominated |
(Hm, triage bot seems to be busted.) |
Nominating: we need to at least get the |
1.0 beta for addressing the ICE. its not clear whether we have time for a breaking-change to try to fix the trait. (and its also not clear whether a breaking-change is the only option for fixing the trait; e.g. there may be some method via deref-coercion or other magic.) |
Update: @nikomatsakis is looking into changing the traits to work by-value, as the RFC originally intended. |
Now that index operators take arguments by value I believe this bug is actually fixed. Yay! use std::collections::HashMap;
fn main() {
let mut m = HashMap::new();
m.insert("a".to_string(), 2);
println!("{}", m["a"]);
} |
Does the ICE have a separate issue? |
If you do |
:(
:((((((
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?
The text was updated successfully, but these errors were encountered: