};
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 {
--- /dev/null
+// Copyright 2014 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 f() -> isize {
+ (return 1, return 2)
+//~^ ERROR mismatched types
+//~| expected type `isize`
+//~| found type `(_, _)`
+//~| expected isize, found tuple
+}
+
+fn main() {}
--- /dev/null
+// 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
+}
+++ /dev/null
-// Copyright 2014 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 g() {
- &panic!()
-}
-
-fn f() -> isize {
- (return 1, return 2)
-}
-
-fn main() {}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![allow(unused_features)]
-#![allow(unreachable_code)]
+#![allow(unknown_features)]
#![feature(box_syntax)]
#[derive(PartialEq, Debug)]
}
fn foo() -> Result<Foo, isize> {
- return Ok::<Foo, isize>(Foo {
+ return Ok(Foo {
x: Bar { x: 22 },
a: return Err(32)
});
}
fn baz() -> Result<Foo, isize> {
- Ok::<Foo, isize>(Foo {
+ Ok(Foo {
x: Bar { x: 22 },
a: return Err(32)
})
// 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)]
-> ImageBuffer<Luma<u8>, Vec<u8>>
where Pix: Pixel<Subpixel=u8> + 'static,
{
- let mut indices: ImageBuffer<Luma<u8>, Vec<u8>> = loop { };
+ 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