diff options
| author | bors <bors@rust-lang.org> | 2017-02-17 10:46:59 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-02-17 10:46:59 +0000 |
| commit | dc0bb3f2839c13ab42feacd423f728fbfd2f2f7a (patch) | |
| tree | ebfa66a9d4fc5336a9bba7bed3eff676ad853c34 /src | |
| parent | e879aa43ef63962f8e4d797292194a9f40a22a13 (diff) | |
| parent | 18be42c5d7cf0e445befee2ca8aba092808b7e35 (diff) | |
| download | rust-dc0bb3f2839c13ab42feacd423f728fbfd2f2f7a.tar.gz rust-dc0bb3f2839c13ab42feacd423f728fbfd2f2f7a.zip | |
Auto merge of #39485 - canndrew:inference-fix-39297, r=nikomatsakis
Ignore expected type in diverging blocks As per comment: https://github.com/rust-lang/rust/issues/39297#issuecomment-276810343
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_typeck/check/mod.rs | 11 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-5500.rs | 17 | ||||
| -rw-r--r-- | src/test/run-pass/inference-changes-39485.rs (renamed from src/test/compile-fail/issue-10176.rs) | 8 | ||||
| -rw-r--r-- | src/test/run-pass/issue-15763.rs | 7 | ||||
| -rw-r--r-- | src/test/run-pass/project-defer-unification.rs | 4 |
5 files changed, 11 insertions, 36 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 4b36e682f1e..9d963226caf 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4156,17 +4156,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { }; if self.diverges.get().always() { - if let ExpectHasType(ety) = expected { - // Avoid forcing a type (only `!` for now) in unreachable code. - // FIXME(aburka) do we need this special case? and should it be is_uninhabited? - if !ety.is_never() { - if let Some(ref e) = blk.expr { - // Coerce the tail expression to the right type. - self.demand_coerce(e, ty, ety); - } - } - } - ty = self.next_diverging_ty_var(TypeVariableOrigin::DivergingBlockExpr(blk.span)); } else if let ExpectHasType(ety) = expected { if let Some(ref e) = blk.expr { diff --git a/src/test/compile-fail/issue-5500.rs b/src/test/compile-fail/issue-5500.rs deleted file mode 100644 index 1cbb7588e17..00000000000 --- a/src/test/compile-fail/issue-5500.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - &panic!() - //~^ ERROR mismatched types - //~| expected type `()` - //~| found type `&_` - //~| expected (), found reference -} diff --git a/src/test/compile-fail/issue-10176.rs b/src/test/run-pass/inference-changes-39485.rs index 434b795ff31..193c66b2a2a 100644 --- a/src/test/compile-fail/issue-10176.rs +++ b/src/test/run-pass/inference-changes-39485.rs @@ -8,12 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +fn g() { + &panic!() +} + fn f() -> isize { (return 1, return 2) -//~^ ERROR mismatched types -//~| expected type `isize` -//~| found type `(_, _)` -//~| expected isize, found tuple } fn main() {} diff --git a/src/test/run-pass/issue-15763.rs b/src/test/run-pass/issue-15763.rs index 0baaaac2676..f77888c2955 100644 --- a/src/test/run-pass/issue-15763.rs +++ b/src/test/run-pass/issue-15763.rs @@ -8,7 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unknown_features)] +#![allow(unused_features)] +#![allow(unreachable_code)] #![feature(box_syntax)] #[derive(PartialEq, Debug)] @@ -28,14 +29,14 @@ struct Foo { } fn foo() -> Result<Foo, isize> { - return Ok(Foo { + return Ok::<Foo, isize>(Foo { x: Bar { x: 22 }, a: return Err(32) }); } fn baz() -> Result<Foo, isize> { - Ok(Foo { + Ok::<Foo, isize>(Foo { x: Bar { x: 22 }, a: return Err(32) }) diff --git a/src/test/run-pass/project-defer-unification.rs b/src/test/run-pass/project-defer-unification.rs index 9a6ea2272fe..8e008c639b3 100644 --- a/src/test/run-pass/project-defer-unification.rs +++ b/src/test/run-pass/project-defer-unification.rs @@ -11,6 +11,8 @@ // A regression test extracted from image-0.3.11. The point of // failure was in `index_colors` below. +#![allow(unused)] + use std::ops::{Deref, DerefMut}; #[derive(Copy, Clone)] @@ -92,7 +94,7 @@ 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 { }; + let mut indices: ImageBuffer<Luma<u8>, Vec<u8>> = 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 |
