Skip to content

Commit

Permalink
auto merge of #11605 : alexcrichton/rust/issue-9582, r=brson
Browse files Browse the repository at this point in the history
Closes #9582
  • Loading branch information
bors committed Jan 18, 2014
2 parents 1da2962 + afa392a commit 88dd987
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/librustc/middle/typeck/infer/coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions src/libstd/path/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions src/test/compile-fail/coerce-unsafe-to-closure.rs
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 88dd987

Please sign in to comment.