-
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
cargo -Zscript uses invalid package names when the file name starts with a digit #12330
Comments
I'm curious, was My primary concern with unilaterally applying The question is whether there is a viable alternative. Purely for brainstorming purposes
|
Yes. I set up my editor (neovim) to create temporary files using
Out of the ideas you listed, this is the best option in my opinion (tied with my initial approach)
I'm not sure what this means, does it mean that |
We can also unconditionally add an arbitrary word, so both |
So not necessarily
Yes
Most likely we'd also make the prefix be "package". "script" is unlikely to be in any of the official naming as this isn't really a script though it behaves somewhat like people are used to using scripts. |
Yes |
The behavior pre-#12255 was fairly arbitrary so reverting some of it isn't going to any better state but going to some state. Seeing as this is an unstable feature and this isn't the biggest of concerns for resolving for stabilization, I don't think we need to rush a specific answer but lets figure out a proposal of what it should be and document it so we reduce the number of caveats, rather than just transferring this caveat into a different one. At the moment, I lean towards stripping invalid package-name start chars until we find a valid one. If we don't find any valid ones, we substitute in |
Problem
When the file name starts with a digit, e.g.
0.rs
,cargo -Zscript 0.rs
defaults the package name to-0
and failsSteps
Possible Solution(s)
When the first character of the file name is invalid, insert
_
instead of-
, which makes the package name valid. So for0.rs
, the package name would default to_0
. This is #12329's approachNotes
Related: #12207, #12329 (comment)
Version
The text was updated successfully, but these errors were encountered: