Skip to content

Commit 2bba901

Browse files
committed
Revert "Auto merge of rust-lang#39485 - canndrew:inference-fix-39297, r=nikomatsakis"
This reverts commit dc0bb3f, reversing changes made to e879aa4. This is a temporary step intended to fix regressions. A more comprehensive fix for type inference and dead-code is in the works.
1 parent 646873b commit 2bba901

File tree

5 files changed

+36
-11
lines changed

5 files changed

+36
-11
lines changed

src/librustc_typeck/check/mod.rs

+11
Original file line numberDiff line numberDiff line change
@@ -4041,6 +4041,17 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
40414041
};
40424042

40434043
if self.diverges.get().always() {
4044+
if let ExpectHasType(ety) = expected {
4045+
// Avoid forcing a type (only `!` for now) in unreachable code.
4046+
// FIXME(aburka) do we need this special case? and should it be is_uninhabited?
4047+
if !ety.is_never() {
4048+
if let Some(ref e) = blk.expr {
4049+
// Coerce the tail expression to the right type.
4050+
self.demand_coerce(e, ty, ety);
4051+
}
4052+
}
4053+
}
4054+
40444055
ty = self.next_diverging_ty_var(TypeVariableOrigin::DivergingBlockExpr(blk.span));
40454056
} else if let ExpectHasType(ety) = expected {
40464057
if let Some(ref e) = blk.expr {

src/test/run-pass/inference-changes-39485.rs src/test/compile-fail/issue-10176.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-
1511
fn f() -> isize {
1612
(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/compile-fail/issue-5500.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
&panic!()
13+
//~^ ERROR mismatched types
14+
//~| expected type `()`
15+
//~| found type `&_`
16+
//~| expected (), found reference
17+
}

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

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

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

1514
#[derive(PartialEq, Debug)]
@@ -29,14 +28,14 @@ struct Foo {
2928
}
3029

3130
fn foo() -> Result<Foo, isize> {
32-
return Ok::<Foo, isize>(Foo {
31+
return Ok(Foo {
3332
x: Bar { x: 22 },
3433
a: return Err(32)
3534
});
3635
}
3736

3837
fn baz() -> Result<Foo, isize> {
39-
Ok::<Foo, isize>(Foo {
38+
Ok(Foo {
4039
x: Bar { x: 22 },
4140
a: return Err(32)
4241
})

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
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-
1614
use std::ops::{Deref, DerefMut};
1715

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

0 commit comments

Comments
 (0)