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

Update nom dependency in Cargo.toml #47

Merged
merged 8 commits into from
Feb 5, 2020

Conversation

rekanorman
Copy link
Contributor

This change gives users the option of using nom_locate without needing to use the default features of nom, e.g. "lexical".

This change is necessary to allow nom_locate to be used without using the default features of nom, e.g. "lexical".
@progval progval self-requested a review January 16, 2020 23:53
@rekanorman
Copy link
Contributor Author

@fflorent would you mind merging this change so that we can use nom_locate without needing to include all the default dependencies of nom, such as "lexical-core".

@progval
Copy link
Collaborator

progval commented Jan 16, 2020

@rekanorman I'll review this later in the week

@rekanorman
Copy link
Contributor Author

@progval thanks!

@rekanorman
Copy link
Contributor Author

@progval just checking if there's any update on this?

@rekanorman
Copy link
Contributor Author

Hi @progval, @fflorent, just checking in again to see if there's been any update.

@progval
Copy link
Collaborator

progval commented Feb 3, 2020

Ugh sorry, I still haven't found the time to look at this

@progval
Copy link
Collaborator

progval commented Feb 3, 2020

Okay, that looks good to me. Could you just fix the tests so they run on Travis? This would mostly involve skipping some tests (eg. #[cfg(not(feature="std"))])

I don't think it's possible to make FEATURES="allow" work on stable or beta, so you should tell Travis that they are allowed to fail

rekanorman and others added 3 commits February 4, 2020 10:39
Since a lot of stuff in nom_locate depends on nom having the "std" feature, it probably makes sense to require this feature. Other nom features such as "regexp" and "lexical" will still be optional.
@rekanorman
Copy link
Contributor Author

Thanks for taking a look.

It looks like the line #![cfg_attr(all(not(feature = "std"), feature = "alloc"), feature(alloc))] in nom might be an error. There's currently no compiler feature called alloc, possibly this was an old feature which no longer exists?

Instead of allowing the tests to fail on stable and beta, I thought it might be nicer to just require the "std" feature in the nom dependency. The "lexical" feature will still be optional.

Let me know what you think. If you'd prefer to allow the tests to fail instead, I'm happy to make this change.

@progval
Copy link
Collaborator

progval commented Feb 4, 2020

It looks like the line #![cfg_attr(all(not(feature = "std"), feature = "alloc"), feature(alloc))] in nom might be an error. There's currently no compiler feature called alloc, possibly this was an old feature which no longer exists?

hmm, last I checked, the alloc compiler feature was used to determine if the alloc crate was available. It looks like it's always available now? Weird.

I'll look into it later.

Instead of allowing the tests to fail on stable and beta, I thought it might be nicer to just require the "std" feature in the nom dependency.

No, nom_locate shouldn't unconditionally depend on nom's std. If any dependency requires std, it means the whole crate depends on std, which defeats the purpose

@rekanorman
Copy link
Contributor Author

No, nom_locate shouldn't unconditionally depend on nom's std. If any dependency requires std, it means the whole crate depends on std, which defeats the purpose

That makes sense.

Sorry, I was confused before and didn't understand that alloc was a nightly-only feature. I belived I've made the correct change now, let me know what you think.

.travis.yml Outdated
Comment on lines 46 to 54
- rust: stable
env: FEATURES='alloc'
- rust: stable
env: FEATURES=''

- rust: beta
env: FEATURES='default'
- rust: beta
env: FEATURES='alloc'
Copy link
Collaborator

Choose a reason for hiding this comment

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

don't remove these; the jobs should be in both (yeah I know, it doesn't make sense, but that's how Travis works)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Collaborator

@progval progval left a comment

Choose a reason for hiding this comment

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

Sorry, one last thing I should have caught earlier

@@ -10,6 +10,7 @@ use std::ops::{Range, RangeFull};
type StrSpan<'a> = LocatedSpan<&'a str>;
type BytesSpan<'a> = LocatedSpan<&'a [u8]>;

#[cfg(feature = "alloc")]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be:

 #[cfg(any(feature = "std", feature = "alloc"))]

because std does not imply alloc.

(same for the other occurences below)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@progval
Copy link
Collaborator

progval commented Feb 5, 2020

Thanks!

@progval progval merged commit aa72618 into fflorent:master Feb 5, 2020
progval pushed a commit that referenced this pull request Feb 5, 2020
* Update nom dependency in Cargo.toml

This change is necessary to allow nom_locate to be used without using the default features of nom, e.g. "lexical".

* Change nom dependency to require "std" feature.

Since a lot of stuff in nom_locate depends on nom having the "std" feature, it probably makes sense to require this feature. Other nom features such as "regexp" and "lexical" will still be optional.

* Add #[cfg(feature = alloc)] to tests which require the nom alloc feature.

* Revert "Add #[cfg(feature = alloc)] to tests which require the nom alloc feature."

This reverts commit 6b72f8b.

* Remove "std" feature from nom dependency, and allow failures with "alloc" on stable/beta.

* Add removed jobs back to travis.yml include section.

* Add missing quote

* Change #[cfg(feature = "alloc")] to #[cfg(any(feature = "std", feature = "alloc"))]
@rekanorman rekanorman deleted the change-dependency branch February 5, 2020 09:13
@rekanorman
Copy link
Contributor Author

Thanks for all your help!
Would you mind publishing a version with these changes to crates.io?

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.

None yet

2 participants