-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strange/funny error message with include_bytes!
#48364
Comments
I believe that we should verify wether any given span has a macro backtrace before providing suggestions in a general way. I'm sure there're other cases of this lurking that haven't yet been reported. Performing the check in |
cc @flip1995 |
Can we even do the macro check in the Should I just take the easy route here and add a check after each call to |
Clippy's does not access anything but the span. So we could probably move that method onto |
Do not suggest changes to str literal if it isn't one Fix rust-lang#48364.
Do not suggest changes to str literal if it isn't one Fix rust-lang#48364.
Do not suggest changes to str literal if it isn't one Fix rust-lang#48364.
The "fix-it" hint when using the
include_bytes!
macro where a&str
is expected is rather interesting:I was able to reproduce this on stable 1.24.0 and nightly. Here are the relevant
rustc --version --verbose
outputs:Stable:
Nightly:
I don't know anything about the compiler internals, but my best guess is that the fix-it suggestion is generated based on the expanded macro output (which starts with a
b
), but the suggested "fix" is generated from the source text without knowing that the two are different. Not a serious problem, but it's certainly entertaining :) I tried searching the issue tracker to see if anyone else had experienced this, but I couldn't find anything, so my apologies if this is a duplicate of something.EDIT: Right after filing the issue, I decided to go and track it down in the source: it originates here, and could probably be fixed easily by checking if the first character is actually a
b
before outputting the message. Not so sure about the error suggested by the code that immediately follows, which will add ab
toinclude_str!
if a&[u8]
is expected.The text was updated successfully, but these errors were encountered: