mthom / scryer-prolog

A modern Prolog implementation written mostly in Rust.
BSD 3-Clause "New" or "Revised" License
2.02k stars 118 forks source link

Error E0277 compiling sodiumoxide while building dev branch #822

Open dcnorris opened 3 years ago

dcnorris commented 3 years ago
david@tarnhelm scryer-prolog % git status
On branch rebis-dev
Your branch is up to date with 'origin/rebis-dev'.

nothing to commit, working tree clean
david@tarnhelm scryer-prolog % rustup check 
stable-x86_64-apple-darwin - Up to date : 1.50.0 (cb75ad5db 2021-02-10)
david@tarnhelm scryer-prolog % cargo build --no-default-features --features num
   Compiling libc v0.2.85
   Compiling autocfg v1.0.1
   [ etc. ]
   Compiling markup5ever v0.8.1
   Compiling select v0.4.3
   Compiling sodiumoxide v0.2.6
error[E0277]: can't compare `num_rug_adapter::Integer` with `usize`
   --> src/machine/loader.rs:998:56
    |
998 |             Ok(Number::Integer(n)) if &*n >= &0 && &*n <= &MAX_ARITY => Ok(n.to_usize().unwrap()),
    |                                                        ^^ no implementation for `num_rug_adapter::Integer < usize` and `num_rug_adapter::Integer > usize`
    |
    = help: the trait `PartialOrd<usize>` is not implemented for `num_rug_adapter::Integer`
    = note: required because of the requirements on the impl of `PartialOrd<&usize>` for `&num_rug_adapter::Integer`

error[E0277]: can't compare `num_rug_adapter::Integer` with `usize`
   --> src/machine/machine_state.rs:576:56
    |
576 |             Ok(Number::Integer(n)) if &*n >= &0 && &*n <= &MAX_ARITY => n.to_usize().unwrap(),
    |                                                        ^^ no implementation for `num_rug_adapter::Integer < usize` and `num_rug_adapter::Integer > usize`
    |
    = help: the trait `PartialOrd<usize>` is not implemented for `num_rug_adapter::Integer`
    = note: required because of the requirements on the impl of `PartialOrd<&usize>` for `&num_rug_adapter::Integer`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
error: could not compile `scryer-prolog`

To learn more, run the command again with --verbose.
david@tarnhelm scryer-prolog %

cc @malbarbo

dcnorris commented 3 years ago

(I can confirm, however, that build works on master branch.)

mthom commented 3 years ago

This now works in rebis-dev also. I internalized the num-rug-adapter crate, similarly to what we now do with prolog-parser.

dcnorris commented 3 years ago

I can confirm this works, including with --release.

I do note however a much worsened performance on a DCG phrase_from_file/2 application (top is with this recent build):

%?- once(time(translate_tables)).
%@ Loading studies...
%@ Loading design_groups...
%@ Loading interventions...
%@ Loading intervention_aliases...
%@    % CPU time: 140.769 seconds
%@    % CPU time: 140.776 seconds
%@    true.
%@ Loading studies...
%@ Loading design_groups...
%@ Loading interventions...
%@ Loading intervention_aliases...
%@    % CPU time: 15.588 seconds
%@    % CPU time: 15.633 seconds
%@    true.
dcnorris commented 3 years ago

I can no longer reproduce the shorter timing, even by systematically checking out versions of the repo back to early Dec 2020. (I have not tried reverting Rust libs, however.) Glad to see this issue closed.