-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Crate name found in --extern
gets suggested verbatim on unresolved import
#113035
Comments
Rustc could in fact issue an error if an invalid identifier is passed as extern name, because there is no way this identifier can be used by the program anyways (outside of the |
Sounds even better! For some reason that didn't come to my mind when opening this issue |
MCP is accepted now. Now, one could file a pull request. It should be pretty simple. |
@rustbot claim |
A low-level check would be to use rustc_lexer::is_ident. Of course, if you have any better ideas, write me. |
I'm sorry for not getting back to you. There's |
@fmease no pressure! I'm in a similar situation in fact. Thanks for the heads up. Yeah, |
Given the code in file
user.rs
as shown below:rustc outputs the following when invoked via
rustc user.rs --crate-type=lib --edition=2021 --extern=a-great-crate=liba_great_crate.rlib
:While ideally, in this specific case it should either suggest nothing of if feasible suggest changing the
--extern
flag to--extern=a_great_crate=liba_great_crate.rlib
(the latter is probably P-low). I did actually get confused by the suggestion when I originally faced it.In fact, rustc suggests whatever garbage you put in the flag (e.g. on
rustc … '--extern=a&-gre?t#crate=xxx'
). In these cases it shouldn't consider the name at all (I realize though that this might be a case of garbage in, garbage out).@rustbot label T-compiler A-diagnostics A-suggestion-diagnostics D-invalid-suggestion
The text was updated successfully, but these errors were encountered: