Skip to content

Commit dc0bb3f

Browse files
committed
Auto merge of #39485 - canndrew:inference-fix-39297, r=nikomatsakis
Ignore expected type in diverging blocks As per comment: #39297 (comment)
2 parents e879aa4 + 18be42c commit dc0bb3f

File tree

5 files changed

+11
-36
lines changed

5 files changed

+11
-36
lines changed

src/librustc_typeck/check/mod.rs

-11
Original file line numberDiff line numberDiff line change
@@ -4156,17 +4156,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
41564156
};
41574157

41584158
if self.diverges.get().always() {
4159-
if let ExpectHasType(ety) = expected {
4160-
// Avoid forcing a type (only `!` for now) in unreachable code.
4161-
// FIXME(aburka) do we need this special case? and should it be is_uninhabited?
4162-
if !ety.is_never() {
4163-
if let Some(ref e) = blk.expr {
4164-
// Coerce the tail expression to the right type.
4165-
self.demand_coerce(e, ty, ety);
4166-
}
4167-
}
4168-
}
4169-
41704159
ty = self.next_diverging_ty_var(TypeVariableOrigin::DivergingBlockExpr(blk.span));
41714160
} else if let ExpectHasType(ety) = expected {
41724161
if let Some(ref e) = blk.expr {

src/test/compile-fail/issue-5500.rs

-17
This file was deleted.

src/test/compile-fail/issue-10176.rs renamed to src/test/run-pass/inference-changes-39485.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
fn g() {
12+
&panic!()
13+
}
14+
1115
fn f() -> isize {
1216
(return 1, return 2)
13-
//~^ ERROR mismatched types
14-
//~| expected type `isize`
15-
//~| found type `(_, _)`
16-
//~| expected isize, found tuple
1717
}
1818

1919
fn main() {}

src/test/run-pass/issue-15763.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![allow(unknown_features)]
11+
#![allow(unused_features)]
12+
#![allow(unreachable_code)]
1213
#![feature(box_syntax)]
1314

1415
#[derive(PartialEq, Debug)]
@@ -28,14 +29,14 @@ struct Foo {
2829
}
2930

3031
fn foo() -> Result<Foo, isize> {
31-
return Ok(Foo {
32+
return Ok::<Foo, isize>(Foo {
3233
x: Bar { x: 22 },
3334
a: return Err(32)
3435
});
3536
}
3637

3738
fn baz() -> Result<Foo, isize> {
38-
Ok(Foo {
39+
Ok::<Foo, isize>(Foo {
3940
x: Bar { x: 22 },
4041
a: return Err(32)
4142
})

src/test/run-pass/project-defer-unification.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
// A regression test extracted from image-0.3.11. The point of
1212
// failure was in `index_colors` below.
1313

14+
#![allow(unused)]
15+
1416
use std::ops::{Deref, DerefMut};
1517

1618
#[derive(Copy, Clone)]
@@ -92,7 +94,7 @@ pub fn index_colors<Pix>(image: &ImageBuffer<Pix, Vec<u8>>)
9294
-> ImageBuffer<Luma<u8>, Vec<u8>>
9395
where Pix: Pixel<Subpixel=u8> + 'static,
9496
{
95-
let mut indices: ImageBuffer<_,Vec<_>> = loop { };
97+
let mut indices: ImageBuffer<Luma<u8>, Vec<u8>> = loop { };
9698
for (pixel, idx) in image.pixels().zip(indices.pixels_mut()) {
9799
// failured occurred here ^^ because we were requiring that we
98100
// could project Pixel or Subpixel from `T_indices` (type of

0 commit comments

Comments
 (0)