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 /compiler | |
| 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 'compiler')
| -rw-r--r-- | compiler/rustc_resolve/src/late/diagnostics.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 9c95adc628b..5b9513ebc0d 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -282,6 +282,14 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { "you may want to use a bool value instead", format!("{}", item_typo), )) + // FIXME(vicnenzopalazzo): make the check smarter, + // and maybe expand with levenshtein distance checks + } else if item_str.as_str() == "printf" { + Some(( + item_span, + "you may have meant to use the `print` macro", + "print!".to_owned(), + )) } else { suggestion }; |
