about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/suggestions/seggest_print_over_printf.rs9
-rw-r--r--src/test/ui/suggestions/seggest_print_over_printf.stderr14
2 files changed, 23 insertions, 0 deletions
diff --git a/src/test/ui/suggestions/seggest_print_over_printf.rs b/src/test/ui/suggestions/seggest_print_over_printf.rs
new file mode 100644
index 00000000000..25566cd7f2a
--- /dev/null
+++ b/src/test/ui/suggestions/seggest_print_over_printf.rs
@@ -0,0 +1,9 @@
+// Suggest to a user to use the print macros
+// instead to use the printf.
+
+fn main() {
+    let x = 4;
+    printf("%d", x);
+    //~^ ERROR cannot find function `printf` in this scope
+    //~| HELP you may have meant to use the `print` macro
+}
diff --git a/src/test/ui/suggestions/seggest_print_over_printf.stderr b/src/test/ui/suggestions/seggest_print_over_printf.stderr
new file mode 100644
index 00000000000..7b1ce047a92
--- /dev/null
+++ b/src/test/ui/suggestions/seggest_print_over_printf.stderr
@@ -0,0 +1,14 @@
+error[E0425]: cannot find function `printf` in this scope
+  --> $DIR/seggest_print_over_printf.rs:6:5
+   |
+LL |     printf("%d", x);
+   |     ^^^^^^ not found in this scope
+   |
+help: you may have meant to use the `print` macro
+   |
+LL |     print!("%d", x);
+   |     ~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.