diff --git a/src/librustc/middle/typeck/infer/coercion.rs b/src/librustc/middle/typeck/infer/coercion.rs index 5008dd8a0dbc57c609371e93415f71eee7f21112..d3931d277dd8f073906b0bd484f7651917b943b1 100644 --- a/src/librustc/middle/typeck/infer/coercion.rs +++ b/src/librustc/middle/typeck/infer/coercion.rs @@ -410,7 +410,7 @@ pub fn coerce_from_bare_fn_post_unpack(&self, debug!("coerce_from_bare_fn(a={}, b={})", a.inf_str(self.get_ref().infcx), b.inf_str(self.get_ref().infcx)); - if !fn_ty_a.abis.is_rust() { + if !fn_ty_a.abis.is_rust() || fn_ty_a.purity != ast::ImpureFn { return self.subtype(a, b); } diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index f8d805991511f9772100dec211660edb99898cd6..29e2e41d718efcd2f37325c3b82c3590a1010e29 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -392,13 +392,13 @@ fn filename_str<'a>(&'a self) -> Option<&'a str> { #[inline] fn filestem_str<'a>(&'a self) -> Option<&'a str> { // filestem() returns a byte vector that's guaranteed valid UTF-8 - self.filestem().map(cast::transmute) + self.filestem().map(|t| unsafe { cast::transmute(t) }) } #[inline] fn extension_str<'a>(&'a self) -> Option<&'a str> { // extension() returns a byte vector that's guaranteed valid UTF-8 - self.extension().map(cast::transmute) + self.extension().map(|t| unsafe { cast::transmute(t) }) } fn dir_path(&self) -> Path { diff --git a/src/test/compile-fail/coerce-unsafe-to-closure.rs b/src/test/compile-fail/coerce-unsafe-to-closure.rs new file mode 100644 index 0000000000000000000000000000000000000000..c22c4014f47bf7c5a009b34ad84d3717f498d123 --- /dev/null +++ b/src/test/compile-fail/coerce-unsafe-to-closure.rs @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let x: Option<&[u8]> = Some("foo").map(std::cast::transmute); + //~^ ERROR: mismatched types +}