match self.unsafe_context.root {
SafeContext => {
// Report an error.
- span_err!(self.tcx.sess, span, E0133,
- "{} requires unsafe function or block",
- description);
+ struct_span_err!(
+ self.tcx.sess, span, E0133,
+ "{} requires unsafe function or block", description)
+ .span_label(span, &format!("unsafe call requires unsafe function or block"))
+ .emit();
}
UnsafeBlock(block_id) => {
// OK, but record this.
unsafe fn f() { return; }
fn main() {
- f(); //~ ERROR E0133
+ f();
+ //~^ ERROR E0133
+ //~| NOTE unsafe call requires unsafe function or block
}
use std::ptr;
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
}
unsafe impl UnsafeTrait for *mut isize {
fn foo(self) {
// 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
}
}
!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() {
assert_eq!(VAL, 0xFFFF0000);