about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/pretty/autodiff/autodiff_forward.pp (renamed from tests/pretty/autodiff_forward.pp)0
-rw-r--r--tests/pretty/autodiff/autodiff_forward.rs (renamed from tests/pretty/autodiff_forward.rs)0
-rw-r--r--tests/pretty/autodiff/autodiff_reverse.pp (renamed from tests/pretty/autodiff_reverse.pp)0
-rw-r--r--tests/pretty/autodiff/autodiff_reverse.rs (renamed from tests/pretty/autodiff_reverse.rs)0
-rw-r--r--tests/pretty/autodiff/inherent_impl.pp41
-rw-r--r--tests/pretty/autodiff/inherent_impl.rs24
-rw-r--r--tests/ui/macros/reparse-expr-issue-139495.rs14
-rw-r--r--tests/ui/macros/reparse-expr-issue-139495.stderr25
-rw-r--r--tests/ui/parser/expr-rarrow-call-on-a-raw-pointer.rs22
-rw-r--r--tests/ui/parser/expr-rarrow-call-on-a-raw-pointer.stderr53
-rw-r--r--tests/ui/parser/expr-rarrow-call.fixed10
-rw-r--r--tests/ui/parser/expr-rarrow-call.rs10
-rw-r--r--tests/ui/parser/expr-rarrow-call.stderr20
-rw-r--r--tests/ui/parser/issues/issue-118530-ice.rs2
-rw-r--r--tests/ui/parser/issues/issue-118530-ice.stderr4
15 files changed, 192 insertions, 33 deletions
diff --git a/tests/pretty/autodiff_forward.pp b/tests/pretty/autodiff/autodiff_forward.pp
index 713b8f541ae..713b8f541ae 100644
--- a/tests/pretty/autodiff_forward.pp
+++ b/tests/pretty/autodiff/autodiff_forward.pp
diff --git a/tests/pretty/autodiff_forward.rs b/tests/pretty/autodiff/autodiff_forward.rs
index 5a0660a08e5..5a0660a08e5 100644
--- a/tests/pretty/autodiff_forward.rs
+++ b/tests/pretty/autodiff/autodiff_forward.rs
diff --git a/tests/pretty/autodiff_reverse.pp b/tests/pretty/autodiff/autodiff_reverse.pp
index 31920694a3a..31920694a3a 100644
--- a/tests/pretty/autodiff_reverse.pp
+++ b/tests/pretty/autodiff/autodiff_reverse.pp
diff --git a/tests/pretty/autodiff_reverse.rs b/tests/pretty/autodiff/autodiff_reverse.rs
index 3c024272f40..3c024272f40 100644
--- a/tests/pretty/autodiff_reverse.rs
+++ b/tests/pretty/autodiff/autodiff_reverse.rs
diff --git a/tests/pretty/autodiff/inherent_impl.pp b/tests/pretty/autodiff/inherent_impl.pp
new file mode 100644
index 00000000000..97ac766b6b9
--- /dev/null
+++ b/tests/pretty/autodiff/inherent_impl.pp
@@ -0,0 +1,41 @@
+#![feature(prelude_import)]
+#![no_std]
+//@ needs-enzyme
+
+#![feature(autodiff)]
+#[prelude_import]
+use ::std::prelude::rust_2015::*;
+#[macro_use]
+extern crate std;
+//@ pretty-mode:expanded
+//@ pretty-compare-only
+//@ pp-exact:inherent_impl.pp
+
+use std::autodiff::autodiff;
+
+struct Foo {
+    a: f64,
+}
+
+trait MyTrait {
+    fn f(&self, x: f64)
+    -> f64;
+    fn df(&self, x: f64, seed: f64)
+    -> (f64, f64);
+}
+
+impl MyTrait for Foo {
+    #[rustc_autodiff]
+    #[inline(never)]
+    fn f(&self, x: f64) -> f64 {
+        self.a * 0.25 * (x * x - 1.0 - 2.0 * x.ln())
+    }
+    #[rustc_autodiff(Reverse, 1, Const, Active, Active)]
+    #[inline(never)]
+    fn df(&self, x: f64, dret: f64) -> (f64, f64) {
+        unsafe { asm!("NOP", options(pure, nomem)); };
+        ::core::hint::black_box(self.f(x));
+        ::core::hint::black_box((dret,));
+        ::core::hint::black_box((self.f(x), f64::default()))
+    }
+}
diff --git a/tests/pretty/autodiff/inherent_impl.rs b/tests/pretty/autodiff/inherent_impl.rs
new file mode 100644
index 00000000000..59de93f7e0f
--- /dev/null
+++ b/tests/pretty/autodiff/inherent_impl.rs
@@ -0,0 +1,24 @@
+//@ needs-enzyme
+
+#![feature(autodiff)]
+//@ pretty-mode:expanded
+//@ pretty-compare-only
+//@ pp-exact:inherent_impl.pp
+
+use std::autodiff::autodiff;
+
+struct Foo {
+    a: f64,
+}
+
+trait MyTrait {
+    fn f(&self, x: f64) -> f64;
+    fn df(&self, x: f64, seed: f64) -> (f64, f64);
+}
+
+impl MyTrait for Foo {
+    #[autodiff(df, Reverse, Const, Active, Active)]
+    fn f(&self, x: f64) -> f64 {
+        self.a * 0.25 * (x * x - 1.0 - 2.0 * x.ln())
+    }
+}
diff --git a/tests/ui/macros/reparse-expr-issue-139495.rs b/tests/ui/macros/reparse-expr-issue-139495.rs
index 38d24573a53..89734cae0a6 100644
--- a/tests/ui/macros/reparse-expr-issue-139495.rs
+++ b/tests/ui/macros/reparse-expr-issue-139495.rs
@@ -1,7 +1,15 @@
-macro_rules! m {
-  ($abi : expr) => { extern $abi } //~ ERROR expected expression, found keyword `extern`
+macro_rules! m1 {
+  ($abi: literal) => { extern $abi } //~ ERROR expected expression, found keyword `extern`
+}
+
+macro_rules! m2 {
+  ($abi: expr) => { extern $abi } //~ ERROR expected expression, found keyword `extern`
 }
 
 fn main() {
-    m!(-2)
+    m1!(-2)
+}
+
+fn f() {
+    m2!(-2)
 }
diff --git a/tests/ui/macros/reparse-expr-issue-139495.stderr b/tests/ui/macros/reparse-expr-issue-139495.stderr
index 73a8ed87ba0..e2e05d67ecc 100644
--- a/tests/ui/macros/reparse-expr-issue-139495.stderr
+++ b/tests/ui/macros/reparse-expr-issue-139495.stderr
@@ -1,13 +1,24 @@
 error: expected expression, found keyword `extern`
-  --> $DIR/reparse-expr-issue-139495.rs:2:22
+  --> $DIR/reparse-expr-issue-139495.rs:2:24
    |
-LL |   ($abi : expr) => { extern $abi }
-   |                      ^^^^^^ expected expression
+LL |   ($abi: literal) => { extern $abi }
+   |                        ^^^^^^ expected expression
 ...
-LL |     m!(-2)
-   |     ------ in this macro invocation
+LL |     m1!(-2)
+   |     ------- in this macro invocation
    |
-   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m1` (in Nightly builds, run with -Z macro-backtrace for more info)
 
-error: aborting due to 1 previous error
+error: expected expression, found keyword `extern`
+  --> $DIR/reparse-expr-issue-139495.rs:6:21
+   |
+LL |   ($abi: expr) => { extern $abi }
+   |                     ^^^^^^ expected expression
+...
+LL |     m2!(-2)
+   |     ------- in this macro invocation
+   |
+   = note: this error originates in the macro `m2` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 2 previous errors
 
diff --git a/tests/ui/parser/expr-rarrow-call-on-a-raw-pointer.rs b/tests/ui/parser/expr-rarrow-call-on-a-raw-pointer.rs
new file mode 100644
index 00000000000..0ce5e233930
--- /dev/null
+++ b/tests/ui/parser/expr-rarrow-call-on-a-raw-pointer.rs
@@ -0,0 +1,22 @@
+#![allow(
+    dead_code,
+    unused_must_use
+)]
+
+struct Named {
+    foo: usize,
+}
+
+struct Unnamed(usize);
+
+unsafe fn named_struct_field_access(named: *mut Named) {
+    named->foo += 1; //~ ERROR `->` is not valid syntax for field accesses and method calls
+    //~^ ERROR no field `foo` on type `*mut Named`
+}
+
+unsafe fn unnamed_struct_field_access(unnamed: *mut Unnamed) {
+    unnamed->0 += 1; //~ ERROR `->` is not valid syntax for field accesses and method calls
+    //~^ ERROR no field `0` on type `*mut Unnamed`
+}
+
+fn main() {}
diff --git a/tests/ui/parser/expr-rarrow-call-on-a-raw-pointer.stderr b/tests/ui/parser/expr-rarrow-call-on-a-raw-pointer.stderr
new file mode 100644
index 00000000000..45f3c5549f7
--- /dev/null
+++ b/tests/ui/parser/expr-rarrow-call-on-a-raw-pointer.stderr
@@ -0,0 +1,53 @@
+error: `->` is not valid syntax for field accesses and method calls
+  --> $DIR/expr-rarrow-call-on-a-raw-pointer.rs:13:10
+   |
+LL |     named->foo += 1;
+   |          ^^
+   |
+   = help: the `.` operator will automatically dereference the value, except if the value is a raw pointer
+help: try using `.` instead
+   |
+LL -     named->foo += 1;
+LL +     named.foo += 1;
+   |
+
+error: `->` is not valid syntax for field accesses and method calls
+  --> $DIR/expr-rarrow-call-on-a-raw-pointer.rs:18:12
+   |
+LL |     unnamed->0 += 1;
+   |            ^^
+   |
+   = help: the `.` operator will automatically dereference the value, except if the value is a raw pointer
+help: try using `.` instead
+   |
+LL -     unnamed->0 += 1;
+LL +     unnamed.0 += 1;
+   |
+
+error[E0609]: no field `foo` on type `*mut Named`
+  --> $DIR/expr-rarrow-call-on-a-raw-pointer.rs:13:12
+   |
+LL |     named->foo += 1;
+   |            ^^^ unknown field
+   |
+help: `named` is a raw pointer; try dereferencing it
+   |
+LL -     named->foo += 1;
+LL +     (*named).foo += 1;
+   |
+
+error[E0609]: no field `0` on type `*mut Unnamed`
+  --> $DIR/expr-rarrow-call-on-a-raw-pointer.rs:18:14
+   |
+LL |     unnamed->0 += 1;
+   |              ^ unknown field
+   |
+help: `unnamed` is a raw pointer; try dereferencing it
+   |
+LL -     unnamed->0 += 1;
+LL +     (*unnamed).0 += 1;
+   |
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0609`.
diff --git a/tests/ui/parser/expr-rarrow-call.fixed b/tests/ui/parser/expr-rarrow-call.fixed
index 9a05e20092d..c97284c4b01 100644
--- a/tests/ui/parser/expr-rarrow-call.fixed
+++ b/tests/ui/parser/expr-rarrow-call.fixed
@@ -11,23 +11,23 @@ struct Named {
 struct Unnamed(usize);
 
 fn named_struct_field_access(named: &Named) {
-    named.foo; //~ ERROR `->` used for field access or method call
+    named.foo; //~ ERROR `->` is not valid syntax for field accesses and method calls
 }
 
 fn unnamed_struct_field_access(unnamed: &Unnamed) {
-    unnamed.0; //~ ERROR `->` used for field access or method call
+    unnamed.0; //~ ERROR `->` is not valid syntax for field accesses and method calls
 }
 
 fn tuple_field_access(t: &(u8, u8)) {
-    t.0; //~ ERROR `->` used for field access or method call
-    t.1; //~ ERROR `->` used for field access or method call
+    t.0; //~ ERROR `->` is not valid syntax for field accesses and method calls
+    t.1; //~ ERROR `->` is not valid syntax for field accesses and method calls
 }
 
 #[derive(Clone)]
 struct Foo;
 
 fn method_call(foo: &Foo) {
-    foo.clone(); //~ ERROR `->` used for field access or method call
+    foo.clone(); //~ ERROR `->` is not valid syntax for field accesses and method calls
 }
 
 fn main() {}
diff --git a/tests/ui/parser/expr-rarrow-call.rs b/tests/ui/parser/expr-rarrow-call.rs
index 760b0f6f345..78cd72b12ec 100644
--- a/tests/ui/parser/expr-rarrow-call.rs
+++ b/tests/ui/parser/expr-rarrow-call.rs
@@ -11,23 +11,23 @@ struct Named {
 struct Unnamed(usize);
 
 fn named_struct_field_access(named: &Named) {
-    named->foo; //~ ERROR `->` used for field access or method call
+    named->foo; //~ ERROR `->` is not valid syntax for field accesses and method calls
 }
 
 fn unnamed_struct_field_access(unnamed: &Unnamed) {
-    unnamed->0; //~ ERROR `->` used for field access or method call
+    unnamed->0; //~ ERROR `->` is not valid syntax for field accesses and method calls
 }
 
 fn tuple_field_access(t: &(u8, u8)) {
-    t->0; //~ ERROR `->` used for field access or method call
-    t->1; //~ ERROR `->` used for field access or method call
+    t->0; //~ ERROR `->` is not valid syntax for field accesses and method calls
+    t->1; //~ ERROR `->` is not valid syntax for field accesses and method calls
 }
 
 #[derive(Clone)]
 struct Foo;
 
 fn method_call(foo: &Foo) {
-    foo->clone(); //~ ERROR `->` used for field access or method call
+    foo->clone(); //~ ERROR `->` is not valid syntax for field accesses and method calls
 }
 
 fn main() {}
diff --git a/tests/ui/parser/expr-rarrow-call.stderr b/tests/ui/parser/expr-rarrow-call.stderr
index 2e168ca26fe..0b105273861 100644
--- a/tests/ui/parser/expr-rarrow-call.stderr
+++ b/tests/ui/parser/expr-rarrow-call.stderr
@@ -1,62 +1,62 @@
-error: `->` used for field access or method call
+error: `->` is not valid syntax for field accesses and method calls
   --> $DIR/expr-rarrow-call.rs:14:10
    |
 LL |     named->foo;
    |          ^^
    |
-   = help: the `.` operator will dereference the value if needed
+   = help: the `.` operator will automatically dereference the value, except if the value is a raw pointer
 help: try using `.` instead
    |
 LL -     named->foo;
 LL +     named.foo;
    |
 
-error: `->` used for field access or method call
+error: `->` is not valid syntax for field accesses and method calls
   --> $DIR/expr-rarrow-call.rs:18:12
    |
 LL |     unnamed->0;
    |            ^^
    |
-   = help: the `.` operator will dereference the value if needed
+   = help: the `.` operator will automatically dereference the value, except if the value is a raw pointer
 help: try using `.` instead
    |
 LL -     unnamed->0;
 LL +     unnamed.0;
    |
 
-error: `->` used for field access or method call
+error: `->` is not valid syntax for field accesses and method calls
   --> $DIR/expr-rarrow-call.rs:22:6
    |
 LL |     t->0;
    |      ^^
    |
-   = help: the `.` operator will dereference the value if needed
+   = help: the `.` operator will automatically dereference the value, except if the value is a raw pointer
 help: try using `.` instead
    |
 LL -     t->0;
 LL +     t.0;
    |
 
-error: `->` used for field access or method call
+error: `->` is not valid syntax for field accesses and method calls
   --> $DIR/expr-rarrow-call.rs:23:6
    |
 LL |     t->1;
    |      ^^
    |
-   = help: the `.` operator will dereference the value if needed
+   = help: the `.` operator will automatically dereference the value, except if the value is a raw pointer
 help: try using `.` instead
    |
 LL -     t->1;
 LL +     t.1;
    |
 
-error: `->` used for field access or method call
+error: `->` is not valid syntax for field accesses and method calls
   --> $DIR/expr-rarrow-call.rs:30:8
    |
 LL |     foo->clone();
    |        ^^
    |
-   = help: the `.` operator will dereference the value if needed
+   = help: the `.` operator will automatically dereference the value, except if the value is a raw pointer
 help: try using `.` instead
    |
 LL -     foo->clone();
diff --git a/tests/ui/parser/issues/issue-118530-ice.rs b/tests/ui/parser/issues/issue-118530-ice.rs
index cf14eebec2b..8930eb86c6b 100644
--- a/tests/ui/parser/issues/issue-118530-ice.rs
+++ b/tests/ui/parser/issues/issue-118530-ice.rs
@@ -5,7 +5,7 @@ fn bar() -> String {
     attr::fn bar() -> String { //~ ERROR expected identifier, found keyword `fn`
     //~^ ERROR expected one of `(`, `.`, `::`, `;`, `?`, `}`, or an operator, found `{`
     //~| ERROR expected `;`, found `bar`
-    //~| ERROR `->` used for field access or method call
+    //~| ERROR `->` is not valid syntax for field accesses and method calls
     #[attr]
     [1, 2, 3].iter().map().collect::<String>()
     #[attr]
diff --git a/tests/ui/parser/issues/issue-118530-ice.stderr b/tests/ui/parser/issues/issue-118530-ice.stderr
index 72c0397e9c9..ef891d1dc29 100644
--- a/tests/ui/parser/issues/issue-118530-ice.stderr
+++ b/tests/ui/parser/issues/issue-118530-ice.stderr
@@ -33,13 +33,13 @@ LL |     attr::fn bar() -> String {
    |             |
    |             help: add `;` here
 
-error: `->` used for field access or method call
+error: `->` is not valid syntax for field accesses and method calls
   --> $DIR/issue-118530-ice.rs:5:20
    |
 LL |     attr::fn bar() -> String {
    |                    ^^
    |
-   = help: the `.` operator will dereference the value if needed
+   = help: the `.` operator will automatically dereference the value, except if the value is a raw pointer
 help: try using `.` instead
    |
 LL -     attr::fn bar() -> String {