-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Ignore expected type in diverging blocks #39485
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
Also, please use a more descriptive title (e.g. "Allow diverging blocks to have a type different than that of their trailing expression." but that's maybe too long). |
@canndrew instead of removing the affected tests, can you move at least one of them into a |
cc @eddyb |
Oh, I see he already commented =) |
It occurs to me that we perhaps ought to crater this too. That is, I guess that this can lead to types becoming constrained that were not otherwise (as we saw in #39009). |
Is there a way to skip debuginfo tests when testing rustc? They always fail for me and it throws me off because sometimes I think the other tests have succeeded when I've gotten that far. As for the failing run-pass tests. This now fails (unable to infer enough type information for fn foo() -> Result<Foo, isize> {
return Ok(Foo {
x: Bar { x: 22 },
a: return Err(32)
});
} Which is unfortunate. Shouldn't inference be able to infer that the Also, this now fails (unable to infer enough type information for pub fn index_colors<Pix>(image: &ImageBuffer<Pix, Vec<u8>>)
-> ImageBuffer<Luma<u8>, Vec<u8>>
where Pix: Pixel<Subpixel=u8> + 'static,
{
let mut indices: ImageBuffer<_,Vec<_>> = loop { };
for (pixel, idx) in image.pixels().zip(indices.pixels_mut()) {
// failured occurred here ^^ because we were requiring that we
// could project Pixel or Subpixel from `T_indices` (type of
// `indices`), but the type is insufficiently constrained
// until we reach the return below.
}
indices
} Which makes sense, but is also unfortunate. (Because the function body is diverging, the type of |
Well, the whole change here is basically that it doesn't have to. (Since it is dead-code.) cc @eddyb -- it makes sense that this would be causing some back-compat issues, but it's a drag. Definitely have to do a crater run I guess. |
Started a crater run. |
Root regressions
|
So, according to that crater run there's 4 directly-broken packages: libimagestore and tera have already been fixed upstream, they just need to publish new versions or get people using those new versions. lion has been yanked from crates.io and twig can be fixed easily enough. Of course if we did default to What's everyone's take on all this?
Sure, I was just surprised that it didn't still force that particular bit of unification to happen. |
d35e5b1
to
18be42c
Compare
I've fixed the two failing tests. |
@canndrew ok, well, seems like we might as well go through with this. I feel like the current behavior is pretty inconsistent.
I'm not sure I understand what you mean here by "default to |
Sounds good to me.
I just meant set the type variable which can't be inferred to |
@canndrew I see. Well, I'm not a big fan of that idea, for a couple of reasons. For one thing, it would re-create the problem we are trying to fix here. Consider e.g. something like this: let mut v = vec![];
if condition {
return;
v.push(vec![]); // this type variable is created in dead code
} Now the type of In general, the rule of "dead code halts information flow up the tree (i.e., from expression to where expression is used)" but not "side-to-side" seems pretty good to me. Among other things, since the code is dead, there is (indeed) no data or information flow up the tree, and we can't know if you intended to add conversion and so forth. |
cc @Nercury -- twig-rs may be affected by this change. The testing of the PR got this error:
This PR affects information flow around dead-code. The problem seems to be that the type of this variable |
I'm marking this for relnotes, since it does affect code. The relnotes could read: "Fixed bugs around how type inference interacts with dead-code. The existing code generally ignores the type of dead-code unless a type-hint is provided; this can cause surprising inference interactions particularly around defaulting. The new code uniformly ignores the result type of dead-code." |
@bors r+ |
📌 Commit 18be42c has been approved by |
⌛ Testing commit 18be42c with merge 8725c90... |
💔 Test failed - status-appveyor |
@bors: retry
* appveyor timeout
…On Thu, Feb 16, 2017 at 1:47 PM, bors ***@***.***> wrote:
💔 Test failed - status-appveyor
<https://ci.appveyor.com/project/rust-lang/rust/build/1.0.1981>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#39485 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAD95OQ-avTCsRkLda_veYnN4AtQf28Aks5rdKftgaJpZM4L2UC7>
.
|
⌛ Testing commit 18be42c with merge 82756e4... |
💔 Test failed - status-travis |
@bors: retry
* network failure
…On Thu, Feb 16, 2017 at 9:26 PM, bors ***@***.***> wrote:
💔 Test failed - status-travis
<https://travis-ci.org/rust-lang/rust/builds/202486669>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#39485 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAD95C-9golHpDkFDDG6f4ZHN6ed11vWks5rdRNQgaJpZM4L2UC7>
.
|
@nikomatsakis twig was my early Rust project that is not finished and is paused now, so the breakage won't cause any issues |
Ignore expected type in diverging blocks As per comment: #39297 (comment)
☀️ Test successful - status-appveyor, status-travis |
There was some concerns about what is expected breakage and what is not in #39984 but I suspect they are more likely to be answered here. There is this code that returns an So, is it expected breakage that the dead branch of code is 1) required to have fully known types but 2) is not type-inferred, unlike live branches, so these dead branches must have additional type annotations, which they wouldn't need if they were live branches? |
Revert rust-lang#39485, fixing type-inference regressions This reverts PR rust-lang#39485, which should fix the immediate regressions. Eventually I'd like to land rust-lang#40224 -- or some variant of it -- which revisits the question fo dead-code and inference. r? @eddyb cc @canndrew
Revert rust-lang#39485, fixing type-inference regressions This reverts PR rust-lang#39485, which should fix the immediate regressions. Eventually I'd like to land rust-lang#40224 -- or some variant of it -- which revisits the question fo dead-code and inference. r? @eddyb cc @canndrew
As per comment: #39297 (comment)