Rollup merge of #35565 - wdv4758h:E0133, r=jonathandturner

Update E0133 to new format

Part of #35233
Fix #35509
r? @jonathandturner
This commit is contained in:
Jonathan Turner 2016-08-11 06:34:01 -07:00 committed by GitHub
commit efbed8ba79
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 {
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.

View File

@ -11,5 +11,7 @@
unsafe fn f() { return; }
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;
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 {
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
}
}

View File

@ -16,7 +16,9 @@ const unsafe fn dummy(v: u32) -> u32 {
!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);