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

Compiler error when combined with cfg-if in particular ways. #1156

Closed
jonhoo opened this issue May 26, 2020 · 5 comments
Closed

Compiler error when combined with cfg-if in particular ways. #1156

jonhoo opened this issue May 26, 2020 · 5 comments

Comments

@jonhoo
Copy link

jonhoo commented May 26, 2020

Prerequisites

  • Rust version : rustc 1.43.1 (8d69840ab 2020-05-04)
  • nom version : 5.1.1

Test case

This is a manifestation of Alexhuszagh/rust-lexical#38, and I gave a bit of context in #1115 (comment). The issue specifically is that nom 5 depends on lexical-core 0.6, which now pins cfg-if 0.1.9. And cfg-if fails to compile all sorts valid Rust code on newer Rust versions (this is fixed in cfg-if 0.1.10). See the lexical-core issue linked above for more details.

Normally, this would be none of nom's business (since nom is doing nothing wrong here). However, since the bump from lexical-core 0.6 to lexical-core 0.7 presented no API changes, as @shepmaster pointed out in #1115, it should be possible to issue a new minor release of nom 5 that allows lexical-core 0.7 (basically by backporting @shepmaster's PR).

The error cases are pretty bad:

Example test case 1:

[dependencies]
nom = "5"
time = "0.2"
fn main() {}

Note that this applies if nom 5 and time 0.2 every appear together in any dependency graph.

Example test case 2:

[dependencies]
nom = "5"
cfg-if = "0.1"

All sorts of different things fail, but here's an example:

fn main() {
    cfg_if::cfg_if! {
        if #[cfg(unix)] {
            fn bar() {}
            let tm = ();
        }
    }
}
@Geal
Copy link
Collaborator

Geal commented Oct 25, 2021

closing as it's been fixed by moving to minimal-lexical

@Geal Geal closed this as completed Oct 25, 2021
@jonhoo
Copy link
Author

jonhoo commented Oct 26, 2021

Note that this was specifically about backporting the change to nom5. Was the move to minimal-lexical also done for 5.x?

@Stargateur
Copy link
Contributor

Stargateur commented Oct 26, 2021

@jonhoo Have you try rename ?

[dependencies.cfg_if_1]
package = "cfg-if"
version = "0.1"

Or a patch ?

@Geal
Copy link
Collaborator

Geal commented Nov 4, 2021

@jonhoo nom 5.1.2 allows lexical-core 0.7: https://crates.io/crates/nom/5.1.2/dependencies since commit e73a4d4

is there still an issue with it?

@jonhoo
Copy link
Author

jonhoo commented Nov 6, 2021

Ah, sorry, you're entirely right ­— I missed that change! Sorry for the noise :)

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

No branches or pull requests

3 participants