about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2018-12-23 23:09:08 +0100
committerGitHub <noreply@github.com>2018-12-23 23:09:08 +0100
commiteb24b33b666451dbf0193df1a997e0fa1da970fd (patch)
treec9d48d06baab08face2cb3f4154bb5fd913782e5 /src/test
parent61f50d9d2e446ebc4fb4a8f5b5ea886f9e661efd (diff)
parent030987481b339616954d36b4c421e86077f00e75 (diff)
downloadrust-eb24b33b666451dbf0193df1a997e0fa1da970fd.tar.gz
rust-eb24b33b666451dbf0193df1a997e0fa1da970fd.zip
Rollup merge of #56966 - varkor:raw-pointer-deref-parens, r=zackmdavis
Correct strings for raw pointer deref and array access suggestions

Fixes https://github.com/rust-lang/rust/issues/56714.
Fixes https://github.com/rust-lang/rust/issues/56963.

r? @zackmdavis
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/issues/issue-11004.stderr8
-rw-r--r--src/test/ui/parenthesised-deref-suggestion.rs11
-rw-r--r--src/test/ui/parenthesised-deref-suggestion.stderr21
-rw-r--r--src/test/ui/unsafe/unsafe-fn-autoderef.stderr4
4 files changed, 41 insertions, 3 deletions
diff --git a/src/test/ui/issues/issue-11004.stderr b/src/test/ui/issues/issue-11004.stderr
index 215120c9c25..eb5b568b347 100644
--- a/src/test/ui/issues/issue-11004.stderr
+++ b/src/test/ui/issues/issue-11004.stderr
@@ -2,13 +2,17 @@ error[E0609]: no field `x` on type `*mut A`
   --> $DIR/issue-11004.rs:17:21
    |
 LL |     let x : i32 = n.x; //~ no field `x` on type `*mut A`
-   |                     ^ help: `n` is a native pointer; try dereferencing it: `(*n).x`
+   |                   --^
+   |                   |
+   |                   help: `n` is a raw pointer; try dereferencing it: `(*n).x`
 
 error[E0609]: no field `y` on type `*mut A`
   --> $DIR/issue-11004.rs:18:21
    |
 LL |     let y : f64 = n.y; //~ no field `y` on type `*mut A`
-   |                     ^ help: `n` is a native pointer; try dereferencing it: `(*n).y`
+   |                   --^
+   |                   |
+   |                   help: `n` is a raw pointer; try dereferencing it: `(*n).y`
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/parenthesised-deref-suggestion.rs b/src/test/ui/parenthesised-deref-suggestion.rs
new file mode 100644
index 00000000000..0b4ccdd5a56
--- /dev/null
+++ b/src/test/ui/parenthesised-deref-suggestion.rs
@@ -0,0 +1,11 @@
+struct Session {
+    opts: u8,
+}
+
+fn main() {
+    let sess: &Session = &Session { opts: 0 };
+    (sess as *const Session).opts; //~ ERROR no field `opts` on type `*const Session`
+
+    let x = [0u32];
+    (x as [u32; 1]).0; //~ ERROR no field `0` on type `[u32; 1]`
+}
diff --git a/src/test/ui/parenthesised-deref-suggestion.stderr b/src/test/ui/parenthesised-deref-suggestion.stderr
new file mode 100644
index 00000000000..71a2bf67f06
--- /dev/null
+++ b/src/test/ui/parenthesised-deref-suggestion.stderr
@@ -0,0 +1,21 @@
+error[E0609]: no field `opts` on type `*const Session`
+  --> $DIR/parenthesised-deref-suggestion.rs:7:30
+   |
+LL |     (sess as *const Session).opts; //~ ERROR no field `opts` on type `*const Session`
+   |                              ^^^^
+help: `(sess as *const Session)` is a raw pointer; try dereferencing it
+   |
+LL |     (*(sess as *const Session)).opts; //~ ERROR no field `opts` on type `*const Session`
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0609]: no field `0` on type `[u32; 1]`
+  --> $DIR/parenthesised-deref-suggestion.rs:10:21
+   |
+LL |     (x as [u32; 1]).0; //~ ERROR no field `0` on type `[u32; 1]`
+   |     ----------------^
+   |     |
+   |     help: instead of using tuple indexing, use array indexing: `(x as [u32; 1])[0]`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0609`.
diff --git a/src/test/ui/unsafe/unsafe-fn-autoderef.stderr b/src/test/ui/unsafe/unsafe-fn-autoderef.stderr
index 13fcbb347c9..7525f670515 100644
--- a/src/test/ui/unsafe/unsafe-fn-autoderef.stderr
+++ b/src/test/ui/unsafe/unsafe-fn-autoderef.stderr
@@ -2,7 +2,9 @@ error[E0609]: no field `f` on type `*const Rec`
   --> $DIR/unsafe-fn-autoderef.rs:29:14
    |
 LL |     return p.f; //~ ERROR no field `f` on type `*const Rec`
-   |              ^ help: `p` is a native pointer; try dereferencing it: `(*p).f`
+   |            --^
+   |            |
+   |            help: `p` is a raw pointer; try dereferencing it: `(*p).f`
 
 error: aborting due to previous error