Closed
Description
I tried this code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=b628c24337168091d1c20e62ff6e31e8
#![feature(inline_const)]
use std::collections::HashMap;
fn main() {
let mut h = <HashMap<usize, Vec<i32>>>::new();
h.entry(123).or_insert(const { Vec::new() });
dbg!(h);
}
I expected to see this happen: It compiles, the same as the following (without the const{}
) does https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=2da5b1d9926024223ba6dff77a647f17
#![feature(inline_const)]
use std::collections::HashMap;
fn main() {
let mut h = <HashMap<usize, Vec<i32>>>::new();
h.entry(123).or_insert(Vec::new());
dbg!(h);
}
Instead, this happened: type inference fails
error[E0282]: type annotations needed
--> src/main.rs:5:36
|
5 | h.entry(123).or_insert(const { Vec::new() });
| ^^^^^^^^ cannot infer type for type parameter `T`
(Spotted after looking at https://internals.rust-lang.org/t/should-clippy-warn-about-function-calls-outside-closures-if-those-are-const-answered/15452/4?u=scottmcm)