-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Reverse regression: unsized coercion from array to slice in Arc::from
started compiling in 1.74.0
#120541
Comments
@rustbot label +S-has-mcve |
Possibly related: |
Bisection points to #114041 cc @nvzqz @dtolnay searched nightlies: from nightly-2023-07-08 to nightly-2024-02-01 bisected with cargo-bisect-rustc v0.6.7Host triple: x86_64-unknown-linux-gnu cargo bisect-rustc --start 1.72.0 --script ./test.sh |
This is not a regression. |
Hi @dtolnay, feel free to remove tags that are incorrect, but please reopen the issue until a new regression test is added to verify this new functionality, as I clearly stated in the original issue in bold. |
There is non-obvious inference behavior here that I think makes this more interesting than just "this conversion was newly added in 1.74.0" Also, closing people's issues with 5-word explanations is just really discouraging for people who put in the work to report issues. |
@dtolnay I echo the sentiment that perhaps a bit more context would be helpful |
A new API was added to the standard library. The new API has tests, is documented, is noted in the 1.74.0 release announcement, and did not break existing code. The point of adding APIs in the standard library is that code can use them. If said API were to not exist, code could not use it. One can imagine that if code used some API, and that API did not exist, it makes sense the code would not compile. This is why, if you take code that uses an API, and you compile it with an old compiler in which the API does not exist, then you will observe that the code does not compile. Beyond that, I am not sure what we are talking about. |
This was all the context I needed. I would have felt much less discouraged if you had added that context. I didn't know that the impl was new, and so I thought there might be something weird going on with inference and unsizing.
I see it now; I'll be sure to read more closely next time.
Yes. Agreed on all that.
Well, there is the confusing fact that the takes_arc_slice(if true {
Arc::from([255])
} else {
Arc::from([])
}); How is that possible if the impl didn't exist? Before closing this issue, I seek to understand if/how inference is involved and understand if any additional regression test is warranted because of that. Otherwise I trust the doctests added with the new API. |
Good call. This new impl was linked in the previous comment above my misconceived one: #120541 (comment) I believe there is no inference change worth testing that is at play here. As I understand it, this issue was reported under the understanding that some inference change had been made (intentionally or unintentionally) in the compiler, and after looking at the release notes, that no inference change was described there. However, no inference change was described in the release notes because no inference change was made in the compiler in that release. The same inference applies to 1.73 and 1.74 and is extensively tested. In this code from let binding = if true {
Arc::from([255])
} else {
Arc::from([])
}; there is exactly one In 1.74+ there are now 2 possible functions this Inference in function arguments (and also takes_arc_slice(if true {
Arc::from([255])
} else {
Arc::from([])
});
The inference relevant to |
Awesome, that clarification is exactly what I needed. Thanks for taking the time to write it out. |
Code
The following code compiles successfully on 1.74.0 and stable (1.75.0) (playground):
It fails to compile on 1.73.0 with the following error:
Only the
with_binding
version fails, interestingly.This was reported in pola-rs/polars#14134. A user tried to compile the latest
polars
version on rustc 1.73.0 and got the above error.Repro of the failure on godbolt.
Despite
polars
not having a documented MSRV, I feel that this kind of change in what is allowed to compile is non-obvious and wouldn't make the average MSRV-minded Rust developer think twice if it compiled on stable. The 1.74.0 release notes don't mention anything about a change here.Request: at minimum, we should add a regression test to make sure this code continues to compile.
Version it worked on
The code failed to compile in 1.73.0.
Version with regression
The code started compiling in 1.74.0.
@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged +A-array +A-coercions +A-slice +A-inference +T-compiler
The text was updated successfully, but these errors were encountered: