Skip to content
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

Closed
wants to merge 1 commit into from
Closed

embedded: use _ instead of - at the start of package names #12329

wants to merge 1 commit into from

Conversation

figsoda
Copy link

@figsoda figsoda commented Jul 4, 2023

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.

@rustbot
Copy link
Collaborator

rustbot commented Jul 4, 2023

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 (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 4, 2023
@epage
Copy link
Contributor

epage commented Jul 5, 2023

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.

@figsoda
Copy link
Author

figsoda commented Jul 5, 2023

Could you please open an issue for this?

#12330

@epage epage added S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 5, 2023
@ehuss
Copy link
Contributor

ehuss commented Jul 8, 2023

r? @epage

@rustbot rustbot assigned epage and unassigned ehuss Jul 8, 2023
bors added a commit that referenced this pull request Jul 11, 2023
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.
@bors
Copy link
Contributor

bors commented Jul 11, 2023

☔ The latest upstream changes (presumably #12349) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added the S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. label Jul 11, 2023
@figsoda figsoda closed this Jul 11, 2023
@figsoda figsoda deleted the script branch July 11, 2023 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants