diff options
| author | bors <bors@rust-lang.org> | 2014-01-18 01:06:47 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-01-18 01:06:47 -0800 |
| commit | 88dd987df0c1fdc64078c570e1712f1cc2e0d4ac (patch) | |
| tree | c0b250f47eeca33b2a1c5cdc09a7611505ba5cbd | |
| parent | 1da2962e2ee6e0ccbe19116f4baea47f7aff0956 (diff) | |
| parent | afa392a8407bd7e514f023bca467f35e62339ea8 (diff) | |
| download | rust-88dd987df0c1fdc64078c570e1712f1cc2e0d4ac.tar.gz rust-88dd987df0c1fdc64078c570e1712f1cc2e0d4ac.zip | |
auto merge of #11605 : alexcrichton/rust/issue-9582, r=brson
Closes #9582
| -rw-r--r-- | src/librustc/middle/typeck/infer/coercion.rs | 2 | ||||
| -rw-r--r-- | src/libstd/path/windows.rs | 4 | ||||
| -rw-r--r-- | src/test/compile-fail/coerce-unsafe-to-closure.rs | 14 |
3 files changed, 17 insertions, 3 deletions
diff --git a/src/librustc/middle/typeck/infer/coercion.rs b/src/librustc/middle/typeck/infer/coercion.rs index 5008dd8a0db..d3931d277dd 100644 --- a/src/librustc/middle/typeck/infer/coercion.rs +++ b/src/librustc/middle/typeck/infer/coercion.rs @@ -410,7 +410,7 @@ impl Coerce { 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 9b0169bf22d..a529aaf0a24 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -392,13 +392,13 @@ impl GenericPath for Path { #[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 00000000000..c22c4014f47 --- /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 <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() { + let x: Option<&[u8]> = Some("foo").map(std::cast::transmute); + //~^ ERROR: mismatched types +} |
