-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-inferenceArea: Type inferenceArea: Type inferenceC-bugCategory: This is a bug.Category: This is a bug.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.T-libs-apiRelevant to the library API 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.T-releaseRelevant to the release subteam, which will review and decide on the PR/issue.Relevant to the release subteam, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.
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
A-inferenceArea: Type inferenceArea: Type inferenceC-bugCategory: This is a bug.Category: This is a bug.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.T-libs-apiRelevant to the library API 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.T-releaseRelevant to the release subteam, which will review and decide on the PR/issue.Relevant to the release subteam, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.