diff options
| author | Vincenzo Palazzo <vincenzopalazzodev@gmail.com> | 2022-11-26 22:23:27 +0100 |
|---|---|---|
| committer | Vincenzo Palazzo <vincenzopalazzodev@gmail.com> | 2022-11-27 11:50:02 +0100 |
| commit | ee6f18ef595df21cfe167834f59c768985d74d4c (patch) | |
| tree | 5a1d0d4c41dbeec0bdb6e387b250099410038878 /src | |
| parent | c3a1c023c0784ffbcf4dd57cf4618d208bccae69 (diff) | |
| download | rust-ee6f18ef595df21cfe167834f59c768985d74d4c.tar.gz rust-ee6f18ef595df21cfe167834f59c768985d74d4c.zip | |
make simple check of prinf function.
With this commit we start to make some simple check when the name resolution fails, and we generate some helper message in case the name is a C name like in the case of the `printf` and suggest the correct rust method. Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/suggestions/seggest_print_over_printf.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/suggestions/seggest_print_over_printf.stderr | 14 |
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`. |
