parent
19402f11e1
commit
a6b1a81750
|
@ -75,7 +75,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
|
|||
TerminatorKind::Return |
|
||||
TerminatorKind::Unreachable |
|
||||
TerminatorKind::FalseEdges { .. } => {
|
||||
// safe (at least as emitted during MIR construction)
|
||||
// safe (at least as emitted during MIR construction)
|
||||
}
|
||||
|
||||
TerminatorKind::Call { ref func, .. } => {
|
||||
|
@ -117,12 +117,17 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
|
|||
rvalue: &Rvalue<'tcx>,
|
||||
location: Location)
|
||||
{
|
||||
if let &Rvalue::Aggregate(
|
||||
box AggregateKind::Closure(def_id, _),
|
||||
_
|
||||
) = rvalue {
|
||||
let unsafety_violations = self.tcx.unsafety_violations(def_id);
|
||||
self.register_violations(&unsafety_violations);
|
||||
if let &Rvalue::Aggregate(box ref aggregate, _) = rvalue {
|
||||
match aggregate {
|
||||
&AggregateKind::Array(..) |
|
||||
&AggregateKind::Tuple |
|
||||
&AggregateKind::Adt(..) => {}
|
||||
&AggregateKind::Closure(def_id, _) |
|
||||
&AggregateKind::Generator(def_id, _, _) => {
|
||||
let unsafety_violations = self.tcx.unsafety_violations(def_id);
|
||||
self.register_violations(&unsafety_violations);
|
||||
}
|
||||
}
|
||||
}
|
||||
self.super_rvalue(rvalue, location);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright 2017 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.
|
||||
|
||||
#![feature(generators)]
|
||||
|
||||
fn main() {
|
||||
let _ = || {
|
||||
*(1 as *mut u32) = 42;
|
||||
//~^ ERROR dereference of raw pointer requires unsafe
|
||||
yield;
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue