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

Fix compatibility issues with various versions of Rust. #6

Merged
merged 10 commits into from
Feb 4, 2021

Conversation

Anders429
Copy link
Contributor

Fix for #5. This allows the crate to be used in all versions of Rust, from 1.0.0 upwards, as specified by the Rust version badge. I have also added coverage for each of these versions to the CI, so that they don't accidentally break again in the future :)

I had to remove the Kleene operator (?) from assert_matches! in order to not lose coverage in rustc 1.32.0, since the operator requires edition 2018 in order to be used before rustc 1.37.0. I simply broke the optional arguments into separate matchers. Interestingly, this allows assert_matches! to be used in earlier rustc versions. I bumped the MSRV for it back to 1.26.0, because that's as far back as it tests, but you could probably move it even further back by making the tests compatible (it builds all the way back to version 1.7.0, and the only thing holding it back is that the tests aren't compatible before 1.26.0). For now, I've left it at 1.26.0.

@Anders429
Copy link
Contributor Author

Hmm, I think the no_std failure is a shortcoming of cargo-nono. Building the crate on a no_std target works just fine:

$ cargo build --target thumbv6m-none-eabi
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s

Seems like cargo-nono doesn't check for anything besides #![no_std] or something like #![cfg_attr(not(feature = "std"), no_std)]. Going off of this issue, it doesn't seem like other cases are covered in its checks.

@Anders429
Copy link
Contributor Author

After further investigation, the breakage is indeed due to a limitation of cargo-nono. The code only checks for #![no_std] and #![cfg_attr(not(test), no_std)] explicitly, and doesn't check for any other cfg_attr form. There is one other check for features that disable no_std, but that is all.

@Anders429
Copy link
Contributor Author

I've changed the no_std test in the CI to directly build the crate on a no_std target, thumbv6m-none-eabi. This is, in my opinion, better than running cargo-nono, as it actually runs the build and will fail if there are any actual errors in building on no_std.

This is the same approach used by many other crates, including rand.

If you'd rather not do this, that's fine with me, but this resolves the CI failure while still showing no_std compatibility :)

Copy link
Owner

@svartalf svartalf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you'd rather not do this, that's fine with me

Also fine by me, thanks for doing it!
Can you elaborate on one thing I personally find confusing?

src/assert_matches.rs Show resolved Hide resolved
@svartalf svartalf merged commit d5ed345 into svartalf:master Feb 4, 2021
@svartalf
Copy link
Owner

svartalf commented Feb 4, 2021

I'll publish new version in a couple hours, thanks for your work!

@svartalf
Copy link
Owner

svartalf commented Feb 4, 2021

Follow-up: your changes were released in claim = "0.5.0" release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants