about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-06-04 04:50:36 +0000
committerbors <bors@rust-lang.org>2021-06-04 04:50:36 +0000
commit4afa3a80926f52aa361fe4e89643dac2e2e57f34 (patch)
treec0693324bfe3de1c7c5465330e084cd7ccffd85f /src/test
parent1c82bb293c83877b52380d0d7a181a011fb70603 (diff)
parentedb8f653e768361eb6191b5bbe2f31087394d79d (diff)
downloadrust-4afa3a80926f52aa361fe4e89643dac2e2e57f34.tar.gz
rust-4afa3a80926f52aa361fe4e89643dac2e2e57f34.zip
Auto merge of #85984 - JohnTitor:rollup-rq0g9ph, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #85717 (Document `From` impls for cow.rs)
 - #85850 (Remove unused feature gates)
 - #85888 (Fix typo in internal documentation for `TrustedRandomAccess`)
 - #85889 (Restoring the `num_def_ids` function in the CStore API )
 - #85899 (jsondocck small cleanup)
 - #85937 (Fix bad suggestions for code from proc_macro)
 - #85963 (Show `::{{constructor}}` in std::any::type_name().)
 - #85977 (Fix linkcheck script from getting out of sync.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/suggestions/auxiliary/proc-macro-type-error.rs18
-rw-r--r--src/test/ui/suggestions/suggest-ref-macro.rs29
-rw-r--r--src/test/ui/suggestions/suggest-ref-macro.stderr34
3 files changed, 81 insertions, 0 deletions
diff --git a/src/test/ui/suggestions/auxiliary/proc-macro-type-error.rs b/src/test/ui/suggestions/auxiliary/proc-macro-type-error.rs
new file mode 100644
index 00000000000..d71747f9687
--- /dev/null
+++ b/src/test/ui/suggestions/auxiliary/proc-macro-type-error.rs
@@ -0,0 +1,18 @@
+// force-host
+// no-prefer-dynamic
+#![crate_type = "proc-macro"]
+#![feature(proc_macro_quote)]
+
+extern crate proc_macro;
+
+use proc_macro::{quote, TokenStream};
+
+#[proc_macro_attribute]
+pub fn hello(_: TokenStream, _: TokenStream) -> TokenStream {
+    quote!(
+        fn f(_: &mut i32) {}
+        fn g() {
+            f(123);
+        }
+    )
+}
diff --git a/src/test/ui/suggestions/suggest-ref-macro.rs b/src/test/ui/suggestions/suggest-ref-macro.rs
new file mode 100644
index 00000000000..6f780f32a14
--- /dev/null
+++ b/src/test/ui/suggestions/suggest-ref-macro.rs
@@ -0,0 +1,29 @@
+// run-check
+// aux-build:proc-macro-type-error.rs
+
+extern crate proc_macro_type_error;
+
+use proc_macro_type_error::hello;
+
+#[hello] //~ERROR mismatched types
+fn abc() {}
+
+fn x(_: &mut i32) {}
+
+macro_rules! bla {
+    () => {
+        x(123);
+        //~^ ERROR mismatched types
+        //~| SUGGESTION &mut 123
+    };
+    ($v:expr) => {
+        x($v)
+    }
+}
+
+fn main() {
+    bla!();
+    bla!(456);
+    //~^ ERROR mismatched types
+    //~| SUGGESTION &mut 456
+}
diff --git a/src/test/ui/suggestions/suggest-ref-macro.stderr b/src/test/ui/suggestions/suggest-ref-macro.stderr
new file mode 100644
index 00000000000..147001f0c94
--- /dev/null
+++ b/src/test/ui/suggestions/suggest-ref-macro.stderr
@@ -0,0 +1,34 @@
+error[E0308]: mismatched types
+  --> $DIR/suggest-ref-macro.rs:8:1
+   |
+LL | #[hello]
+   | ^^^^^^^^ expected `&mut i32`, found integer
+   |
+   = note: this error originates in the attribute macro `hello` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0308]: mismatched types
+  --> $DIR/suggest-ref-macro.rs:15:11
+   |
+LL |         x(123);
+   |           ^^^
+   |           |
+   |           expected `&mut i32`, found integer
+   |           help: consider mutably borrowing here: `&mut 123`
+...
+LL |     bla!();
+   |     ------- in this macro invocation
+   |
+   = note: this error originates in the macro `bla` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0308]: mismatched types
+  --> $DIR/suggest-ref-macro.rs:26:10
+   |
+LL |     bla!(456);
+   |          ^^^
+   |          |
+   |          expected `&mut i32`, found integer
+   |          help: consider mutably borrowing here: `&mut 456`
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0308`.