Repository: rust-bakery/nom (language: rust)

Issue:
Fails to compile with minimal dependency versions (due to old lexical-core)
## TL;DR
`lexical-core` dependency should be bumped to `^0.7.5`.

(Strictly, it is enough if `^0.7.5 OR ^0.6.4` can be specified, but it doesn't seem to be possible with the current Cargo.toml format.)

## Prerequisites

- Rust version : `rustc 1.51.0 (2fd73fabe 2021-03-23)`
- nom version : `6.1.2` (released on 2021-02-15)
- nom compilation features used: any combination with `lexical` enabled (e.g. `default-features = false, features = ["lexical"]`)

## Test case

While I'm not sure why, this problem cannot be reproduced by tests inside the nom repository.
In order to reproduce, you have to set up another tiny crate, which depends on nom.

```toml
# Cargo.toml
[package]
name = "nom-mindep"
version = "0.0.0"
edition = "2018"

[dependencies]
nom = { version = "6.1.2", default-features = false, features = ["lexical"] }
```
(Actually, `lexical-core = "=0.6.2"` or `lexical-core = "=0.7.4"` seem to cause the same problem.)

```rust
// lib.rs, empty.
```

Then, run `cargo +nightly update -Z minimal-versions ; cargo check`.
Note that `cargo +nightly update -Z minimal-versions` only regenerates `Cargo.lock` with **old** dependency verisons as possible, in contrast to `cargo update` (which regenerates `Cargo.lock` with **new** dependency verisons as possible).
Once the lock file is regenerated, `cargo check` or normal build can be done by stable rustc.

<details>
<summary>Compile error message (long)</summary>

```
$ cargo +nightly update -Z minimal-versions ; cargo check
    Updating crates.io index
    Checking lexical-core v0.6.0
error: unexpected end of macro invocation
   --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/lib.rs:166:2
    |
166 | }}  // cfg_if
    |  ^ missing tokens in macro arguments

error: unexpected end of macro invocation
   --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/lib.rs:183:2
    |
183 | }}  // cfg_if
    |  ^ missing tokens in macro arguments

error: unexpected end of macro invocation
   --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/lib.rs:207:2
    |
207 | }}  // cfg_if
    |  ^ missing tokens in macro arguments

error: unexpected end of macro invocation
   --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/util/cast.rs:366:2
    |
366 | }}  // cfg_if
    |  ^ missing tokens in macro arguments

error: unexpected end of macro invocation
   --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/util/config.rs:408:2
    |
408 | }}  // cfg_if
    |  ^ missing tokens in macro arguments

error: unexpected end of macro invocation
  --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/util/table.rs:35:2
   |
35 | }}  // cfg_if
   |  ^ missing tokens in macro arguments

error: unexpected end of macro invocation
  --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/util/table.rs:73:2
   |
73 | }}  // cfg_if
   |  ^ missing tokens in macro arguments

error: unexpected end of macro invocation
    --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/util/table.rs:3227:2
     |
3227 | }}   // cfg_if
     |  ^ missing tokens in macro arguments

error: unexpected end of macro invocation
  --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/atof/algorithm/state.rs:12:2
   |
12 | }}  // cfg_if
   |  ^ missing tokens in macro arguments

error: unexpected end of macro invocation
  --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/atof/algorithm/mod.rs:35:2
   |
35 | }}  // cfg_if
   |  ^ missing tokens in macro arguments

error: unexpected end of macro invocation
   --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/itoa/decimal.rs:760:2
    |
760 | }} // cfg_if
    |  ^ missing tokens in macro arguments

error[E0432]: unresolved import `super::alias`
  --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/atof/algorithm/correct.rs:10:12
   |
10 | use super::alias::*;
   |            ^^^^^ could not find `alias` in `super`

error[E0432]: unresolved import `super::bhcomp`
  --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/atof/algorithm/correct.rs:11:5
   |
11 | use super::bhcomp;
   |     ^^^^^^^^^^^^^ no `bhcomp` in `atof::algorithm`

error[E0432]: unresolved import `super::cached`
  --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/atof/algorithm/correct.rs:12:12
   |
12 | use super::cached::ModeratePathCache;
   |            ^^^^^^ could not find `cached` in `super`

error[E0432]: unresolved import `super::errors`
  --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/atof/algorithm/correct.rs:13:12
   |
13 | use super::errors::FloatErrors;
   |            ^^^^^^ could not find `errors` in `super`

error[E0432]: unresolved import `super::exponent`
  --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/atof/algorithm/correct.rs:14:12
   |
14 | use super::exponent::*;
   |            ^^^^^^^^ could not find `exponent` in `super`

error[E0432]: unresolved import `super::small_powers`
  --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/atof/algorithm/correct.rs:16:12
   |
16 | use super::small_powers::get_small_powers_64;
   |            ^^^^^^^^^^^^ could not find `small_powers` in `super`

error[E0432]: unresolved import `ryu`
 --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/ftoa/ryu.rs:3:5
  |
3 | use ryu::raw;
  |     ^^^ help: a similar path exists: `super::ryu`

error[E0425]: cannot find value `USIZE_FORMATTED_SIZE` in this scope
   --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/util/num.rs:53:11
    |
53  |     usize USIZE_FORMATTED_SIZE USIZE_FORMATTED_SIZE_DECIMAL ;
    |           ^^^^^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `I16_FORMATTED_SIZE`
    |
   ::: /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/util/config.rs:379:5
    |
379 |     pub(crate) const I16_FORMATTED_SIZE: usize = I16_FORMATTED_SIZE_DECIMAL;
    |     ------------------------------------------------------------------------ similarly named constant `I16_FORMATTED_SIZE` defined here

error[E0425]: cannot find value `USIZE_FORMATTED_SIZE_DECIMAL` in this scope
   --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/util/num.rs:53:32
    |
53  |     usize USIZE_FORMATTED_SIZE USIZE_FORMATTED_SIZE_DECIMAL ;
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `I16_FORMATTED_SIZE_DECIMAL`
    |
   ::: /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/util/config.rs:344:1
    |
344 | pub(crate) const I16_FORMATTED_SIZE_DECIMAL: usize = 6;
    | ------------------------------------------------------- similarly named constant `I16_FORMATTED_SIZE_DECIMAL` defined here

error[E0425]: cannot find value `ISIZE_FORMATTED_SIZE` in this scope
   --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/util/num.rs:58:11
    |
58  |     isize ISIZE_FORMATTED_SIZE ISIZE_FORMATTED_SIZE_DECIMAL ;
    |           ^^^^^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `I128_FORMATTED_SIZE`
    |
   ::: /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/util/config.rs:388:22
    |
388 |     #[cfg(has_i128)] pub(crate) const I128_FORMATTED_SIZE: usize = I128_FORMATTED_SIZE_DECIMAL;
    |                      -------------------------------------------------------------------------- similarly named constant `I128_FORMATTED_SIZE` defined here

error[E0425]: cannot find value `ISIZE_FORMATTED_SIZE_DECIMAL` in this scope
   --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/util/num.rs:58:32
    |
58  |     isize ISIZE_FORMATTED_SIZE ISIZE_FORMATTED_SIZE_DECIMAL ;
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `I128_FORMATTED_SIZE_DECIMAL`
    |
   ::: /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/util/config.rs:353:18
    |
353 | #[cfg(has_i128)] pub(crate) const I128_FORMATTED_SIZE_DECIMAL: usize = 40;
    |                  --------------------------------------------------------- similarly named constant `I128_FORMATTED_SIZE_DECIMAL` defined here

error[E0405]: cannot find trait `TablePower` in this scope
  --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/util/pow.rs:17:63
   |
17 |     pub(crate) trait StablePowerImpl: Float + ExactExponent + TablePower {
   |                                                               ^^^^^^^^^^ help: a trait with a similar name exists: `StablePower`
...
28 | pub(crate) trait StablePower: private::StablePowerImpl {
   | ------------------------------------------------------ similarly named trait `StablePower` defined here

error[E0412]: cannot find type `SliceIter` in this scope
   --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/atof/algorithm/state.rs:207:42
    |
207 |     pub(super) fn integer_iter(&self) -> SliceIter<u8> {
    |                                          ^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `SliceIter` in this scope
   --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/atof/algorithm/state.rs:225:43
    |
225 |     pub(super) fn fraction_iter(&self) -> SliceIter<u8> {
    |                                           ^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `ChainedSliceIter` in this scope
   --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/atof/algorithm/state.rs:245:43
    |
245 |     pub(super) fn mantissa_iter(&self) -> ChainedSliceIter<u8> {
    |                                           ^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `mantissa_exponent` in this scope
   --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/atof/algorithm/state.rs:258:9
    |
258 |         mantissa_exponent(self.raw_exponent, self.fraction_len(), self.truncated_digits())
    |         ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `scientific_exponent` in this scope
   --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/atof/algorithm/state.rs:264:9
    |
264 |         scientific_exponent(self.raw_exponent, self.integer_digits(), self.digits_start)
    |         ^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0405]: cannot find trait `FloatType` in this scope
  --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/atof/algorithm/correct.rs:41:14
   |
41 |     where F: FloatType
   |              ^^^^^^^^^ not found in this scope

error[E0405]: cannot find trait `FloatType` in this scope
   --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/atof/algorithm/correct.rs:268:14
    |
268 |     where F: FloatType
    |              ^^^^^^^^^ not found in this scope

error[E0405]: cannot find trait `FloatType` in this scope
   --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/atof/algorithm/correct.rs:295:14
    |
295 |     where F: FloatType
    |              ^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `mantissa_exponent` in this scope
   --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/atof/algorithm/correct.rs:310:24
    |
310 |         let mant_exp = mantissa_exponent(state.exponent, state.fraction.len(), 0);
    |                        ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0405]: cannot find trait `FloatType` in this scope
   --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/atof/algorithm/correct.rs:410:14
    |
410 |     where F: FloatType
    |              ^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `DIGIT_TO_BASE10_SQUARED` in this scope
   --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/itoa/decimal.rs:129:23
    |
129 | const TABLE: &[u8] = &DIGIT_TO_BASE10_SQUARED;
    |                       ^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `usizetoa` in this scope
   --> /home/lo48576/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.6.0/src/itoa/decimal.rs:786:22
    |
776 |                 $cb(self, buffer)
    |                 ----------------- help: try calling `usizetoa` as a method: `self.usizetoa(buffer)`
...
786 | decimal_impl!(usize, usizetoa);
    |                      ^^^^^^^^

error: aborting due to 35 previous errors

Some errors have detailed explanations: E0405, E0412, E0425, E0432.
For more information about an error, try `rustc --explain E0405`.
error: could not compile `lexical-core`

To learn more, run the command again with --verbose.
$
```

</details>

## Cause

Currently, nom depends on lexical-core crate `>= 0.6, < 0.8`, but this is problematic.

https://github.com/Geal/nom/blob/d1aff18e3c6b03bf3a1b6ca2826417c48995f4c1/Cargo.toml#L62

This problem is fixed by lexical-core `^0.6.4` **OR** `^0.7.5`, so nom should pull only these newer versions.
However, it seems that cargo does not allow such "OR" condition.
In order to avoid this problem (i.e. to stop allowing invalid (non-compilable) dependency to be accepted), nom should depend on lexical-core `^0.7.5`.


Discussion / hints:
I'm not sure #1156 is related, but older `lexical-core` seems to have caused other difficulties...

Fix patch:
diff --git a/Cargo.toml b/Cargo.toml
index 346a5a880..55ef40ae4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -59,7 +59,7 @@ version = "^2.0"
 default-features = false
 
 [dependencies.lexical-core]
-version = ">= 0.6, < 0.8"
+version = "^0.7.5"
 optional = true
 
 [dev-dependencies]


Test patch: