Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #12349 - epage:sanitize, r=weihanglo
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.
- Loading branch information