-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Type checker does not eagerly select predicates from where-clauses #5514
Comments
Interesting, I didn't realize this exists. I think this needs to be solved in Chalk, since it works even if the where clause doesn't directly match the goal (e.g. if you have a trait |
Is there any progress on the issue? I don't want to push, I just would like to know. |
@flodiebold I browsed the code, trying to understand what is executed when a type for such case is inferred. I made the test: #[test]
fn infer_into() {
check_types(
r#"
fn call(v: impl Into<u32>) {
let n = v.into();
n;
} //^ u32
fn test() {
call(0u32);
}
"#,
);
} Of cause it fails. The thing is that it fails because the inferred type is In the beginning I thought that the type inference should be fixed in
|
Your test doesn't work because neither As to your question, no, this needs to be solved in Chalk, i.e. the issue you linked needs to be fixed. This is unrelated to |
Alright, thank you. I'll take a look at Chalk. Speaking of the test, you're right, the test works after removing the |
I'm also hitting into this (via #13761 / #17170) - there's a use of a borrow that isn't resolved in DataFusion, and then a destructuring that causes a later type error (because RA isn't inferring the real use of ref bindings when matching the borrow). It looks like quite a long-standing issue, both here and in Chalk upstream (rust-lang/chalk#584). I've seen some of the discussions about the next-gen trait solver in rustc, and a few different issues suggesting RA plans to take advantage of it when it's more stabilized. Would that be expected to solve this? Also, is there an RA issue/epic for the new trait solver somewhere? |
Yes
No not yet, we are still trying to figure out how to tackle adopting the new trait solver. |
The following code fails to infer the type of
x
, as well as the call to the inherent methodas_str
:rustc has no problem with this code, since the
.into()
call will eagerly use theT: Into<String>
bound from the where clause. This happens despite plenty of otherInto
impls existing in the wild and is an intentional Rust feature.The text was updated successfully, but these errors were encountered: