nom icon indicating copy to clipboard operation
nom copied to clipboard

`tuple_parser` and `error_position` not found in scope

Open rbalicki2 opened this issue 8 years ago • 6 comments

Prerequisites

Here are a few things you should provide to help me understand the issue:

  • Rust version : rustc 1.32.0-nightly (6b9b97bd9 2018-11-15)
  • nom version : 4.1.1
  • nom compilation features used: none

Test case

If you are using Rust 2018 edition (or otherwise import nom without macro_use), you can still import the tuple! etc parsers directly. However, they do not work, because they reference other macros.

I've noticed it with tuple_parser and error_position, although presumably it happens with others.

It is obviously not a problem for me to import these separately, however, it would be more elegant if I could import them through a prelude or if the macros were referenced with their full 2018 path. (That might break pre-2018 code, though, so... /shrug)

Thanks for the great library!

rbalicki2 avatar Nov 18 '18 22:11 rbalicki2

I feel a need to clarify a little bit. Changing to edition 2018 should not break anything (whether in edition 2018 or not), because that syntax processing is applied on a crate-by-crate basis. However, as with all compiler and language features, it does bump the minimum rustc version to one which supports the edition (1.31 will be the first such stable version, to be released in early December).

It's important to be clear about this, though, because these kinds of compatibility guarantees are important to the rust team. If something isn't importing properly, it may be a compiler bug to look at.

With all that said, I'm not entirely clear on what exact use statements you're writing that don't work, and what use statements you're writing that do. The bulk of the module system changes are not Rust 2018 features. They were stabilized for the entire ecosystem with Rust 1.30, including the changes to whether you need :: before crate names and removing the need for #[macro_use] in most cases.

If you could perhaps show us (rather than describe to us) the code which does and does not work, that would be really helpful in deciding what we can do to solve the issue.

Zarenor avatar Nov 19 '18 21:11 Zarenor

You can check out https://github.com/rbalicki2/smithy/tree/57028760fb487396b7c4593dbdfbab1b4c241415 (please use that commit, because this is a WIP and at any point in time, master may be broken 😄). You can run the tests with make watch-test-nc in the root of the crate.

In packages/smd_macro/src/parsers/core.rs, we bring nom::error_position and nom::tuple_parser into scope, but do not use these. However, if we don't bring them into scope, the test fails, complaining that the macros aren't in scope. I believe this has to do with Rust 2018, as mentioned above.

rbalicki2 avatar Dec 02 '18 16:12 rbalicki2

the issue here is that some nom macros internally use other macros. With previous Rust crates, all macros are brought into scope, so it's fine, but with Rust 2018, they are imported like functions, so it's not transparent anymore. I'm planning to do a new major version of nom to migrate to 2018 edition, that will fix the issue.

Geal avatar Dec 14 '18 14:12 Geal

@Geal, I wonder, doesn't e3fa8e71279738e03ac057e8e426eed416e00b2e fix that? It only needs to be released, but using nom = { git = "https://github.com/Geal/nom.git" } in my project introduces "unused import" warnings (which are a good thing, as I hackily used unnecessary macros so that it would work).

sugar700 avatar Dec 31 '18 12:12 sugar700

It does, but I have not made a new release yet

On Mon, Dec 31, 2018, 13:49 Konrad Borowski <[email protected] wrote:

I wonder, doesn't e3fa8e7 https://github.com/Geal/nom/commit/e3fa8e71279738e03ac057e8e426eed416e00b2e fix that?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Geal/nom/issues/850#issuecomment-450642345, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHSACZoDZfZbj1VkBdon96xHW59ilstks5u-gfigaJpZM4YoLGn .

Geal avatar Dec 31 '18 14:12 Geal

this should be fixed in nom 4.2.2

Geal avatar Mar 04 '19 09:03 Geal