Skip to content

Commit

Permalink
Test -Zthir-unsafeck for unused unsafe blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
LeSeulArtichaut committed May 11, 2021
1 parent a95b342 commit d5ea294
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error: unnecessary `unsafe` block
--> $DIR/issue-48131.rs:9:9
--> $DIR/issue-48131.rs:12:9
|
LL | unsafe { /* unnecessary */ }
| ^^^^^^ unnecessary `unsafe` block
|
note: the lint level is defined here
--> $DIR/issue-48131.rs:3:9
--> $DIR/issue-48131.rs:6:9
|
LL | #![deny(unused_unsafe)]
| ^^^^^^^^^^^^^

error: unnecessary `unsafe` block
--> $DIR/issue-48131.rs:20:13
--> $DIR/issue-48131.rs:23:13
|
LL | unsafe { /* unnecessary */ }
| ^^^^^^ unnecessary `unsafe` block
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/issues/issue-48131.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck

// This note is annotated because the purpose of the test
// is to ensure that certain other notes are not generated.
#![deny(unused_unsafe)] //~ NOTE
Expand Down
20 changes: 20 additions & 0 deletions src/test/ui/issues/issue-48131.thir.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
error: unnecessary `unsafe` block
--> $DIR/issue-48131.rs:12:9
|
LL | unsafe { /* unnecessary */ }
| ^^^^^^ unnecessary `unsafe` block
|
note: the lint level is defined here
--> $DIR/issue-48131.rs:6:9
|
LL | #![deny(unused_unsafe)]
| ^^^^^^^^^^^^^

error: unnecessary `unsafe` block
--> $DIR/issue-48131.rs:23:13
|
LL | unsafe { /* unnecessary */ }
| ^^^^^^ unnecessary `unsafe` block

error: aborting due to 2 previous errors

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error: unnecessary `unsafe` block
--> $DIR/unsafe-around-compiler-generated-unsafe.rs:6:5
--> $DIR/unsafe-around-compiler-generated-unsafe.rs:9:5
|
LL | unsafe { println!("foo"); }
| ^^^^^^ unnecessary `unsafe` block
|
note: the lint level is defined here
--> $DIR/unsafe-around-compiler-generated-unsafe.rs:3:9
--> $DIR/unsafe-around-compiler-generated-unsafe.rs:6:9
|
LL | #![deny(unused_unsafe)]
| ^^^^^^^^^^^^^
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// issue #12418

// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck

#![deny(unused_unsafe)]

fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error: unnecessary `unsafe` block
--> $DIR/unsafe-around-compiler-generated-unsafe.rs:9:5
|
LL | unsafe { println!("foo"); }
| ^^^^^^ unnecessary `unsafe` block
|
note: the lint level is defined here
--> $DIR/unsafe-around-compiler-generated-unsafe.rs:6:9
|
LL | #![deny(unused_unsafe)]
| ^^^^^^^^^^^^^

error: aborting due to previous error

0 comments on commit d5ea294

Please sign in to comment.