-
Notifications
You must be signed in to change notification settings - Fork 126
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
Improve use of unsafe Rust in arena.rs (#2391) #2393
Conversation
Several new style check warnings: warning: this `if` statement can be collapsed --> src/machine/system_calls.rs:431:17 | 431 | / if heap[h].get_tag() == HeapCellValueTag::PStrOffset { 432 | | if heap[h_offset].get_tag() == HeapCellValueTag::CStr { 433 | | return if pstr_chars < max_steps { 434 | | CycleSearchResult::ProperList(pstr_chars + 1) ... | 439 | | } 440 | | } | |_________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if = note: `#[warn(clippy::collapsible_if)]` on by default help: collapse nested if block | 431 ~ if heap[h].get_tag() == HeapCellValueTag::PStrOffset && heap[h_offset].get_tag() == HeapCellValueTag::CStr { 432 + return if pstr_chars < max_steps { 433 + CycleSearchResult::ProperList(pstr_chars + 1) 434 + } else { 435 + let offset = max_steps as usize + n; 436 + CycleSearchResult::PStrLocation(max_steps, h_offset, offset) 437 + } 438 + } | error: read amount is not handled --> src/parser/char_reader.rs:332:13 | 332 | (&self.buf[self.pos..]).read_vectored(bufs)? | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_io_amount = note: `#[deny(clippy::unused_io_amount)]` on by default warning: match expression looks like `matches!` macro --> src/machine/machine_indices.rs:301:56 | 301 | meta_specs.iter().find(|meta_spec| match meta_spec { | ________________________________________________________^ 302 | | MetaSpec::Colon | MetaSpec::RequiresExpansionWithArgument(_) => true, 303 | | _ => false, 304 | | }) | |_____________________^ help: try: `matches!(meta_spec, MetaSpec::Colon | MetaSpec::RequiresExpansionWithArgument(_))` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro = note: `#[warn(clippy::match_like_matches_macro)]` on by default warning: casting to the same type is unnecessary (`usize` -> `usize`) --> src/machine/system_calls.rs:436:42 | 436 | ... let offset = max_steps as usize + n; | ^^^^^^^^^^^^^^^^^^ help: try: `max_steps` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast = note: `#[warn(clippy::unnecessary_cast)]` on by default |
The test build for ubuntu-22.04 with Rust 1.70 now fails, I think this target should now be removed since Rust 1.77 is required? Run cargo build --all-targets --target x86_64-unknown-linux-gnu --verbose error: package `scryer-prolog v0.9.4 (/home/runner/work/scryer-prolog/scryer-prolog)` cannot be built because it requires rustc 1.77 or newer, while the currently active rustc version is 1.70.0 |
@@ -47,7 +47,6 @@ jobs: | |||
# FIXME(issue #2138): run wasm tests, failing to run since https://github.com/mthom/scryer-prolog/pull/2137 removed wasm-pack | |||
- { os: ubuntu-22.04, rust-version: nightly, target: 'wasm32-unknown-unknown', publish: true, args: '--no-default-features' , test-args: '--no-run --no-default-features' } | |||
# rust versions | |||
- { os: ubuntu-22.04, rust-version: "1.70", target: 'x86_64-unknown-linux-gnu'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this job should have been changed to use 1.77 instead of being removed. This job is here to test that the version declared in the Cargo.toml still works, which I think is what to # rust version
comment directly above it tried to convey.
was removed in mthom#2391 instead of being updated, see - mthom#2393 (comment) and - mthom@79bc2d9#commitcomment-141790142
was removed in mthom#2393 instead of being updated, see - mthom#2393 (comment) and - mthom@79bc2d9#commitcomment-141790142
The use of unsafe Rust is revised in arena.rs to answer some of the criticisms made in #2391, particularly regarding the misaligned allocation of some stream types. Explicit use of
alloc
is removed in favor ofBox
.TypedAllocSlab<Payload>
is a type parameterized template overAllocSlab
used to allow rustc to get value allocation right. As well, some new macros (likemem::offset_of!
) are used to calculate byte offsets into structs. This requires bumping the Rust version in Cargo.toml to 1.77.