diff options
| author | LeSeulArtichaut <leseulartichaut@gmail.com> | 2021-05-14 23:19:59 +0200 |
|---|---|---|
| committer | LeSeulArtichaut <leseulartichaut@gmail.com> | 2021-05-20 00:01:05 +0200 |
| commit | 27fe959c2c99207828cedfe19dbf96debd3be591 (patch) | |
| tree | 032331ed30cfa08471cd2a400b3f47fb618dd4a4 /src/test/ui/traits | |
| parent | f94942d8421dc4b1da86d07069571ddb43127235 (diff) | |
| download | rust-27fe959c2c99207828cedfe19dbf96debd3be591.tar.gz rust-27fe959c2c99207828cedfe19dbf96debd3be591.zip | |
Check for raw pointer dereference in THIR unsafeck
Diffstat (limited to 'src/test/ui/traits')
| -rw-r--r-- | src/test/ui/traits/safety-fn-body.mir.stderr (renamed from src/test/ui/traits/safety-fn-body.stderr) | 2 | ||||
| -rw-r--r-- | src/test/ui/traits/safety-fn-body.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/traits/safety-fn-body.thir.stderr | 11 |
3 files changed, 15 insertions, 1 deletions
diff --git a/src/test/ui/traits/safety-fn-body.stderr b/src/test/ui/traits/safety-fn-body.mir.stderr index 0aeb186828e..ea7b2048e83 100644 --- a/src/test/ui/traits/safety-fn-body.stderr +++ b/src/test/ui/traits/safety-fn-body.mir.stderr @@ -1,5 +1,5 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block - --> $DIR/safety-fn-body.rs:11:9 + --> $DIR/safety-fn-body.rs:14:9 | LL | *self += 1; | ^^^^^^^^^^ dereference of raw pointer diff --git a/src/test/ui/traits/safety-fn-body.rs b/src/test/ui/traits/safety-fn-body.rs index df527747305..2cc4fe1b344 100644 --- a/src/test/ui/traits/safety-fn-body.rs +++ b/src/test/ui/traits/safety-fn-body.rs @@ -1,6 +1,9 @@ // Check that an unsafe impl does not imply that unsafe actions are // legal in the methods. +// revisions: mir thir +// [thir]compile-flags: -Z thir-unsafeck + unsafe trait UnsafeTrait : Sized { fn foo(self) { } } diff --git a/src/test/ui/traits/safety-fn-body.thir.stderr b/src/test/ui/traits/safety-fn-body.thir.stderr new file mode 100644 index 00000000000..94a1a2a03cd --- /dev/null +++ b/src/test/ui/traits/safety-fn-body.thir.stderr @@ -0,0 +1,11 @@ +error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block + --> $DIR/safety-fn-body.rs:14:9 + | +LL | *self += 1; + | ^^^^^ dereference of raw pointer + | + = note: raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0133`. |
