-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
embedded: use _
instead of -
at the start of package names
#12329
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
Could you please open an issue for this? I feel like this needs more solution-exploration / solution-design discussion which I find better in Issues as things can evolve and there can be more than one PR per Issue, while I try to leave PRs to just the implementation. |
|
r? @epage |
fix(embedded): Always generate valid package names ### What does this PR try to resolve? The sanitization logic uses a placeholder for the first character that isn't valid in the first character position. #12329 took the approach of always using `_` which has the problem of mixing separators if the user used `-` or we had other placeholders to insert. Instead, this takes the approach of stripping the leading invalid characters and using a placeholder name if nothing is left. Fixes #12330 ### How should we test and review this PR? Per-commit. The first adds tests so the change in behavior can be observed over each additional commit. ### Additional information I was also hoping to make the binary name not use placeholders by setting `bin.name` to `file_stem` but then I got ``` Compiling s-h-w-c- v0.0.0 (/home/epage/src/personal/cargo/target/tmp/cit/t133/foo) error: invalid character `'.'` in crate name: `s_h.w§c!` error: invalid character `'§'` in crate name: `s_h.w§c!` error: invalid character `'!'` in crate name: `s_h.w§c!` error: could not compile `s-h-w-c-` (bin "s-h.w§c!") due to 3 previous errors ``` I decided to not get into what are or aren't valid characters according to rustc.
☔ The latest upstream changes (presumably #12349) made this pull request unmergeable. Please resolve the merge conflicts. |
Related: #12207
-Zscript
fails when the file name starts with a digit: e.g.0.rs
because-0
is not a valid package name. Changing the placeholder from-
to_
at the start of the package name fixes the issue.