about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-10-02 03:28:57 +0000
committerbors <bors@rust-lang.org>2015-10-02 03:28:57 +0000
commit0ffc6829751a551c7a34bad4c0be66055f552abb (patch)
tree874447e75646d01f12c0b26ad785e4db9d296ac3
parent48a5004ead9782ba95871238cd8e3e3f389cf07e (diff)
parent0706ac0faeff6c01b8a2505736534038978164c0 (diff)
downloadrust-0ffc6829751a551c7a34bad4c0be66055f552abb.tar.gz
rust-0ffc6829751a551c7a34bad4c0be66055f552abb.zip
Auto merge of #28790 - arielb1:unsafe-coerce, r=eddyb
Fixes #28776

r? @eddyb 
-rw-r--r--src/librustc/lib.rs2
-rw-r--r--src/librustc/middle/effect.rs4
-rw-r--r--src/test/compile-fail/issue-28776.rs15
3 files changed, 18 insertions, 3 deletions
diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs
index cfeab976e24..0bbb57afc27 100644
--- a/src/librustc/lib.rs
+++ b/src/librustc/lib.rs
@@ -105,6 +105,7 @@ pub mod front {
 }
 
 pub mod middle {
+    pub mod expr_use_visitor; // STAGE0: increase glitch immunity
     pub mod astconv_util;
     pub mod astencode;
     pub mod cfg;
@@ -122,7 +123,6 @@ pub mod middle {
     pub mod dependency_format;
     pub mod effect;
     pub mod entry;
-    pub mod expr_use_visitor;
     pub mod free_region;
     pub mod intrinsicck;
     pub mod infer;
diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs
index d1e1434dad8..8a206e3d88e 100644
--- a/src/librustc/middle/effect.rs
+++ b/src/librustc/middle/effect.rs
@@ -151,7 +151,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
                 }
             }
             hir::ExprCall(ref base, _) => {
-                let base_type = self.tcx.node_id_to_type(base.id);
+                let base_type = self.tcx.expr_ty_adjusted(base);
                 debug!("effect: call case, base type is {:?}",
                         base_type);
                 if type_is_unsafe_function(base_type) {
@@ -159,7 +159,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
                 }
             }
             hir::ExprUnary(hir::UnDeref, ref base) => {
-                let base_type = self.tcx.node_id_to_type(base.id);
+                let base_type = self.tcx.expr_ty_adjusted(base);
                 debug!("effect: unary case, base type is {:?}",
                         base_type);
                 if let ty::TyRawPtr(_) = base_type.sty {
diff --git a/src/test/compile-fail/issue-28776.rs b/src/test/compile-fail/issue-28776.rs
new file mode 100644
index 00000000000..ce06c8bf220
--- /dev/null
+++ b/src/test/compile-fail/issue-28776.rs
@@ -0,0 +1,15 @@
+// Copyright 2015 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.
+
+use std::ptr;
+
+fn main() {
+    (&ptr::write)(1 as *mut _, 42); //~ ERROR E0133
+}