-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I tried this code:
fn main() {
let map: HashMap<i32, i32, _> = HashMap::from_iter(vec![(1, 1), (2, 2)].into_iter());
}
I expected to see this happen:
when run cargo check
, it should says
--> src/main.rs:30:14
|
30 | let map: HashMap<i32, i32, _> = HashMap::from_iter(vec![(1, 1), (2, 2)].into_iter());
| --- ^^^^^^^^^^^^^^^^^^^^ cannot infer type
| |
| consider change `HashMap<i32, i32, _>` to `HashMap<i32, i32>` because it has a default type, or specify a detail type.
Instead, this happened:
--> src/main.rs:30:14
|
30 | let map: HashMap<i32, i32, _> = HashMap::from_iter(vec![(1, 1), (2, 2)].into_iter());
| --- ^^^^^^^^^^^^^^^^^^^^ cannot infer type
| |
| consider giving `map` the explicit type `std::collections::HashMap<i32, i32, _>`, with the type parameters specified
Meta
rustc --version --verbose
:
ustc 1.43.0-nightly (a1912f2e8 2020-02-12)
binary: rustc
commit-hash: a1912f2e89b77cfe2a0e64b96f444848fe4e2d49
commit-date: 2020-02-12
host: x86_64-unknown-linux-gnu
release: 1.43.0-nightly
LLVM version: 9.0
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.