You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use core::hashmap::HashMap;fnmain(){letmut m = HashMap::new();match m.find_mut(&1){Some(a) => { a.push(2);}None => ()}
m.insert(3, ~[3]);}
You get the error
foo.rs:7:17: 7:18 error: the type of this value must be known in this context
foo.rs:7 Some(a) => { a.push(2); }
^
error: aborting due to previous error
If the m.insert line were farther up, the program compiles just fine. It seems like if the compiler were to look ahead a bit farther it could figure out the type of the hash map.
The text was updated successfully, but these errors were encountered:
Seems like a typechecker bug to me (it should gather all the constraints before reporting this error). Though @nikomatsakis can correct me if I'm wrong.
This is working as expected. We use a hybrid form of HM which sometimes requires type information to proceed. Certain operators (the . operator and the * operator, in particular, though perhaps a few others) are overloaded based on the type of the argument and simply cannot be typed otherwise. Sorry, you'll just have to add an annotation on m.
…e, r=flip1995
Ref style link false positive
This PR does not fixrust-lang#5834, but it records the problematic link text as a **known problem** inside `doc_markdown` lint.
r? `@flip1995`
- [ ] Followed [lint naming conventions][lint_naming]
- [ ] Added passing UI tests (including committed `.stderr` file)
- [x] `cargo test` passes locally
- [x] Executed `cargo dev update_lints`
- [ ] Added lint documentation
- [x] Run `cargo dev fmt`
---
*Please keep the line below*
changelog: Document problematic link text style as known problem for `doc_markdown`
For this program
You get the error
If the
m.insert
line were farther up, the program compiles just fine. It seems like if the compiler were to look ahead a bit farther it could figure out the type of the hash map.The text was updated successfully, but these errors were encountered: