CyclotomicFields / cyclotomic

Implementations of cyclotomic field arithmetic
GNU Lesser General Public License v3.0
6 stars 0 forks source link

anno 2024, it's broken. updating rug to 1.24 doesn't help #5

Closed dimpase closed 5 months ago

dimpase commented 5 months ago

untouched, one gets errors building (old) mpfr in gmp-mpfr. Updating rug to current, one gets the following

   Compiling cyclotomic v0.2.0 (/mnt/opt/work/software/cyclotomic)
error: expected one of `)`, `,`, `.`, `?`, or an operator, found `:`
   --> src/fields/sparse/basis.rs:213:57
    |
213 |                         &((k.clone() * n.clone()).into(): E / p.clone() + i.clone()),
    |                                                         ^ expected one of `)`, `,`, `.`, `?`, or an operator

error: expected one of `)`, `,`, `.`, `?`, or an operator, found `:`
  --> src/fields/sparse/mul.rs:25:68
   |
25 |                 let new_exp = ((exp1.clone() + exp2.clone()).into(): E) % z1.order.clone();
   |                                                                    ^ expected one of `)`, `,`, `.`, `?`, or an operator

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> src/lib.rs:1:1
  |
1 | #![feature(type_ascription)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: unused imports: `BigInt`, `BigRational`, `Signed`, `ToPrimitive`
 --> src/divisors/euclid.rs:3:17
  |
3 | use self::num::{BigInt, BigRational, Integer, One, Signed, ToPrimitive, Zero};
  |                 ^^^^^^  ^^^^^^^^^^^                ^^^^^^  ^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `BigInt`
 --> src/divisors/library_divisors.rs:5:17
  |
5 | use self::num::{BigInt, ToPrimitive, Zero};
  |                 ^^^^^^

warning: unused import: `Z`
 --> src/polynomial/substitute.rs:4:52
  |
4 | use crate::polynomial::polynomial::{Polynomial, Q, Z};
  |                                                    ^

warning: unused import: `num::BigInt`
 --> src/prime_factors/recursive_prime_factorize.rs:6:5
  |
6 | use num::BigInt;
  |     ^^^^^^^^^^^

warning: unused import: `num::Integer`
 --> src/fields/mod.rs:5:5
  |
5 | use num::Integer;
  |     ^^^^^^^^^^^^

warning: unused import: `One`
 --> src/fields/sparse/mod.rs:4:17
  |
4 | use self::num::{One, Zero};
  |                 ^^^

warning: unused import: `num::traits::Inv`
  --> src/fields/sparse/mod.rs:11:5
   |
11 | use num::traits::Inv;
   |     ^^^^^^^^^^^^^^^^

warning: unused import: `HashMap`
  --> src/fields/sparse/mod.rs:14:24
   |
14 | use std::collections::{HashMap, HashSet};
   |                        ^^^^^^^

warning: unused imports: `AddAssign`, `SubAssign`
  --> src/fields/sparse/mod.rs:16:16
   |
16 | use std::ops::{AddAssign, Mul, SubAssign};
   |                ^^^^^^^^^       ^^^^^^^^^

warning: unused import: `ExpCoeffMap`
 --> src/fields/sparse/add.rs:3:29
  |
3 | use crate::fields::sparse::{ExpCoeffMap, Number};
  |                             ^^^^^^^^^^^

warning: unused imports: `Q`, `Z`
 --> src/fields/sparse/add.rs:4:67
  |
4 | use crate::fields::{AdditiveGroupElement, CyclotomicFieldElement, Q, Z};
  |                                                                   ^  ^

warning: unused import: `std::ops::AddAssign`
 --> src/fields/sparse/add.rs:5:5
  |
5 | use std::ops::AddAssign;
  |     ^^^^^^^^^^^^^^^^^^^

warning: unused import: `crate::fields::util::*`
 --> src/fields/sparse/galois.rs:7:5
  |
7 | use crate::fields::util::*;
  |     ^^^^^^^^^^^^^^^^^^^^^^

warning: unused import: `std::convert::TryInto`
 --> src/fields/sparse/galois.rs:9:5
  |
9 | use std::convert::TryInto;
  |     ^^^^^^^^^^^^^^^^^^^^^

warning: unused import: `Q`
 --> src/fields/sparse/mul.rs:4:73
  |
4 | use crate::fields::{CyclotomicFieldElement, MultiplicativeGroupElement, Q};
  |                                                                         ^

warning: unused import: `std::convert::TryInto`
 --> src/fields/sparse/mul.rs:6:5
  |
6 | use std::convert::TryInto;
  |     ^^^^^^^^^^^^^^^^^^^^^

