@@ -1528,7 +1528,7 @@ fn require_unsafe(sess: session::session, f_purity: ast::purity, sp: span) {
1528
1528
alt f_purity {
1529
1529
ast : : unsafe_fn. { ret; }
1530
1530
_ {
1531
- sess. span_fatal (
1531
+ sess. span_err (
1532
1532
sp,
1533
1533
"unsafe operation requires unsafe function or block" ) ;
1534
1534
}
@@ -1541,7 +1541,7 @@ fn require_impure(sess: session::session, f_purity: ast::purity, sp: span) {
1541
1541
ast : : unsafe_fn. { ret; }
1542
1542
ast:: impure_fn. { ret; }
1543
1543
ast:: pure_fn. {
1544
- sess . span_fatal ( sp, "Found impure expression in pure function decl" ) ;
1544
+ sess . span_err ( sp, "Found impure expression in pure function decl" ) ;
1545
1545
}
1546
1546
}
1547
1547
}
@@ -1556,7 +1556,7 @@ fn require_pure_call(ccx: @crate_ctxt, caller_purity: ast::purity,
1556
1556
some ( ast:: def_fn ( _, ast:: unsafe_fn. ) ) |
1557
1557
some ( ast:: def_native_fn ( _, ast:: unsafe_fn. ) ) {
1558
1558
if sess. get_opts ( ) . check_unsafe {
1559
- ccx. tcx . sess . span_fatal (
1559
+ ccx. tcx . sess . span_err (
1560
1560
sp,
1561
1561
"safe function calls function marked unsafe" ) ;
1562
1562
}
@@ -1570,7 +1570,7 @@ fn require_pure_call(ccx: @crate_ctxt, caller_purity: ast::purity,
1570
1570
alt ccx . tcx . def_map . find ( callee. id ) {
1571
1571
some ( ast:: def_fn ( _, ast:: pure_fn. ) ) { ret; }
1572
1572
_ {
1573
- ccx. tcx . sess . span_fatal
1573
+ ccx. tcx . sess . span_err
1574
1574
( sp, "pure function calls function not known to be pure" ) ;
1575
1575
}
1576
1576
}
@@ -1591,23 +1591,6 @@ fn check_expr_with(fcx: @fn_ctxt, expr: @ast::expr, expected: ty::t) -> bool {
1591
1591
ret check_expr_with_unifier ( fcx, expr, demand:: simple, expected) ;
1592
1592
}
1593
1593
1594
- fn check_for_unsafe_assignments ( fcx : @fn_ctxt , lhs : @ast:: expr ) {
1595
- alt lhs. node {
1596
- ast:: expr_unary ( ast:: deref. , ptr ) {
1597
- let ty = expr_ty ( fcx. ccx . tcx , ptr) ;
1598
- let sty = structure_of ( fcx, ptr. span , ty) ;
1599
- alt sty {
1600
- ty : : ty_ptr ( _) {
1601
- require_unsafe ( fcx. ccx . tcx . sess , fcx. purity , lhs. span ) ;
1602
- }
1603
- _ { }
1604
- }
1605
- }
1606
- _ {
1607
- }
1608
- }
1609
- }
1610
-
1611
1594
fn check_expr_with_unifier ( fcx : @fn_ctxt , expr : @ast:: expr , unify : unifier ,
1612
1595
expected : ty:: t ) -> bool {
1613
1596
//log_err "typechecking expr " + syntax::print::pprust::expr_to_str(expr);
@@ -1719,7 +1702,6 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
1719
1702
rhs: @ast:: expr, id: ast:: node_id) -> bool {
1720
1703
let t = next_ty_var( fcx) ;
1721
1704
let bot = check_expr_with( fcx, lhs, t) | check_expr_with( fcx, rhs, t) ;
1722
- check_for_unsafe_assignments( fcx, lhs) ;
1723
1705
write:: ty_only_fixup( fcx, id, ty:: mk_nil( fcx. ccx. tcx) ) ;
1724
1706
ret bot;
1725
1707
}
@@ -1872,7 +1854,10 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
1872
1854
oper_t =
1873
1855
ty:: substitute_type_params( tcx, tps, variants[ 0 ] . args[ 0 ] ) ;
1874
1856
}
1875
- ty:: ty_ptr( inner) { oper_t = inner. ty; }
1857
+ ty:: ty_ptr( inner) {
1858
+ oper_t = inner. ty;
1859
+ require_unsafe( fcx. ccx. tcx. sess, fcx. purity, expr. span) ;
1860
+ }
1876
1861
_ {
1877
1862
tcx. sess. span_fatal( expr. span,
1878
1863
"dereferencing non-" +
0 commit comments