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

MSRV: Make the code buildable on Rust 1.34 #17

Merged
merged 4 commits into from
Sep 24, 2020

Conversation

laarmen
Copy link
Contributor

@laarmen laarmen commented Sep 20, 2020

Rationale

A crate I'm depending on is about to depend on duplicate, and while the changes there seem really nice, I need to be able to build on 1.34.2 (which is the version of Rust shipped on the current Debian Stable).

Description of the changes

The changes are relatively benign, with only one small semantic change, in parse_utils::next_token, where in the inner group matching the function now unconditionally pops two values from the iterator instead of just one and "perhaps" another. As the iterator is locally created I don't think it leaks any side effect out of the function.

You'll find some details about what wasn't 1.34-compatible in the commit messages.

Caveats

To be able to test those changes on 1.34, one need a patched version of macrotest.
Two tests fail on 1.34, but they fail because it's not possible to apply attributes to modules (module_disambiguation) nor statements (duplicate_inline) in 1.34, not because of the underlying logic of the macro.

In Rust versions prior to 1.42, the proc_macro internal crate couldn't
be used without this declaration, see https://github.com/rust-lang/rust/blob/master/RELEASES.md#cargo-4
@Emoun
Copy link
Owner

Emoun commented Sep 21, 2020

@laarmen Thank you for this PR, I have had a quick look at it and it seems reasonable.

I will have a deeper look at your PR in the coming days. I have not decided on an MSRV policy for this crate yet, so I'll need to look into it as part of reviewing this.

@Emoun Emoun mentioned this pull request Sep 21, 2020
2 tasks
Copy link
Owner

@Emoun Emoun left a comment

Choose a reason for hiding this comment

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

@laarmen I have reviewed your code and only requested a small change.

When I am confident that I can commit to an MSRV of 1.34 I will merge this PR. You can track my progress in #18.

src/parse_utils.rs Outdated Show resolved Hide resolved
@Emoun
Copy link
Owner

Emoun commented Sep 23, 2020

@laarmen I have finished looking at the MSRV policy and am ready to accept your PR after you apply the requested change.

I will look into publishing a new release with the new MSRV policy as soon as possible.

@laarmen
Copy link
Contributor Author

laarmen commented Sep 23, 2020 via email

While this technically changes the semantics of the code, it shouldn't
impact the overall behaviour of the method as a *normal* implementation
of Iterator would be idempotent once the end reached. As such, if the
first token is None, we can safely discard the second one.

This change is done in order to avoid using a reference to `in_group`
within the guard clause, as Rust 1.34 complains about it. It is probable
that the more recent versions accept it from 1.39 on, see https://github.com/rust-lang/rust/blob/master/RELEASES.md#language-7
Being able to borrow a reference that has been bound-by-move in its guard
clause has only been made possible in Rust 1.39, see
https://github.com/rust-lang/rust/blob/master/RELEASES.md#language-7.

Those changes are just a matter of specifying that we only want to match
on references and not plain values.
@Emoun
Copy link
Owner

Emoun commented Sep 24, 2020

@laarmen Thanks for the changes, and thanks for the detailed commit messages. I'll merge this PR and look into publishing a new release.

@Emoun Emoun merged commit fa3b754 into Emoun:master Sep 24, 2020
@Emoun Emoun mentioned this pull request Jan 16, 2022
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