Closed
Description
Code
I tried this code in nightly:
pub fn parse(bytes: &[u8]) -> String {
std::ffi::CStr::from_bytes_until_nul(bytes)
.unwrap()
.to_str()
.unwrap()
.split('\n')
.map(str::trim_end)
.collect::<Box<_>>()
.join("\n")
}
I expected to see this happen: it compiles successfully
Instead, this happened:
error[E0282]: type annotations needed
--> src/lib.rs:8:10
|
8 | .collect::<Box<_>>()
| ^^^^^^^ cannot infer type of the type parameter `B` declared on the method `collect`
9 | .join("\n")
| ---- type must be known at this point
|
help: consider specifying the generic argument
|
8 | .collect::<Vec<_>>()
| ~~~~~~~~~~
For more information about this error, try `rustc --explain E0282`.
error: could not compile `playground` (lib) due to 1 previous error
Version it worked on
It most recently worked on: Rust 1.79.0
Version with regression
nightly-2024-06-19
Metadata
Metadata
Assignees
Labels
Area: Type inferenceCategory: This is a bug.Relevant to the compiler team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.Relevant to the release subteam, which will review and decide on the PR/issue.Performance or correctness regression from stable to beta.