warning: type `Number_i64` should have an upper camel case name
   --> src/fields/sparse/mod.rs:276:6
    |
276 | type Number_i64 = Number<i64, rug::Rational>;
    |      ^^^^^^^^^^ help: convert the identifier to upper camel case: `NumberI64`
    |
    = note: `#[warn(non_camel_case_types)]` on by default

warning: type `Number_Z` should have an upper camel case name
   --> src/fields/sparse/mod.rs:277:6
    |
277 | type Number_Z = Number<Z, rug::Rational>;
    |      ^^^^^^^^ help: convert the identifier to upper camel case: `NumberZ`

warning: unused imports: `One`, `Zero`
 --> src/fields/dense/mod.rs:4:17
  |
4 | use self::num::{One, Zero};
  |                 ^^^  ^^^^

warning: unused import: `num::traits::Inv`
 --> src/fields/dense/mod.rs:9:5
  |
9 | use num::traits::Inv;
  |     ^^^^^^^^^^^^^^^^

warning: unused imports: `AddAssign`, `SubAssign`
  --> src/fields/dense/mod.rs:13:16
   |
13 | use std::ops::{AddAssign, Mul, SubAssign};
   |                ^^^^^^^^^       ^^^^^^^^^

warning: unused import: `crate::fields::*`
  --> src/fields/dense/mod.rs:17:5
   |
17 | use crate::fields::*;
   |     ^^^^^^^^^^^^^^^^

warning: unused import: `crate::fields::exponent::Exponent`
  --> src/fields/dense/mod.rs:22:5
   |
22 | use crate::fields::exponent::Exponent;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: unused import: `Z`
 --> src/fields/dense/add.rs:2:70
  |
2 | use crate::fields::{AdditiveGroupElement, CyclotomicFieldElement, Q, Z};
  |                                                                      ^

warning: unused import: `super::num::Zero`
 --> src/fields/dense/basis.rs:5:5
  |
5 | use super::num::Zero;
  |     ^^^^^^^^^^^^^^^^

warning: unused import: `crate::fields::util::*`
 --> src/fields/dense/galois.rs:5:5
  |
5 | use crate::fields::util::*;
  |     ^^^^^^^^^^^^^^^^^^^^^^

warning: unused import: `super::num::Zero`
 --> src/fields/dense/mul.rs:1:5
  |
1 | use super::num::Zero;
  |     ^^^^^^^^^^^^^^^^

warning: unused import: `crate::fields::util::*`
 --> src/fields/structure/mod.rs:3:5
  |
3 | use crate::fields::util::*;
  |     ^^^^^^^^^^^^^^^^^^^^^^

warning: unused import: `num::Zero`
 --> src/fields/structure/mod.rs:6:5
  |
6 | use num::Zero;
  |     ^^^^^^^^^

warning: unused import: `FieldElement`
 --> src/fields/linear_algebra/mod.rs:1:45
  |
1 | use crate::fields::{CyclotomicFieldElement, FieldElement};
  |                                             ^^^^^^^^^^^^

warning: unused imports: `AddAssign`, `MulAssign`
 --> src/fields/rational.rs:6:16
  |
6 | use std::ops::{AddAssign, MulAssign};
  |                ^^^^^^^^^  ^^^^^^^^^

warning: unused import: `crate::fields::Q`
 --> src/character/mod.rs:4:5
  |
4 | use crate::fields::Q;
  |     ^^^^^^^^^^^^^^^^

warning: `#[macro_use]` only has an effect on `extern crate` and modules
  --> src/fields/sparse/mod.rs:19:1
   |
19 | #[macro_use]
   | ^^^^^^^^^^^^
   |
   = note: `#[warn(unused_attributes)]` on by default

warning: `#[macro_use]` only has an effect on `extern crate` and modules
  --> src/fields/dense/mod.rs:16:1
   |
16 | #[macro_use]
   | ^^^^^^^^^^^^

warning: `#[macro_use]` only has an effect on `extern crate` and modules
  --> src/fields/dense/mod.rs:19:1
   |
19 | #[macro_use]
   | ^^^^^^^^^^^^

error[E0277]: the trait bound `&E: Exponent` is not satisfied
   --> src/fields/sparse/basis.rs:212:35
    |
