Skip to content

Commit

Permalink
Rollup merge of rust-lang#35565 - wdv4758h:E0133, r=jonathandturner
Browse files Browse the repository at this point in the history
Update E0133 to new format

Part of rust-lang#35233
Fix rust-lang#35509
r? @jonathandturner
  • Loading branch information
Jonathan Turner committed Aug 11, 2016
2 parents 6692f41 + e7065b7 commit efbed8b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/librustc/middle/effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0133.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@
unsafe fn f() { return; }

fn main() {
f(); //~ ERROR E0133
f();
//~^ ERROR E0133
//~| NOTE unsafe call requires unsafe function or block
}
4 changes: 3 additions & 1 deletion src/test/compile-fail/issue-28776.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 3 additions & 1 deletion src/test/compile-fail/trait-safety-fn-body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/test/compile-fail/unsafe-const-fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit efbed8b

Please sign in to comment.