Update E0133 to new format

This commit is contained in:
Chiu-Hsiang Hsu 2016-08-10 15:29:45 +08:00
parent 576f766594
commit e7065b7f92
5 changed files with 17 additions and 7 deletions

View file

@ -63,9 +63,11 @@ impl<'a, 'tcx> EffectCheckVisitor<'a, 'tcx> {
match self.unsafe_context.root { match self.unsafe_context.root {
SafeContext => { SafeContext => {
// Report an error. // Report an error.
span_err!(self.tcx.sess, span, E0133, struct_span_err!(
"{} requires unsafe function or block", self.tcx.sess, span, E0133,
description); "{} requires unsafe function or block", description)
.span_label(span, &format!("unsafe call requires unsafe function or block"))
.emit();
} }
UnsafeBlock(block_id) => { UnsafeBlock(block_id) => {
// OK, but record this. // OK, but record this.

View file

@ -11,5 +11,7 @@
unsafe fn f() { return; } unsafe fn f() { return; }
fn main() { fn main() {
f(); //~ ERROR E0133 f();
//~^ ERROR E0133
//~| NOTE unsafe call requires unsafe function or block
} }

View file

@ -11,5 +11,7 @@
use std::ptr; use std::ptr;
fn main() { fn main() {
(&ptr::write)(1 as *mut _, 42); //~ ERROR E0133 (&ptr::write)(1 as *mut _, 42);
//~^ ERROR E0133
//~| NOTE unsafe call requires unsafe function or block
} }

View file

@ -18,7 +18,9 @@ unsafe trait UnsafeTrait : Sized {
unsafe impl UnsafeTrait for *mut isize { unsafe impl UnsafeTrait for *mut isize {
fn foo(self) { fn foo(self) {
// Unsafe actions are not made legal by taking place in an unsafe trait: // Unsafe actions are not made legal by taking place in an unsafe trait:
*self += 1; //~ ERROR E0133 *self += 1;
//~^ ERROR E0133
//~| NOTE unsafe call requires unsafe function or block
} }
} }

View file

@ -16,7 +16,9 @@ const unsafe fn dummy(v: u32) -> u32 {
!v !v
} }
const VAL: u32 = dummy(0xFFFF); //~ ERROR E0133 const VAL: u32 = dummy(0xFFFF);
//~^ ERROR E0133
//~| NOTE unsafe call requires unsafe function or block
fn main() { fn main() {
assert_eq!(VAL, 0xFFFF0000); assert_eq!(VAL, 0xFFFF0000);