212 |                     let new_exp = Exponent::math_mod(
    |                                   ^^^^^^^^^^^^^^^^^^ the trait `Exponent` is not implemented for `&E`
    |
help: consider borrowing here
    |
212 |                     let new_exp = &Exponent::math_mod(
    |                                   +

error[E0277]: `E` cannot be shared between threads safely
   --> src/fields/sparse/basis.rs:212:35
    |
212 |                     let new_exp = Exponent::math_mod(
    |                                   ^^^^^^^^^^^^^^^^^^ `E` cannot be shared between threads safely
    |
    = note: required for `&E` to implement `Send`
note: required by a bound in `Exponent::math_mod`
   --> src/fields/exponent.rs:24:7
    |
24  |     + Send
    |       ^^^^ required by this bound in `Exponent::math_mod`
...
75  |     fn math_mod(x: &Self, n: &Self) -> Self {
    |        -------- required by a bound in this associated function
help: consider further restricting this bound
    |
120 |     E: Exponent + std::marker::Sync,
    |                 +++++++++++++++++++

error[E0308]: mismatched types
  --> src/fields/rational.rs:31:17
   |
31 |         *self = self.as_neg().clone();
   |         -----   ^^^^^^^^^^^^^^^^^^^^^ expected `Rational`, found `BorrowRational<'_>`
   |         |
   |         expected due to the type of this binding

warning: unused import: `Div`
 --> src/divisors/euclid.rs:5:16
  |
5 | use std::ops::{Div, Sub};
  |                ^^^

warning: unused import: `Sub`
 --> src/divisors/euclid.rs:5:21
  |
5 | use std::ops::{Div, Sub};
  |                     ^^^

warning: unused import: `Zero`
 --> src/fields/sparse/mod.rs:4:22
  |
4 | use self::num::{One, Zero};
  |                      ^^^^

warning: unused import: `Mul`
  --> src/fields/sparse/mod.rs:16:27
   |
16 | use std::ops::{AddAssign, Mul, SubAssign};
   |                           ^^^

warning: unused import: `crate::fields::MultiplicativeGroupElement`
 --> src/fields/dense/mod.rs:6:5
  |
6 | use crate::fields::MultiplicativeGroupElement;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: unused import: `Mul`
  --> src/fields/dense/mod.rs:13:27
   |
13 | use std::ops::{AddAssign, Mul, SubAssign};
   |                           ^^^

warning: unused import: `crate::fields`
  --> src/fields/sparse/mod.rs:20:5
   |
20 | use crate::fields::*;
   |     ^^^^^^^^^^^^^

warning: unused import: `Neg`
 --> src/polynomial/subtract.rs:1:27
  |
1 | use std::ops::{AddAssign, Neg, Sub, SubAssign};
  |                           ^^^

warning: unused import: `super::num::Zero`
 --> src/fields/sparse/mul.rs:1:5
  |
1 | use super::num::Zero;
  |     ^^^^^^^^^^^^^^^^

warning: unused import: `super::num::Zero`
 --> src/fields/sparse/basis.rs:5:5
  |
5 | use super::num::Zero;
  |     ^^^^^^^^^^^^^^^^

warning: unused import: `std::ops::Mul`
  --> src/fields/sparse/basis.rs:12:5
   |
12 | use std::ops::Mul;
   |     ^^^^^^^^^^^^^

warning: unused import: `crate::fields::MultiplicativeGroupElement`
 --> src/fields/sparse/mod.rs:8:5
  |
8 | use crate::fields::MultiplicativeGroupElement;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Some errors have detailed explanations: E0277, E0308, E0554.
For more information about an error, try `rustc --explain E0277`.
warning: `cyclotomic` (lib) generated 47 warnings
error: could not compile `cyclotomic` (lib) due to 6 previous errors; 47 warnings emitted
warning: build failed, waiting for other jobs to finish...

this is with rustc/cargo 1.73.0

dimpase commented 5 months ago

@kaashif - is this abandoned?

kaashif commented 5 months ago

Yes, this is abandoned! But I'll fix this anyway. I really never expected anyone to actually try to build this - this repo was always built using nightly Rust and evidently I was relying on something that eventually changed.

kaashif commented 5 months ago

I am now able to build and run tests using nightly after fixing those errors:

$ cargo +nightly test
...
test result: ok. 92 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.49s
...

The reason it still "needs" nightly is that it uses black_box which hadn't been stabilised at the time of writing. It has been stabilised now, under std::hint: https://doc.rust-lang.org/std/hint/fn.black_box.html.

I should update this to use stable APIs only (which I think is possible) so this works on stable and thus won't break in future.

kaashif commented 5 months ago

Removing the unstable API usage was actually really easy, this now builds with stable Rust too:

$ cargo test
...
test result: ok. 92 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.40s
...
kaashif commented 5 months ago

I added CI to ensure this continues to build with stable Rust going forward: https://github.com/CyclotomicFields/cyclotomic/actions/runs/8494108062/job/23268859239