Support target-spec json file extension in case-insensitive form #14197
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Following rust-lang/rust#127389 to complete it on both sides. Small minor improvement without breaking changes.
Currently user's target json file can have only
.json
ext, but for file that ends with `.JSON' (in caps).It could be useful in some old OS and old file-systems such as FAT, for example.
Performance cost:
Approximately no changes.
Comparison using
eq_ignore_ascii_case
for only latest ext_len chars of theOsStr
- usingPath::extension
witheq_ignore_ascii_case
.Testing
I did not add any new tests for specs, such as with file-extensions like
jSoN
because minor change and doesn't changes existing behaviour, so existing tests are often. Should I add tests?Also there is no test because cargo tests requires stable toolchain, but to export host target spec I need nightly, using cmd
cargo rustc --bin=cargo --print target-spec-json -Zunstable-options -- -Zunstable-options
. Of course, I can hardcode it, but it requires nightly rustc for build-std... 🤔 What I should to do?How to test:
rustc --print target-spec-json -Zunstable-options > ./some-target.JSON
is-builtin
field from thesome-target.JSON
or set tofalse
cargo build --target=some-target.JSON
should workImplementation note
I've separated the comparison into a trait with methods for use instead of just
str.ends_with(".json")
and to maintain future compatibility.The trait is public for the same reasons and for potential future usage, including other dependent crates.
Questions
HasExtIgnoreCase
is a good name?crate::util
. Or not.This text looks like a copypasta of that PR. That's not exactly so. The changes are similar, and there are noticeable differences in the two texts. I apologize if this has caused inconvenience.