-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP Switch x?
desugaring to use QuestionMark trait and Try enum
#38301
Conversation
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
Edit: Fixed error[E0282]: unable to infer enough type information about `_`
--> /checkout/src/librustc/hir/def_id.rs:124:21
|
124 | write!(f, " => {}", def_path.to_string(tcx))?;
| ---------------------------------------------
| |
| cannot infer type for `_`
| in this macro invocation
|
= note: type annotations or generic parameter binding required
error: aborting due to previous error
error: Could not compile `rustc`. source is: impl fmt::Debug for DefId {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "DefId {{ krate: {:?}, node: {:?}",
self.krate, self.index)?;
ty::tls::with_opt(|opt_tcx| {
if let Some(tcx) = opt_tcx {
if let Some(def_path) = tcx.opt_def_path(*self) {
write!(f, " => {}", def_path.to_string(tcx))?; // <--- LINE 124
}
}
Ok(())
})?;
write!(f, " }}")
}
} Note the second |
Do you have any idea why inference is failing there? It seems to me that between line 124 and 127 the full return type of the closure should be inferrable. |
Not sure. It must be the |
I'm sorry for all the noise it took to get this to compile and be type inference compatible. Now we have proven one of the popular shapes of the API from the discussion of the future of Carrier. (Now: onto harder problems like naming and optimization?) For completeness, I test ran this compiler against #37939 and there is (not surprisingly) no improvement. But: this PR's implementation could be what we have to optimize in the future for instead of the |
I opened a PR because I wanted this to compile on travis.