Skip to content
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

Merged
merged 3 commits into from
Feb 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
17 changes: 0 additions & 17 deletions src/test/compile-fail/issue-5500.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
7 changes: 4 additions & 3 deletions src/test/run-pass/issue-15763.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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)
})
Expand Down
4 changes: 3 additions & 1 deletion src/test/run-pass/project-defer-unification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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
Expand Down