Issue 3223: First phase of migration to Rust Edition 2024

Update cargo dependencies
Apply cargo fix --edition
Change cargo.toml edition property to `2024`

^ Conflicts:
^	Cargo.lock
^	src/ffi.rs

^ Conflicts:
^	src/offset_table.rs
^	src/raw_block.rs
This commit is contained in:
Alexander McLin
2026-04-02 15:55:45 -04:00
parent daaab1cb37
commit efbddeaeee
32 changed files with 389 additions and 395 deletions

144
Cargo.lock generated
View File

@@ -204,9 +204,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.11.1"
version = "2.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3"
checksum = "84d7ced0ae9557296835c32bf1b1e02b44c746701f898460fb000d7eaa84f00a"
[[package]]
name = "bitvec"
@@ -279,12 +279,12 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
[[package]]
name = "cc"
version = "1.2.62"
version = "1.2.63"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1dce859f0832a7d088c4f1119888ab94ef4b5d6795d1ce05afb7fe159d79f98"
checksum = "556e016178bb5662a08681bbe0f00f8e17631781a4dfc8c45e466e4b185ec27f"
dependencies = [
"find-msvc-tools",
"shlex",
"shlex 2.0.1",
]
[[package]]
@@ -525,7 +525,7 @@ version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6"
dependencies = [
"bitflags 2.11.1",
"bitflags 2.12.1",
"crossterm_winapi",
"mio",
"parking_lot",
@@ -613,9 +613,9 @@ checksum = "a74858bcfe44b22016cb49337d7b6f04618c58e5dbfdef61b06b8c434324a0bc"
[[package]]
name = "dashu"
version = "0.4.2"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85b3e5ac1e23ff1995ef05b912e2b012a8784506987a2651552db2c73fb3d7e0"
checksum = "dc8621924e1a1d2e19f3ea55c7b553a90b1f63a0a5c0a3f5b44afce841d08aa0"
dependencies = [
"dashu-base",
"dashu-float",
@@ -627,15 +627,15 @@ dependencies = [
[[package]]
name = "dashu-base"
version = "0.4.1"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0b80bf6b85aa68c58ffea2ddb040109943049ce3fbdf4385d0380aef08ef289"
checksum = "fab3f0756c8585395280bd81b384cd28bbd66d6b00e66124ecfd1f644938b38c"
[[package]]
name = "dashu-float"
version = "0.4.3"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85078445a8dbd2e1bd21f04a816f352db8d333643f0c9b78ca7c3d1df71063e7"
checksum = "85d913daa4f8193f709a2b5cc87a8be649dac8d816f7f049fb0a38e8b9e5d23b"
dependencies = [
"dashu-base",
"dashu-int",
@@ -648,9 +648,9 @@ dependencies = [
[[package]]
name = "dashu-int"
version = "0.4.1"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee99d08031ca34a4d044efbbb21dff9b8c54bb9d8c82a189187c0651ffdb9fbf"
checksum = "d6a93d93dc2aca9a071e6ecb2af883441e8b34357a1037bc536e1c52b0d3c713"
dependencies = [
"cfg-if",
"dashu-base",
@@ -663,15 +663,15 @@ dependencies = [
[[package]]
name = "dashu-macros"
version = "0.4.1"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93381c3ef6366766f6e9ed9cf09e4ef9dec69499baf04f0c60e70d653cf0ab10"
checksum = "a89dbf51c81b22b30a0a30a4fcff84c4af8bdcd7a6159a556007b0b2dabc1e79"
dependencies = [
"dashu-base",
"dashu-float",
"dashu-int",
"dashu-ratio",
"paste",
"pastey",
"proc-macro2",
"quote",
"rustversion",
@@ -679,9 +679,9 @@ dependencies = [
[[package]]
name = "dashu-ratio"
version = "0.4.1"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47e33b04dd7ce1ccf8a02a69d3419e354f2bbfdf4eb911a0b7465487248764c9"
checksum = "b689daf8ea2221461973a29752a648e2971a377acefbf20df88e063f491032c7"
dependencies = [
"dashu-base",
"dashu-float",
@@ -758,7 +758,7 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38"
dependencies = [
"bitflags 2.11.1",
"bitflags 2.12.1",
"block2",
"libc",
"objc2",
@@ -766,9 +766,9 @@ dependencies = [
[[package]]
name = "displaydoc"
version = "0.2.5"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
checksum = "1ac70aa55017e108007fbaf5aa0f54b021c98f92ff8af59d42eda9da96e3dd4f"
dependencies = [
"proc-macro2",
"quote",
@@ -1711,9 +1711,9 @@ dependencies = [
[[package]]
name = "libredox"
version = "0.1.16"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e02f3bb43d335493c96bf3fd3a321600bf6bd07ed34bc64118e9293bdffea46c"
checksum = "f02ab6bace2054fb888a3c16f990117b579d14a3088e472d63c6011fa185c9d3"
dependencies = [
"libc",
]
@@ -1747,9 +1747,9 @@ dependencies = [
[[package]]
name = "log"
version = "0.4.30"
version = "0.4.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "616ec5685824bcc94416c6d4a7a446eea774a31efd7062c8480ba6fd06d7a6e5"
checksum = "113b30b4cd05f7c06868fdb2854f66a7b9fece9a48425351cd532e810d74024f"
[[package]]
name = "mac"
@@ -1790,9 +1790,9 @@ dependencies = [
[[package]]
name = "memchr"
version = "2.8.0"
version = "2.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
checksum = "6b947ae49db0d222b1dbc6b113ce7248a3fc3a6ca21b696717bfc000ba4484d8"
[[package]]
name = "memmap2"
@@ -1830,9 +1830,9 @@ dependencies = [
[[package]]
name = "mio"
version = "1.2.0"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50b7e5b27aa02a74bac8c3f23f448f8d87ff11f92d3aac1a6ed369ee08cc56c1"
checksum = "02bd0af71c67b473010cbbc60715ee815645a4dc942899111f494b4b737d6fda"
dependencies = [
"libc",
"log",
@@ -1928,7 +1928,7 @@ version = "0.31.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d"
dependencies = [
"bitflags 2.11.1",
"bitflags 2.12.1",
"cfg-if",
"cfg_aliases",
"libc",
@@ -2031,7 +2031,7 @@ version = "0.10.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a45fa2aa886c42762255da344f0a0d313e254066c46aad76f300c3d3da62d967"
dependencies = [
"bitflags 2.11.1",
"bitflags 2.12.1",
"cfg-if",
"foreign-types",
"libc",
@@ -2135,10 +2135,10 @@ dependencies = [
]
[[package]]
name = "paste"
version = "1.0.15"
name = "pastey"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4"
[[package]]
name = "percent-encoding"
@@ -2472,7 +2472,7 @@ version = "0.5.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
dependencies = [
"bitflags 2.11.1",
"bitflags 2.12.1",
]
[[package]]
@@ -2614,7 +2614,7 @@ version = "0.38.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
dependencies = [
"bitflags 2.11.1",
"bitflags 2.12.1",
"errno",
"libc",
"linux-raw-sys 0.4.15",
@@ -2627,7 +2627,7 @@ version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190"
dependencies = [
"bitflags 2.11.1",
"bitflags 2.12.1",
"errno",
"libc",
"linux-raw-sys 0.12.1",
@@ -2698,7 +2698,7 @@ version = "18.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a990b25f351b25139ddc7f21ee3f6f56f86d6846b74ac8fad3a719a287cd4a0"
dependencies = [
"bitflags 2.11.1",
"bitflags 2.12.1",
"cfg-if",
"clipboard-win",
"home",
@@ -2728,15 +2728,6 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "scc"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46e6f046b7fef48e2660c57ed794263155d713de679057f2d0c169bfc6e756cc"
dependencies = [
"sdd",
]
[[package]]
name = "schannel"
version = "0.1.29"
@@ -2848,19 +2839,13 @@ dependencies = [
"web-sys",
]
[[package]]
name = "sdd"
version = "3.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "490dcfcbfef26be6800d11870ff2df8774fa6e86d047e3e8c8a76b25655e41ca"
[[package]]
name = "security-framework"
version = "3.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d"
dependencies = [
"bitflags 2.11.1",
"bitflags 2.12.1",
"core-foundation 0.10.1",
"core-foundation-sys",
"libc",
@@ -2883,7 +2868,7 @@ version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd568a4c9bb598e291a08244a5c1f5a8a6650bee243b5b0f8dbb3d9cc1d87fe8"
dependencies = [
"bitflags 2.11.1",
"bitflags 2.12.1",
"cssparser",
"derive_more",
"fxhash",
@@ -2979,24 +2964,23 @@ dependencies = [
[[package]]
name = "serial_test"
version = "3.4.0"
version = "3.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "911bd979bf1070a3f3aa7b691a3b3e9968f339ceeec89e08c280a8a22207a32f"
checksum = "699f4197115b8a7e7ff19c9a315a4bd6fffec26cc4626ef45ecaea389e081c6d"
dependencies = [
"futures-executor",
"futures-util",
"log",
"once_cell",
"parking_lot",
"scc",
"serial_test_derive",
]
[[package]]
name = "serial_test_derive"
version = "3.4.0"
version = "3.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a7d91949b85b0d2fb687445e448b40d322b6b3e4af6b44a29b21d9a5f33e6d9"
checksum = "94e153fc76e1c6a068703d6d29c508a0b15c061c4b7e43da59cc097bc342673c"
dependencies = [
"proc-macro2",
"quote",
@@ -3050,6 +3034,12 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "shlex"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
[[package]]
name = "signal-hook"
version = "0.3.18"
@@ -3148,9 +3138,9 @@ dependencies = [
[[package]]
name = "socket2"
version = "0.6.3"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e"
checksum = "52d1cfed4120b4d927bf7c0f86d2087a4a7d6027c906d9f9d525a80573b9be51"
dependencies = [
"libc",
"windows-sys 0.61.2",
@@ -3415,7 +3405,7 @@ dependencies = [
"parking_lot",
"pin-project-lite",
"signal-hook-registry",
"socket2 0.6.3",
"socket2 0.6.4",
"tokio-macros",
"windows-sys 0.61.2",
]
@@ -3561,7 +3551,7 @@ dependencies = [
"humantime-serde",
"rayon",
"serde",
"shlex",
"shlex 1.3.0",
"snapbox",
"toml_edit",
]
@@ -3587,9 +3577,9 @@ dependencies = [
[[package]]
name = "typenum"
version = "1.20.0"
version = "1.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40ce102ab67701b8526c123c1bab5cbe42d7040ccfd0f64af1a385808d2f43de"
checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
[[package]]
name = "unicase"
@@ -3605,9 +3595,9 @@ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
name = "unicode-segmentation"
version = "1.13.2"
version = "1.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9629274872b2bfaf8d66f5f15725007f635594914870f65218920345aa11aa8c"
checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"
[[package]]
name = "unicode-width"
@@ -3659,9 +3649,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "uuid"
version = "1.23.1"
version = "1.23.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddd74a9687298c6858e9b88ec8935ec45d22e8fd5e6394fa1bd4e99a87789c76"
checksum = "d258b83ceec21034727ecee8c382cfa6c3e133699b0742c64571814fb420c9f7"
dependencies = [
"js-sys",
"wasm-bindgen",
@@ -3845,7 +3835,7 @@ version = "0.244.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe"
dependencies = [
"bitflags 2.11.1",
"bitflags 2.12.1",
"hashbrown 0.15.5",
"indexmap",
"semver",
@@ -4271,7 +4261,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2"
dependencies = [
"anyhow",
"bitflags 2.11.1",
"bitflags 2.12.1",
"indexmap",
"log",
"serde",
@@ -4347,18 +4337,18 @@ dependencies = [
[[package]]
name = "zerocopy"
version = "0.8.48"
version = "0.8.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9"
checksum = "3b065d4f0e55f82fae73202e189638116a87c55ab6b8e6c2721e13dd9d854ad1"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.8.48"
version = "0.8.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4"
checksum = "0b631b19d36a892ab55420c92dbc83ccd79274f25be714855d3074aa71cab639"
dependencies = [
"proc-macro2",
"quote",

View File

@@ -2,7 +2,7 @@
name = "scryer-prolog"
version = "0.10.0"
authors = ["Mark Thom <markjordanthom@gmail.com>"]
edition = "2021"
edition = "2024"
description = "A modern Prolog implementation written mostly in Rust."
readme = "README.md"
repository = "https://github.com/mthom/scryer-prolog"

View File

@@ -70,7 +70,7 @@ impl PrologBenchmark {
}
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
pub fn setup(&self) -> impl FnMut() -> Vec<LeafAnswer> {
pub fn setup(&self) -> impl FnMut() -> Vec<LeafAnswer> + use<> {
let mut machine = self.make_machine();
let query = self.query;
move || {

View File

@@ -281,14 +281,14 @@ pub trait ArenaAllocated {
unsafe fn typed_ptr(ptr: UntypedArenaPtr) -> TypedArenaPtr<Self>
where
Self::Payload: Sized,
{
{ unsafe {
TypedArenaPtr(NonNull::new_unchecked(
ptr.get_ptr()
.byte_add(Self::header_offset_from_payload())
.cast_mut()
.cast::<Self::Payload>(),
))
}
}}
#[allow(clippy::missing_safety_doc)]
fn alloc(arena: &mut Arena, value: Self::Payload) -> TypedArenaPtr<Self>
@@ -496,7 +496,7 @@ impl Arena {
}
}
unsafe fn drop_slab_in_place(value: NonNull<AllocSlab>, tag: ArenaHeaderTag) {
unsafe fn drop_slab_in_place(value: NonNull<AllocSlab>, tag: ArenaHeaderTag) { unsafe {
macro_rules! drop_typed_slab_in_place {
($payload: ty, $value: expr) => {
<$payload as ArenaAllocated>::dealloc($value.cast::<TypedAllocSlab<$payload>>())
@@ -580,7 +580,7 @@ unsafe fn drop_slab_in_place(value: NonNull<AllocSlab>, tag: ArenaHeaderTag) {
unreachable!("NullStream is never arena allocated!");
}
}
}
}}
impl Drop for Arena {
fn drop(&mut self) {

View File

@@ -361,7 +361,7 @@ pub(crate) fn rnd_i(n: &'_ Number, arena: &mut Arena) -> Result<Number, EvalErro
)))
}
}
Number::Rational(ref r) => {
Number::Rational(r) => {
let floor = r.floor();
if let Ok(value) = Fixnum::build_with_checked(&floor) {
@@ -384,9 +384,9 @@ impl From<Fixnum> for Integer {
pub(crate) fn rnd_f(n: &Number) -> f64 {
match n {
&Number::Fixnum(n) => n.get_num() as f64,
Number::Integer(ref n) => n.to_f64().value(),
Number::Integer(n) => n.to_f64().value(),
&Number::Float(OrderedFloat(f)) => f,
Number::Rational(ref r) => r.to_f64().value(),
Number::Rational(r) => r.to_f64().value(),
}
}
@@ -514,33 +514,33 @@ impl PartialEq for Number {
fn eq(&self, rhs: &Self) -> bool {
match (self, rhs) {
(&Number::Fixnum(n1), &Number::Fixnum(n2)) => n1.eq(&n2),
(&Number::Fixnum(n1), Number::Integer(ref n2)) => n1.get_num().num_eq(&**n2),
(Number::Integer(ref n1), &Number::Fixnum(n2)) => n1.num_eq(&n2.get_num()),
(&Number::Fixnum(n1), Number::Rational(ref n2)) => {
(&Number::Fixnum(n1), Number::Integer(n2)) => n1.get_num().num_eq(&**n2),
(Number::Integer(n1), &Number::Fixnum(n2)) => n1.num_eq(&n2.get_num()),
(&Number::Fixnum(n1), Number::Rational(n2)) => {
Integer::from(n1.get_num()).num_eq(&**n2)
}
(Number::Rational(ref n1), &Number::Fixnum(n2)) => {
(Number::Rational(n1), &Number::Fixnum(n2)) => {
n1.num_eq(&Integer::from(n2.get_num()))
}
(&Number::Fixnum(n1), &Number::Float(n2)) => OrderedFloat(n1.get_num() as f64).eq(&n2),
(&Number::Float(n1), &Number::Fixnum(n2)) => n1.eq(&OrderedFloat(n2.get_num() as f64)),
(Number::Integer(ref n1), Number::Integer(ref n2)) => n1.eq(n2),
(Number::Integer(ref n1), Number::Float(n2)) => {
(Number::Integer(n1), Number::Integer(n2)) => n1.eq(n2),
(Number::Integer(n1), Number::Float(n2)) => {
OrderedFloat(n1.to_f64().value()).eq(n2)
}
(&Number::Float(n1), Number::Integer(ref n2)) => {
(&Number::Float(n1), Number::Integer(n2)) => {
n1.eq(&OrderedFloat(n2.to_f64().value()))
}
(Number::Integer(ref n1), Number::Rational(ref n2)) => n1.num_eq(&**n2),
(Number::Rational(ref n1), Number::Integer(ref n2)) => n1.num_eq(&**n2),
(Number::Rational(ref n1), &Number::Float(n2)) => {
(Number::Integer(n1), Number::Rational(n2)) => n1.num_eq(&**n2),
(Number::Rational(n1), Number::Integer(n2)) => n1.num_eq(&**n2),
(Number::Rational(n1), &Number::Float(n2)) => {
OrderedFloat(n1.to_f64().value()).eq(&n2)
}
(&Number::Float(n1), Number::Rational(ref n2)) => {
(&Number::Float(n1), Number::Rational(n2)) => {
n1.eq(&OrderedFloat(n2.to_f64().value()))
}
(&Number::Float(f1), &Number::Float(f2)) => f1.eq(&f2),
(Number::Rational(ref r1), Number::Rational(ref r2)) => r1.eq(r2),
(Number::Rational(r1), Number::Rational(r2)) => r1.eq(r2),
}
}
}
@@ -607,7 +607,7 @@ impl Ord for Number {
(&Number::Float(n1), &Number::Fixnum(n2)) => n1.cmp(&OrderedFloat(n2.get_num() as f64)),
(&Number::Integer(n1), &Number::Integer(n2)) => (*n1).cmp(&*n2),
(&Number::Integer(n1), Number::Float(n2)) => OrderedFloat(n1.to_f64().value()).cmp(n2),
(&Number::Float(n1), Number::Integer(ref n2)) => {
(&Number::Float(n1), Number::Integer(n2)) => {
n1.cmp(&OrderedFloat(n2.to_f64().value()))
}
(&Number::Integer(n1), &Number::Rational(n2)) => {

View File

@@ -388,9 +388,11 @@ impl Atom {
}
unsafe fn write_to_ptr(string: &str, ptr: *mut u8) {
ptr::write(ptr as *mut _, AtomHeader::build_with(string.len() as u64));
let str_ptr = ptr.add(mem::size_of::<AtomHeader>());
ptr::copy_nonoverlapping(string.as_ptr(), str_ptr, string.len());
unsafe { ptr::write(ptr as *mut _, AtomHeader::build_with(string.len() as u64)); }
unsafe {
let str_ptr = ptr.add(mem::size_of::<AtomHeader>());
ptr::copy_nonoverlapping(string.as_ptr(), str_ptr, string.len());
}
}
impl PartialOrd for Atom {

View File

@@ -345,10 +345,10 @@ impl<'a> AddToFreeList<'a, QueryInstruction> for CodeGenerator {
fn structure_cell(term: &Term) -> Option<&Cell<RegType>> {
match term {
&Term::Cons(ref cell, ..)
| &Term::Clause(ref cell, ..)
| Term::PartialString(ref cell, ..)
| Term::CompleteString(ref cell, ..) => Some(cell),
Term::Cons(cell, ..)
| Term::Clause(cell, ..)
| Term::PartialString(cell, ..)
| Term::CompleteString(cell, ..) => Some(cell),
_ => None,
}
}
@@ -401,18 +401,18 @@ impl CodeGenerator {
&Term::AnonVar => {
Self::add_or_increment_void_instr::<Target>(target);
}
&Term::Cons(ref cell, ..)
| &Term::Clause(ref cell, ..)
| Term::PartialString(ref cell, ..)
| Term::CompleteString(ref cell, ..) => {
Term::Cons(cell, ..)
| Term::Clause(cell, ..)
| Term::PartialString(cell, ..)
| Term::CompleteString(cell, ..) => {
self.marker
.mark_non_var::<Target>(Level::Deep, term_loc, cell, target);
target.push_back(Target::clause_arg_to_instr(cell.get()));
}
Term::Literal(_, ref constant) => {
Term::Literal(_, constant) => {
target.push_back(Target::constant_subterm(*constant));
}
Term::Var(ref cell, ref var_ptr) => {
Term::Var(cell, var_ptr) => {
self.deep_var_instr::<Target>(
cell,
var_ptr.to_var_num().unwrap(),
@@ -572,7 +572,7 @@ impl CodeGenerator {
Term::Literal(_, Literal::Atom(..)) => {
instr!("$succeed")
}
Term::Var(ref vr, ref name) => {
Term::Var(vr, name) => {
self.marker.reset_arg(1);
let r = self.marker.mark_non_callable(
@@ -600,7 +600,7 @@ impl CodeGenerator {
Term::Literal(..) => {
instr!("$succeed")
}
Term::Var(ref vr, ref name) => {
Term::Var(vr, name) => {
self.marker.reset_arg(1);
let r = self.marker.mark_non_callable(
@@ -621,7 +621,7 @@ impl CodeGenerator {
| Term::CompleteString(..) => {
instr!("$succeed")
}
Term::Var(ref vr, ref name) => {
Term::Var(vr, name) => {
self.marker.reset_arg(1);
let r = self.marker.mark_non_callable(
@@ -733,7 +733,7 @@ impl CodeGenerator {
Term::Literal(_, Literal::Integer(_)) | Term::Literal(_, Literal::Fixnum(_)) => {
instr!("$succeed")
}
Term::Var(ref vr, name) => {
Term::Var(vr, name) => {
self.marker.reset_arg(1);
let r = self.marker.mark_non_callable(
@@ -828,7 +828,7 @@ impl CodeGenerator {
self.marker
.mark_anon_var::<QueryInstruction>(Level::Shallow, term_loc, code);
if let Term::Var(ref vr, ref var) = &terms[1] {
if let Term::Var(vr, var) = &terms[1] {
let var_num = var.to_var_num().unwrap();
// if var is an anonymous variable, insert

View File

@@ -158,7 +158,7 @@ impl DebrayAllocator {
for var_num in subsumed_hits {
match &mut self.var_data.records[var_num].allocation {
VarAlloc::Perm(_, ref mut allocation) => {
VarAlloc::Perm(_, allocation) => {
if let PermVarAllocation::Done {
shallow_safety,
deep_safety,
@@ -551,7 +551,7 @@ impl DebrayAllocator {
} else if let Some(&temp_var_num) = self.shallow_temp_mappings.get(&self.arg_c) {
match &mut self.var_data.records[temp_var_num].allocation {
VarAlloc::Temp {
ref mut to_perm_var_num,
to_perm_var_num,
..
} => {
*to_perm_var_num = Some(var_num);
@@ -560,7 +560,7 @@ impl DebrayAllocator {
}
}
}
VarAlloc::Temp { ref mut safety, .. } => {
VarAlloc::Temp { safety, .. } => {
*safety = VarSafetyStatus::GloballyUnneeded;
}
_ => {
@@ -581,7 +581,7 @@ impl DebrayAllocator {
VarAlloc::Perm(
_,
PermVarAllocation::Done {
ref mut shallow_safety,
shallow_safety,
..
},
) => {
@@ -617,7 +617,7 @@ impl DebrayAllocator {
VarAlloc::Perm(
_,
PermVarAllocation::Done {
ref mut deep_safety,
deep_safety,
..
},
) => {
@@ -631,7 +631,7 @@ impl DebrayAllocator {
Target::unsafe_subterm_to_value(r)
}
}
VarAlloc::Temp { ref mut safety, .. } => {
VarAlloc::Temp { safety, .. } => {
if self
.branch_stack
.safety_unneeded_in_branch(safety, &branch_designator)
@@ -874,7 +874,7 @@ impl Allocator for DebrayAllocator {
self.arity = args.len();
for (idx, arg) in args.iter().enumerate() {
if let Term::Var(_, ref var) = arg {
if let Term::Var(_, var) = arg {
let var_num = var.to_var_num().unwrap();
let r = self.get_binding(var_num);

View File

@@ -53,27 +53,27 @@ pub struct FunctionImpl {
}
impl FunctionImpl {
unsafe fn call_void(&self, args: &[Arg], _: &mut Arena) -> Result<Value, FfiError> {
unsafe fn call_void(&self, args: &[Arg], _: &mut Arena) -> Result<Value, FfiError> { unsafe {
self.cif.call_return_into(self.code_ptr, args, Ret::void());
Ok(Value::Number(Number::Fixnum(Fixnum::build_with(0))))
}
}}
unsafe fn call_int<T>(&self, args: &[Arg], arena: &mut Arena) -> Result<Value, FfiError>
where
Integer: From<T>,
T: Copy + TryInto<i64> + MightNotFitInFixnum,
{
{ unsafe {
let n = self.cif.call::<T>(self.code_ptr, args);
Ok(Value::Number(fixnum!(Number, n, arena)))
}
}}
unsafe fn call_float<T>(&self, args: &[Arg], _: &mut Arena) -> Result<Value, FfiError>
where
T: Into<f64>,
{
{ unsafe {
let n = self.cif.call::<T>(self.code_ptr, args);
Ok(Value::Number(Number::Float(OrderedFloat(n.into()))))
}
}}
unsafe fn call_ptr(&self, args: &[Arg], arena: &mut Arena) -> Result<Value, FfiError> {
let ptr = unsafe { self.cif.call::<*mut c_void>(self.code_ptr, args) };
@@ -197,14 +197,14 @@ impl StructImpl {
ptr: NonNull<c_void>,
layout: &mut Layout,
val: T,
) -> Result<(), FfiError> {
) -> Result<(), FfiError> { unsafe {
let (new_layout, offset) = layout
.extend(Layout::new::<T>())
.map_err(|_| FfiError::LayoutError)?;
*layout = new_layout;
ptr.byte_offset(offset as isize).cast::<T>().write(val);
Ok(())
}
}}
for arg in args {
unsafe {
@@ -258,14 +258,14 @@ impl StructImpl {
unsafe fn read_primitive<T>(
ptr: *mut c_void,
layout: &mut Layout,
) -> Result<T, FfiError> {
) -> Result<T, FfiError> { unsafe {
let (new_layout, offset) = layout
.extend(Layout::new::<T>())
.map_err(|_| FfiError::LayoutError)?;
*layout = new_layout;
let n = std::ptr::read::<T>(ptr.byte_offset(offset as isize).cast());
Ok(n)
}
}}
unsafe fn read_int<T>(
ptr: *mut c_void,
@@ -275,10 +275,10 @@ impl StructImpl {
where
T: Copy + TryInto<i64> + MightNotFitInFixnum,
Integer: From<T>,
{
{ unsafe {
let n = read_primitive::<T>(ptr, layout)?;
Ok(Value::Number(fixnum!(Number, n, arena)))
}
}}
unsafe fn read_float<T>(
ptr: *mut c_void,
@@ -286,10 +286,10 @@ impl StructImpl {
) -> Result<Value, FfiError>
where
T: Into<f64>,
{
{ unsafe {
let n = read_primitive::<T>(ptr, layout)?;
Ok(Value::Number(Number::Float(OrderedFloat(n.into()))))
}
}}
let mut layout = Layout::from_size_align(0, 1).map_err(|_| FfiError::LayoutError)?;
@@ -788,10 +788,10 @@ impl ForeignFunctionTable {
where
T: Copy + TryInto<i64> + MightNotFitInFixnum,
Integer: From<T>,
{
{ unsafe {
let n = ptr.cast::<T>().read();
Value::Number(fixnum!(Number, n, arena))
}
}}
let ptr = ptr.as_ptr()?;
@@ -924,7 +924,7 @@ impl Value {
fn as_ptr(&mut self) -> Result<*mut c_void, FfiError> {
match self {
Value::CString(ref mut cstr) => Ok(cstr.as_ptr().cast_mut().cast()),
Value::CString(cstr) => Ok(cstr.as_ptr().cast_mut().cast()),
Value::Number(Number::Fixnum(fixnum)) => Ok(std::ptr::with_exposed_provenance_mut(
fixnum.get_num() as usize,
)),

View File

@@ -389,15 +389,15 @@ impl ClauseInfo for Rule {
impl ClauseInfo for PredicateClause {
fn name(&self) -> Option<Atom> {
match self {
PredicateClause::Fact(ref term, ..) => term.head.name(),
PredicateClause::Rule(ref rule, ..) => rule.name(),
PredicateClause::Fact(term, ..) => term.head.name(),
PredicateClause::Rule(rule, ..) => rule.name(),
}
}
fn arity(&self) -> usize {
match self {
PredicateClause::Fact(ref term, ..) => term.head.arity(),
PredicateClause::Rule(ref rule, ..) => rule.arity(),
PredicateClause::Fact(term, ..) => term.head.arity(),
PredicateClause::Rule(rule, ..) => rule.arity(),
}
}
}
@@ -582,7 +582,7 @@ pub(crate) fn fetch_op_spec_from_existing(
op_desc: Option<OpDesc>,
op_dir: &OpDir,
) -> Option<OpDesc> {
if let Some(ref op_desc) = &op_desc {
if let Some(op_desc) = &op_desc {
if op_desc.arity() != arity {
/* it's possible to extend operator functors with
* additional terms. When that happens,
@@ -843,9 +843,9 @@ impl Number {
pub(crate) fn is_positive(&self) -> bool {
match self {
Number::Fixnum(n) => n.get_num() > 0,
Number::Integer(ref n) => n.is_positive(),
Number::Integer(n) => n.is_positive(),
Number::Float(f) => f.is_sign_positive(),
Number::Rational(ref r) => r.is_positive(),
Number::Rational(r) => r.is_positive(),
}
}
@@ -853,9 +853,9 @@ impl Number {
pub(crate) fn is_negative(&self) -> bool {
match self {
Number::Fixnum(n) => n.get_num() < 0,
Number::Integer(ref n) => n.is_negative(),
Number::Integer(n) => n.is_negative(),
&Number::Float(OrderedFloat(f)) => f.is_sign_negative() && f != -0f64,
Number::Rational(ref r) => r.is_negative(),
Number::Rational(r) => r.is_negative(),
}
}
@@ -863,9 +863,9 @@ impl Number {
pub(crate) fn is_zero(&self) -> bool {
match self {
Number::Fixnum(n) => n.get_num() == 0,
Number::Integer(ref n) => n.is_zero(),
Number::Integer(n) => n.is_zero(),
&Number::Float(OrderedFloat(f)) => f == 0.0 || f == -0.0,
Number::Rational(ref r) => r.is_zero(),
Number::Rational(r) => r.is_zero(),
}
}
@@ -920,9 +920,9 @@ impl OptArgIndexKey {
#[inline]
pub(crate) fn set_switch_on_term_loc(&mut self, value: usize) {
match self {
OptArgIndexKey::Literal(_, ref mut loc, ..)
| OptArgIndexKey::Structure(_, ref mut loc, ..)
| OptArgIndexKey::List(_, ref mut loc) => {
OptArgIndexKey::Literal(_, loc, ..)
| OptArgIndexKey::Structure(_, loc, ..)
| OptArgIndexKey::List(_, loc) => {
*loc = value;
}
OptArgIndexKey::None => {}
@@ -934,9 +934,9 @@ impl AddAssign<usize> for OptArgIndexKey {
#[inline]
fn add_assign(&mut self, n: usize) {
match self {
OptArgIndexKey::Literal(_, ref mut o, ..)
| OptArgIndexKey::List(_, ref mut o)
| OptArgIndexKey::Structure(_, ref mut o, ..) => {
OptArgIndexKey::Literal(_, o, ..)
| OptArgIndexKey::List(_, o)
| OptArgIndexKey::Structure(_, o, ..) => {
*o += n;
}
OptArgIndexKey::None => {}

View File

@@ -387,7 +387,7 @@ fn negated_op_needs_bracketing(
op_dir: &OpDir,
op: &Option<DirectedOp>,
) -> bool {
if let Some(ref op) = op {
if let Some(op) = op {
op.is_negative_sign()
&& iter.leftmost_leaf_has_property(op_dir, |addr| {
match Number::try_from((addr, f64_tbl)) {
@@ -1452,7 +1452,7 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
});
for op in &[op, parent_op] {
if let Some(ref op) = &op {
if let Some(op) = &op {
if op.is_left()
&& (op.is_prefix() || requires_space(&op.as_atom().as_str(), "("))
{

View File

@@ -167,7 +167,7 @@ impl<'a> IndexingCodeMergingPtr<'a> {
.push(IndexingLine::IndexedChoice(third_level_index));
match &mut self.indexing_code[self.offset] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnConstant(ref mut constants)) => {
IndexingLine::Indexing(IndexingInstruction::SwitchOnConstant(constants)) => {
constants.insert(
constant,
IndexingCodePtr::Internal(indexing_code_len - self.offset),
@@ -196,7 +196,7 @@ impl<'a> IndexingCodeMergingPtr<'a> {
.push(IndexingLine::DynamicIndexedChoice(third_level_index));
match &mut self.indexing_code[self.offset] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnConstant(ref mut constants)) => {
IndexingLine::Indexing(IndexingInstruction::SwitchOnConstant(constants)) => {
constants.insert(
constant,
IndexingCodePtr::Internal(indexing_code_len - self.offset),
@@ -210,22 +210,22 @@ impl<'a> IndexingCodeMergingPtr<'a> {
fn extend_indexed_choice(&mut self, index: usize) {
match &mut self.indexing_code[self.offset] {
IndexingLine::IndexedChoice(ref mut indexed_choice_instrs)
IndexingLine::IndexedChoice(indexed_choice_instrs)
if self.append_or_prepend.is_append() =>
{
uncap_choice_seq_with_trust(indexed_choice_instrs.make_contiguous());
indexed_choice_instrs.push_back(IndexedChoiceInstruction::Trust(index));
}
IndexingLine::IndexedChoice(ref mut indexed_choice_instrs) => {
IndexingLine::IndexedChoice(indexed_choice_instrs) => {
uncap_choice_seq_with_try(indexed_choice_instrs.make_contiguous());
indexed_choice_instrs.push_front(IndexedChoiceInstruction::Try(index));
}
IndexingLine::DynamicIndexedChoice(ref mut indexed_choice_instrs)
IndexingLine::DynamicIndexedChoice(indexed_choice_instrs)
if self.append_or_prepend.is_append() =>
{
indexed_choice_instrs.push_back(index);
}
IndexingLine::DynamicIndexedChoice(ref mut indexed_choice_instrs) => {
IndexingLine::DynamicIndexedChoice(indexed_choice_instrs) => {
indexed_choice_instrs.push_front(index);
}
_ => {
@@ -244,7 +244,7 @@ impl<'a> IndexingCodeMergingPtr<'a> {
let indexing_code_len = self.indexing_code.len();
match &mut self.indexing_code[self.offset] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, ref mut c, ..)) => {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, c, ..)) => {
match *c {
IndexingCodePtr::Fail if self.is_dynamic => {
*c = IndexingCodePtr::DynamicExternal(index);
@@ -322,7 +322,7 @@ impl<'a> IndexingCodeMergingPtr<'a> {
let indexing_code_len = self.indexing_code.len();
match &mut self.indexing_code[self.offset] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, ref mut c, ..)) => {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, c, ..)) => {
match *c {
IndexingCodePtr::Fail if self.is_dynamic => {
*c = IndexingCodePtr::DynamicExternal(index);
@@ -445,7 +445,7 @@ impl<'a> IndexingCodeMergingPtr<'a> {
.push(IndexingLine::IndexedChoice(third_level_index));
match &mut self.indexing_code[self.offset] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnStructure(ref mut structures)) => {
IndexingLine::Indexing(IndexingInstruction::SwitchOnStructure(structures)) => {
structures.insert(
key,
IndexingCodePtr::Internal(indexing_code_len - self.offset),
@@ -474,7 +474,7 @@ impl<'a> IndexingCodeMergingPtr<'a> {
.push(IndexingLine::DynamicIndexedChoice(third_level_index));
match &mut self.indexing_code[self.offset] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnStructure(ref mut structures)) => {
IndexingLine::Indexing(IndexingInstruction::SwitchOnStructure(structures)) => {
structures.insert(
key,
IndexingCodePtr::Internal(indexing_code_len - self.offset),
@@ -496,7 +496,7 @@ impl<'a> IndexingCodeMergingPtr<'a> {
_,
_,
_,
ref mut s,
s,
)) => match *s {
IndexingCodePtr::Fail if self.is_dynamic => {
*s = IndexingCodePtr::DynamicExternal(index);
@@ -559,7 +559,7 @@ impl<'a> IndexingCodeMergingPtr<'a> {
let indexing_code_len = self.indexing_code.len();
match &mut self.indexing_code[self.offset] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, _, ref mut l, _)) => {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, _, l, _)) => {
match *l {
IndexingCodePtr::Fail if self.is_dynamic => {
*l = IndexingCodePtr::DynamicExternal(index);
@@ -632,7 +632,7 @@ pub(crate) fn merge_clause_index(
);
match &opt_arg_index_key {
OptArgIndexKey::Literal(_, index_loc, constant, ref overlapping_constants) => {
OptArgIndexKey::Literal(_, index_loc, constant, overlapping_constants) => {
let offset = new_clause_loc - index_loc + 1;
merging_ptr.index_constant(HeapCellValue::from(*constant), offset);
@@ -676,7 +676,7 @@ pub(crate) fn remove_constant_indices(
let iter = once(&constant).chain(overlapping_constants.iter());
match &mut indexing_code[index] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, ref mut c, ..)) => {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, c, ..)) => {
match *c {
IndexingCodePtr::DynamicExternal(_) | IndexingCodePtr::External(_) => {
*c = IndexingCodePtr::Fail;
@@ -701,7 +701,7 @@ pub(crate) fn remove_constant_indices(
loop {
match &mut indexing_code[index] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnConstant(
ref mut constants,
constants,
)) => {
constants_index = index;
@@ -720,7 +720,7 @@ pub(crate) fn remove_constant_indices(
}
}
}
IndexingLine::IndexedChoice(ref mut indexed_choice_instrs) => {
IndexingLine::IndexedChoice(indexed_choice_instrs) => {
StaticCodeIndices::remove_instruction_with_offset(
indexed_choice_instrs,
offset,
@@ -734,13 +734,13 @@ pub(crate) fn remove_constant_indices(
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(
_,
_,
ref mut c,
c,
..,
)) => {
*c = ext;
}
IndexingLine::Indexing(IndexingInstruction::SwitchOnConstant(
ref mut constants,
constants,
)) => {
constants.insert(constant, ext);
}
@@ -753,7 +753,7 @@ pub(crate) fn remove_constant_indices(
break;
}
IndexingLine::DynamicIndexedChoice(ref mut indexed_choice_instrs) => {
IndexingLine::DynamicIndexedChoice(indexed_choice_instrs) => {
DynamicCodeIndices::remove_instruction_with_offset(
indexed_choice_instrs,
offset,
@@ -767,13 +767,13 @@ pub(crate) fn remove_constant_indices(
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(
_,
_,
ref mut c,
c,
..,
)) => {
*c = ext;
}
IndexingLine::Indexing(IndexingInstruction::SwitchOnConstant(
ref mut constants,
constants,
)) => {
constants.insert(constant, ext);
}
@@ -794,11 +794,11 @@ pub(crate) fn remove_constant_indices(
}
match &indexing_code[constants_index] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnConstant(ref constants))
IndexingLine::Indexing(IndexingInstruction::SwitchOnConstant(constants))
if constants.is_empty() =>
{
match &mut indexing_code[0] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, ref mut c, ..)) => {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, c, ..)) => {
*c = IndexingCodePtr::Fail;
}
_ => {
@@ -819,7 +819,7 @@ pub(crate) fn remove_structure_index(
let mut index = 0;
match &mut indexing_code[index] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, _, _, ref mut s)) => {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, _, _, s)) => {
match *s {
IndexingCodePtr::DynamicExternal(_) | IndexingCodePtr::External(_) => {
*s = IndexingCodePtr::Fail;
@@ -842,7 +842,7 @@ pub(crate) fn remove_structure_index(
loop {
match &mut indexing_code[index] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnStructure(ref mut structures)) => {
IndexingLine::Indexing(IndexingInstruction::SwitchOnStructure(structures)) => {
structures_index = index;
match structures.get(&(name, arity)).cloned() {
@@ -859,7 +859,7 @@ pub(crate) fn remove_structure_index(
}
}
}
IndexingLine::IndexedChoice(ref mut indexed_choice_instrs) => {
IndexingLine::IndexedChoice(indexed_choice_instrs) => {
StaticCodeIndices::remove_instruction_with_offset(indexed_choice_instrs, offset);
if indexed_choice_instrs.len() == 1 {
@@ -872,12 +872,12 @@ pub(crate) fn remove_structure_index(
_,
_,
_,
ref mut s,
s,
)) => {
*s = ext;
}
IndexingLine::Indexing(IndexingInstruction::SwitchOnStructure(
ref mut structures,
structures,
)) => {
structures.insert((name, arity), ext);
}
@@ -890,7 +890,7 @@ pub(crate) fn remove_structure_index(
break;
}
IndexingLine::DynamicIndexedChoice(ref mut indexed_choice_instrs) => {
IndexingLine::DynamicIndexedChoice(indexed_choice_instrs) => {
DynamicCodeIndices::remove_instruction_with_offset(indexed_choice_instrs, offset);
if indexed_choice_instrs.len() == 1 {
@@ -903,12 +903,12 @@ pub(crate) fn remove_structure_index(
_,
_,
_,
ref mut s,
s,
)) => {
*s = ext;
}
IndexingLine::Indexing(IndexingInstruction::SwitchOnStructure(
ref mut structures,
structures,
)) => {
structures.insert((name, arity), ext);
}
@@ -928,7 +928,7 @@ pub(crate) fn remove_structure_index(
}
match &indexing_code[structures_index] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnStructure(ref structures))
IndexingLine::Indexing(IndexingInstruction::SwitchOnStructure(structures))
if structures.is_empty() =>
{
match &mut indexing_code[0] {
@@ -937,7 +937,7 @@ pub(crate) fn remove_structure_index(
_,
_,
_,
ref mut s,
s,
)) => {
*s = IndexingCodePtr::Fail;
}
@@ -954,7 +954,7 @@ pub(crate) fn remove_list_index(indexing_code: &mut [IndexingLine], offset: usiz
let mut index = 0;
match &mut indexing_code[index] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, _, ref mut l, _)) => {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, _, _, l, _)) => {
match *l {
IndexingCodePtr::DynamicExternal(_) | IndexingCodePtr::External(_) => {
*l = IndexingCodePtr::Fail;
@@ -974,7 +974,7 @@ pub(crate) fn remove_list_index(indexing_code: &mut [IndexingLine], offset: usiz
}
match &mut indexing_code[index] {
IndexingLine::IndexedChoice(ref mut indexed_choice_instrs) => {
IndexingLine::IndexedChoice(indexed_choice_instrs) => {
StaticCodeIndices::remove_instruction_with_offset(indexed_choice_instrs, offset);
if indexed_choice_instrs.len() == 1 {
@@ -986,7 +986,7 @@ pub(crate) fn remove_list_index(indexing_code: &mut [IndexingLine], offset: usiz
_,
_,
_,
ref mut l,
l,
_,
)) => {
*l = ext;
@@ -998,7 +998,7 @@ pub(crate) fn remove_list_index(indexing_code: &mut [IndexingLine], offset: usiz
}
}
}
IndexingLine::DynamicIndexedChoice(ref mut indexed_choice_instrs) => {
IndexingLine::DynamicIndexedChoice(indexed_choice_instrs) => {
DynamicCodeIndices::remove_instruction_with_offset(indexed_choice_instrs, offset);
if indexed_choice_instrs.len() == 1 {
@@ -1010,7 +1010,7 @@ pub(crate) fn remove_list_index(indexing_code: &mut [IndexingLine], offset: usiz
_,
_,
_,
ref mut l,
l,
_,
)) => {
*l = ext;
@@ -1034,7 +1034,7 @@ pub(crate) fn remove_index(
clause_loc: usize,
) {
match opt_arg_index_key {
OptArgIndexKey::Literal(_, _, constant, ref overlapping_constants) => {
OptArgIndexKey::Literal(_, _, constant, overlapping_constants) => {
remove_constant_indices(*constant, *overlapping_constants, indexing_code, clause_loc);
}
OptArgIndexKey::Structure(_, _, name, arity) => {
@@ -1525,11 +1525,11 @@ impl<I: Indexer> CodeOffsets<I> {
&mut prelude,
);
if let IndexingCodePtr::Internal(ref mut i) = &mut str_loc {
if let IndexingCodePtr::Internal(i) = &mut str_loc {
*i += emitted_switch_on_constant as usize; // con_loc.is_internal() as usize;
}
if let IndexingCodePtr::Internal(ref mut i) = &mut lst_loc {
if let IndexingCodePtr::Internal(i) = &mut lst_loc {
*i += emitted_switch_on_constant as usize; // con_loc.is_internal() as usize;
*i += emitted_switch_on_structure as usize; // str_loc.is_internal() as usize;
}

View File

@@ -251,7 +251,7 @@ impl Instruction {
#[inline]
pub fn to_indexing_line_mut(&mut self) -> Option<&mut Vec<IndexingLine>> {
match self {
Instruction::IndexingCode(ref mut indexing_code) => Some(indexing_code),
Instruction::IndexingCode(indexing_code) => Some(indexing_code),
_ => None,
}
}
@@ -259,7 +259,7 @@ impl Instruction {
#[inline]
pub fn to_indexing_line(&self) -> Option<&Vec<IndexingLine>> {
match self {
Instruction::IndexingCode(ref indexing_code) => Some(indexing_code),
Instruction::IndexingCode(indexing_code) => Some(indexing_code),
_ => None,
}
}
@@ -1372,12 +1372,12 @@ impl Instruction {
impl CompareNumber {
pub fn set_terms(&mut self, l_at_1: ArithmeticTerm, l_at_2: ArithmeticTerm) {
match self {
CompareNumber::NumberGreaterThan(ref mut at_1, ref mut at_2)
| CompareNumber::NumberLessThan(ref mut at_1, ref mut at_2)
| CompareNumber::NumberGreaterThanOrEqual(ref mut at_1, ref mut at_2)
| CompareNumber::NumberLessThanOrEqual(ref mut at_1, ref mut at_2)
| CompareNumber::NumberNotEqual(ref mut at_1, ref mut at_2)
| CompareNumber::NumberEqual(ref mut at_1, ref mut at_2) => {
CompareNumber::NumberGreaterThan(at_1, at_2)
| CompareNumber::NumberLessThan(at_1, at_2)
| CompareNumber::NumberGreaterThanOrEqual(at_1, at_2)
| CompareNumber::NumberLessThanOrEqual(at_1, at_2)
| CompareNumber::NumberNotEqual(at_1, at_2)
| CompareNumber::NumberEqual(at_1, at_2) => {
*at_1 = l_at_1;
*at_2 = l_at_2;
}

View File

@@ -103,11 +103,11 @@ impl<'a> QueryIterator<'a> {
fn extend_state(&mut self, lvl: Level, term: &'a QueryTerm) {
match term {
QueryTerm::Clause(ref cell, ClauseType::CallN(_), ref terms, _) => {
QueryTerm::Clause(cell, ClauseType::CallN(_), terms, _) => {
self.state_stack
.push(TermIterState::Clause(lvl, 1, cell, atom!("$call"), terms));
}
QueryTerm::Clause(ref cell, ref ct, ref terms, _) => {
QueryTerm::Clause(cell, ct, terms, _) => {
self.state_stack
.push(TermIterState::Clause(lvl, 0, cell, ct.name(), terms));
}
@@ -419,7 +419,7 @@ impl<'a> Iterator for ClauseIterator<'a> {
self.state_stack
.push(ClauseIteratorState::RemainingBranches(branch_nums, arms, 0));
}
ChunkedTerms::Chunk { ref terms } => {
ChunkedTerms::Chunk { terms } => {
return Some(ClauseItem::Chunk { terms });
}
}

View File

@@ -62,7 +62,7 @@ impl MachineState {
.attr_var_init
.bindings
.iter()
.map(|(ref h, _)| attr_var_as_cell!(*h));
.map(|(h, _)| attr_var_as_cell!(*h));
let var_list_addr = sized_iter_to_heap_list(&mut self.heap, size, iter)?;
let iter = self.attr_var_init.bindings.drain(0..).map(|(_, ref v)| *v);

View File

@@ -80,19 +80,19 @@ fn derelictize_try_me_else(
) -> Option<usize> {
match &mut code[index] {
Instruction::DynamicElse(_, _, NextOrFail::Next(0)) => None,
Instruction::DynamicElse(_, _, NextOrFail::Next(ref mut o)) => {
Instruction::DynamicElse(_, _, NextOrFail::Next(o)) => {
retraction_info.push_record(RetractionRecord::ReplacedDynamicElseOffset(index, *o));
Some(mem::replace(o, 0))
}
Instruction::DynamicInternalElse(_, _, NextOrFail::Next(0)) => None,
Instruction::DynamicInternalElse(_, _, NextOrFail::Next(ref mut o)) => {
Instruction::DynamicInternalElse(_, _, NextOrFail::Next(o)) => {
retraction_info.push_record(RetractionRecord::ReplacedDynamicElseOffset(index, *o));
Some(mem::replace(o, 0))
}
Instruction::DynamicElse(_, _, NextOrFail::Fail(_))
| Instruction::DynamicInternalElse(_, _, NextOrFail::Fail(_)) => None,
Instruction::TryMeElse(0) => None,
Instruction::TryMeElse(ref mut o) => {
Instruction::TryMeElse(o) => {
retraction_info.push_record(RetractionRecord::ModifiedTryMeElse(index, *o));
Some(mem::replace(o, 0))
}
@@ -275,7 +275,7 @@ fn merge_indexed_subsequences(
.unwrap(),
);
if let Instruction::TryMeElse(ref mut o) = &mut code[inner_try_me_else_loc] {
if let Instruction::TryMeElse(o) = &mut code[inner_try_me_else_loc] {
retraction_info.push_record(RetractionRecord::ModifiedTryMeElse(
inner_try_me_else_loc,
*o,
@@ -324,7 +324,7 @@ fn merge_indexed_subsequences(
);
}
None => {
if let Instruction::TryMeElse(ref mut o) = &mut code[outer_threaded_choice_instr_loc] {
if let Instruction::TryMeElse(o) = &mut code[outer_threaded_choice_instr_loc] {
retraction_info
.push_record(RetractionRecord::ModifiedTryMeElse(inner_trust_me_loc, *o));
@@ -472,7 +472,7 @@ fn set_switch_var_offset(
let target_indexing_line = code[index_loc].to_indexing_line_mut().unwrap();
let old_v = match &mut target_indexing_line[0] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, ref mut v, ..)) => match *v {
IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(_, v, ..)) => match *v {
IndexingCodePtr::DynamicExternal(_) => {
mem::replace(v, IndexingCodePtr::DynamicExternal(offset))
}
@@ -497,7 +497,7 @@ fn internalize_choice_instr_at(
match &mut code[instr_loc] {
Instruction::DynamicElse(_, _, NextOrFail::Fail(_))
| Instruction::DynamicInternalElse(_, _, NextOrFail::Fail(_)) => {}
Instruction::DynamicElse(_, _, ref mut o @ NextOrFail::Next(0)) => {
Instruction::DynamicElse(_, _, o @ NextOrFail::Next(0)) => {
retraction_info.push_record(RetractionRecord::ReplacedDynamicElseOffset(instr_loc, 0));
*o = NextOrFail::Fail(0);
}
@@ -516,7 +516,7 @@ fn internalize_choice_instr_at(
}
}
}
Instruction::DynamicInternalElse(_, _, ref mut o @ NextOrFail::Next(0)) => {
Instruction::DynamicInternalElse(_, _, o @ NextOrFail::Next(0)) => {
retraction_info.push_record(RetractionRecord::ReplacedDynamicElseOffset(instr_loc, 0));
*o = NextOrFail::Fail(0);
}
@@ -564,7 +564,7 @@ fn thread_choice_instr_at_to(
) {
loop {
match &mut code[instr_loc] {
Instruction::TryMeElse(ref mut o) | Instruction::RetryMeElse(ref mut o)
Instruction::TryMeElse(o) | Instruction::RetryMeElse(o)
if target_loc >= instr_loc =>
{
retraction_info.push_record(RetractionRecord::ReplacedChoiceOffset(instr_loc, *o));
@@ -572,8 +572,8 @@ fn thread_choice_instr_at_to(
*o = target_loc - instr_loc;
return;
}
Instruction::DynamicElse(_, _, NextOrFail::Next(ref mut o))
| Instruction::DynamicInternalElse(_, _, NextOrFail::Next(ref mut o))
Instruction::DynamicElse(_, _, NextOrFail::Next(o))
| Instruction::DynamicInternalElse(_, _, NextOrFail::Next(o))
if target_loc >= instr_loc =>
{
retraction_info
@@ -588,7 +588,7 @@ fn thread_choice_instr_at_to(
Instruction::TryMeElse(o) | Instruction::RetryMeElse(o) => {
instr_loc += *o;
}
Instruction::RevJmpBy(ref mut o) if instr_loc >= target_loc => {
Instruction::RevJmpBy(o) if instr_loc >= target_loc => {
retraction_info.push_record(RetractionRecord::ModifiedRevJmpBy(instr_loc, *o));
*o = instr_loc - target_loc;
@@ -631,7 +631,7 @@ fn thread_choice_instr_at_to(
Instruction::DynamicInternalElse(_, _, NextOrFail::Fail(o)) if *o > 0 => {
instr_loc += *o;
}
Instruction::TrustMe(ref mut o) if target_loc >= instr_loc => {
Instruction::TrustMe(o) if target_loc >= instr_loc => {
retraction_info.push_record(
RetractionRecord::AppendedTrustMe(instr_loc, *o, false),
//choice_instr.is_default()),
@@ -657,7 +657,7 @@ fn remove_non_leading_clause(
retraction_info: &mut RetractionInfo,
) -> Option<IndexPtr> {
match &mut code[non_indexed_choice_instr_loc] {
Instruction::RetryMeElse(ref mut o) => {
Instruction::RetryMeElse(o) => {
let o = *o;
thread_choice_instr_at_to(
@@ -680,7 +680,7 @@ fn remove_non_leading_clause(
None
}
Instruction::TryMeElse(ref mut o) => {
Instruction::TryMeElse(o) => {
retraction_info.push_record(RetractionRecord::ModifiedTryMeElse(
preceding_choice_instr_loc,
*o,
@@ -730,7 +730,7 @@ fn remove_leading_unindexed_clause(
retraction_info: &mut RetractionInfo,
) -> Option<IndexPtr> {
match &mut code[non_indexed_choice_instr_loc] {
Instruction::TryMeElse(ref mut o) => {
Instruction::TryMeElse(o) => {
if *o > 0 {
retraction_info.push_record(RetractionRecord::ModifiedTryMeElse(
non_indexed_choice_instr_loc,
@@ -935,10 +935,10 @@ fn prepend_compiled_clause(
let prepend_queue_len = prepend_queue.len();
match &mut prepend_queue[1] {
Instruction::TryMeElse(ref mut o) if *o == 0 => {
Instruction::TryMeElse(o) if *o == 0 => {
*o = prepend_queue_len - 2;
}
Instruction::DynamicInternalElse(_, _, ref mut o @ NextOrFail::Next(0)) => {
Instruction::DynamicInternalElse(_, _, o @ NextOrFail::Next(0)) => {
*o = NextOrFail::Fail(prepend_queue_len - 2);
}
_ => {
@@ -1632,8 +1632,8 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
};
match &mut self.wam_prelude.code[clause_loc] {
Instruction::DynamicElse(_, ref mut d, _)
| Instruction::DynamicInternalElse(_, ref mut d, _) => {
Instruction::DynamicElse(_, d, _)
| Instruction::DynamicInternalElse(_, d, _) => {
*d = Death::Finite(LS::machine_st(&mut self.payload).global_clock);
}
_ => unreachable!(),

View File

@@ -1365,8 +1365,8 @@ impl Machine {
let p = self.machine_st.p;
let indexed_choice_instrs = match &self.code[p] {
Instruction::IndexingCode(ref indexing_code) => match &indexing_code[oi as usize] {
IndexingLine::DynamicIndexedChoice(ref indexed_choice_instrs) => {
Instruction::IndexingCode(indexing_code) => match &indexing_code[oi as usize] {
IndexingLine::DynamicIndexedChoice(indexed_choice_instrs) => {
indexed_choice_instrs
}
_ => unreachable!(),
@@ -1376,7 +1376,7 @@ impl Machine {
loop {
match &indexed_choice_instrs.get(ii as usize) {
Some(&offset) => match &self.code[p + offset - 1] {
&Some(&offset) => match &self.code[p + offset - 1] {
&Instruction::DynamicInternalElse(birth, death, next_or_fail) => {
if birth < self.machine_st.cc && Death::Finite(self.machine_st.cc) <= death
{
@@ -2670,7 +2670,7 @@ impl Machine {
self.machine_st.backtrack();
}
}
Instruction::CallNumberLessThanOrEqual(ref at_1, ref at_2) => {
Instruction::CallNumberLessThanOrEqual(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -2692,7 +2692,7 @@ impl Machine {
}
}
}
Instruction::ExecuteNumberLessThanOrEqual(ref at_1, ref at_2) => {
Instruction::ExecuteNumberLessThanOrEqual(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -2714,7 +2714,7 @@ impl Machine {
}
}
}
Instruction::CallNumberEqual(ref at_1, ref at_2) => {
Instruction::CallNumberEqual(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -2736,7 +2736,7 @@ impl Machine {
}
}
}
Instruction::ExecuteNumberEqual(ref at_1, ref at_2) => {
Instruction::ExecuteNumberEqual(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -2758,7 +2758,7 @@ impl Machine {
}
}
}
Instruction::CallNumberNotEqual(ref at_1, ref at_2) => {
Instruction::CallNumberNotEqual(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -2780,7 +2780,7 @@ impl Machine {
}
}
}
Instruction::ExecuteNumberNotEqual(ref at_1, ref at_2) => {
Instruction::ExecuteNumberNotEqual(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -2802,7 +2802,7 @@ impl Machine {
}
}
}
Instruction::CallNumberGreaterThanOrEqual(ref at_1, ref at_2) => {
Instruction::CallNumberGreaterThanOrEqual(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -2824,7 +2824,7 @@ impl Machine {
}
}
}
Instruction::ExecuteNumberGreaterThanOrEqual(ref at_1, ref at_2) => {
Instruction::ExecuteNumberGreaterThanOrEqual(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -2846,7 +2846,7 @@ impl Machine {
}
}
}
Instruction::CallNumberGreaterThan(ref at_1, ref at_2) => {
Instruction::CallNumberGreaterThan(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -2868,7 +2868,7 @@ impl Machine {
}
}
}
Instruction::ExecuteNumberGreaterThan(ref at_1, ref at_2) => {
Instruction::ExecuteNumberGreaterThan(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -2890,7 +2890,7 @@ impl Machine {
}
}
}
Instruction::CallNumberLessThan(ref at_1, ref at_2) => {
Instruction::CallNumberLessThan(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -2912,7 +2912,7 @@ impl Machine {
}
}
}
Instruction::ExecuteNumberLessThan(ref at_1, ref at_2) => {
Instruction::ExecuteNumberLessThan(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -2934,7 +2934,7 @@ impl Machine {
}
}
}
Instruction::DefaultCallNumberLessThanOrEqual(ref at_1, ref at_2) => {
Instruction::DefaultCallNumberLessThanOrEqual(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -2955,7 +2955,7 @@ impl Machine {
}
}
}
Instruction::DefaultExecuteNumberLessThanOrEqual(ref at_1, ref at_2) => {
Instruction::DefaultExecuteNumberLessThanOrEqual(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -2976,7 +2976,7 @@ impl Machine {
}
}
}
Instruction::DefaultCallNumberNotEqual(ref at_1, ref at_2) => {
Instruction::DefaultCallNumberNotEqual(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -2997,7 +2997,7 @@ impl Machine {
}
}
}
Instruction::DefaultExecuteNumberNotEqual(ref at_1, ref at_2) => {
Instruction::DefaultExecuteNumberNotEqual(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -3018,7 +3018,7 @@ impl Machine {
}
}
}
Instruction::DefaultCallNumberEqual(ref at_1, ref at_2) => {
Instruction::DefaultCallNumberEqual(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -3039,7 +3039,7 @@ impl Machine {
}
}
}
Instruction::DefaultExecuteNumberEqual(ref at_1, ref at_2) => {
Instruction::DefaultExecuteNumberEqual(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -3060,7 +3060,7 @@ impl Machine {
}
}
}
Instruction::DefaultCallNumberGreaterThanOrEqual(ref at_1, ref at_2) => {
Instruction::DefaultCallNumberGreaterThanOrEqual(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -3081,7 +3081,7 @@ impl Machine {
}
}
}
Instruction::DefaultExecuteNumberGreaterThanOrEqual(ref at_1, ref at_2) => {
Instruction::DefaultExecuteNumberGreaterThanOrEqual(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -3102,7 +3102,7 @@ impl Machine {
}
}
}
Instruction::DefaultCallNumberGreaterThan(ref at_1, ref at_2) => {
Instruction::DefaultCallNumberGreaterThan(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -3123,7 +3123,7 @@ impl Machine {
}
}
}
Instruction::DefaultExecuteNumberGreaterThan(ref at_1, ref at_2) => {
Instruction::DefaultExecuteNumberGreaterThan(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -3144,7 +3144,7 @@ impl Machine {
}
}
}
Instruction::DefaultCallNumberLessThan(ref at_1, ref at_2) => {
Instruction::DefaultCallNumberLessThan(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -3165,7 +3165,7 @@ impl Machine {
}
}
}
Instruction::DefaultExecuteNumberLessThan(ref at_1, ref at_2) => {
Instruction::DefaultExecuteNumberLessThan(at_1, at_2) => {
let n1 = try_or_throw!(
self.machine_st,
self.machine_st.get_number(at_1),
@@ -3640,7 +3640,7 @@ impl Machine {
&Instruction::Proceed => {
self.machine_st.p = self.machine_st.cp;
}
Instruction::IndexingCode(ref indexing_lines) => {
Instruction::IndexingCode(indexing_lines) => {
match &indexing_lines[self.machine_st.oip as usize] {
IndexingLine::Indexing(_) => {
self.execute_switch_on_term();
@@ -3649,7 +3649,7 @@ impl Machine {
self.machine_st.backtrack();
}
}
IndexingLine::IndexedChoice(ref indexed_choice) => {
IndexingLine::IndexedChoice(indexed_choice) => {
match indexed_choice[self.machine_st.iip as usize] {
IndexedChoiceInstruction::Try(offset) => {
backtrack_on_resource_error!(

View File

@@ -57,7 +57,7 @@ struct InnerHeap {
}
impl InnerHeap {
unsafe fn grow(&mut self) -> bool {
unsafe fn grow(&mut self) -> bool { unsafe {
let new_cap = if self.byte_cap == 0 {
256 * 256 * 8
} else {
@@ -88,7 +88,7 @@ impl InnerHeap {
} else {
false
}
}
}}
}
unsafe impl Send for Heap {}
@@ -101,7 +101,7 @@ pub struct HeapStringScan<'a> {
}
// The heap_slice should be inside the heap
unsafe fn scan_slice_to_str(heap_slice: &[u8]) -> HeapStringScan<'_> {
unsafe fn scan_slice_to_str(heap_slice: &[u8]) -> HeapStringScan<'_> { unsafe {
let string_len = heap_slice
.iter()
.position(|b| *b == 0u8)
@@ -120,11 +120,11 @@ unsafe fn scan_slice_to_str(heap_slice: &[u8]) -> HeapStringScan<'_> {
string: std::str::from_utf8_unchecked(str_slice),
tail_idx,
}
}
}}
// Same as scan_slice_to_str but assumes that the slice is from the start of a string.
// Can be used on strings out of the heap.
unsafe fn scan_slice_to_str_from_start(heap_slice: &[u8]) -> HeapStringScan<'_> {
unsafe fn scan_slice_to_str_from_start(heap_slice: &[u8]) -> HeapStringScan<'_> { unsafe {
let string_len = heap_slice
.iter()
.position(|b| *b == 0u8)
@@ -142,7 +142,7 @@ unsafe fn scan_slice_to_str_from_start(heap_slice: &[u8]) -> HeapStringScan<'_>
string: std::str::from_utf8_unchecked(str_slice),
tail_idx,
}
}
}}
#[derive(Debug, Clone, Copy)]
pub(crate) enum PStrContinuable {
@@ -585,9 +585,9 @@ impl Heap {
}
#[inline(always)]
unsafe fn grow(&mut self) -> bool {
unsafe fn grow(&mut self) -> bool { unsafe {
self.inner.grow()
}
}}
#[inline]
fn resource_error_offset(&self) -> usize {

View File

@@ -34,7 +34,7 @@ pub(super) fn set_code_index<'a, LS: LoadState<'a>>(
RetractionRecord::ReplacedUserPredicate(key, replaced)
}
}
CompilationTarget::Module(ref module_name) => {
CompilationTarget::Module(module_name) => {
if IndexPtrTag::Undefined == code_idx_ptr.tag() {
*code_idx_ptr = code_ptr;
RetractionRecord::AddedModulePredicate(*module_name, key)
@@ -98,7 +98,7 @@ pub(super) fn add_op_decl(
CompilationTarget::User => {
retraction_info.push_record(RetractionRecord::ReplacedUserOp(*op_decl, op_desc));
}
CompilationTarget::Module(ref module_name) => {
CompilationTarget::Module(module_name) => {
retraction_info.push_record(RetractionRecord::ReplacedModuleOp(
*module_name,
*op_decl,
@@ -110,7 +110,7 @@ pub(super) fn add_op_decl(
CompilationTarget::User => {
retraction_info.push_record(RetractionRecord::AddedUserOp(*op_decl));
}
CompilationTarget::Module(ref module_name) => {
CompilationTarget::Module(module_name) => {
retraction_info
.push_record(RetractionRecord::AddedModuleOp(*module_name, *op_decl));
}
@@ -167,7 +167,7 @@ pub(super) fn import_module_exports<'a, LS: LoadState<'a>>(
));
}
}
ModuleExport::OpDecl(ref op_decl) => {
ModuleExport::OpDecl(op_decl) => {
add_op_decl(
&mut payload.retraction_info,
compilation_target,
@@ -221,7 +221,7 @@ fn import_module_exports_into_module<'a, LS: LoadState<'a>>(
));
}
}
ModuleExport::OpDecl(ref op_decl) => {
ModuleExport::OpDecl(op_decl) => {
add_op_decl_as_module_export::<LS>(payload, op_dir, wam_op_dir, op_decl);
}
}
@@ -276,7 +276,7 @@ fn import_qualified_module_exports<'a, LS: LoadState<'a>>(
));
}
}
ModuleExport::OpDecl(ref op_decl) => {
ModuleExport::OpDecl(op_decl) => {
add_op_decl(
&mut payload.retraction_info,
compilation_target,
@@ -336,7 +336,7 @@ fn import_qualified_module_exports_into_module<'a, LS: LoadState<'a>>(
));
}
}
ModuleExport::OpDecl(ref op_decl) => {
ModuleExport::OpDecl(op_decl) => {
add_op_decl_as_module_export::<LS>(payload, op_dir, wam_op_dir, op_decl);
}
}
@@ -545,7 +545,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
) {
for export in removed_module.module_decl.exports.iter() {
match export {
ModuleExport::PredicateKey(ref key) => {
ModuleExport::PredicateKey(key) => {
if let (Some(module_code_idx), Some(target_code_idx)) = (
removed_module.code_dir.get(key).cloned(),
code_dir.get_mut(key).cloned(),
@@ -1050,7 +1050,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
);
for export in &module.module_decl.exports {
if let ModuleExport::OpDecl(ref op_decl) = export {
if let ModuleExport::OpDecl(op_decl) = export {
add_op_decl_as_module_export::<LS>(
&mut self.payload,
&mut module.op_dir,
@@ -1084,7 +1084,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
&mut self.wam_prelude.indices.meta_predicates,
)?;
}
CompilationTarget::Module(ref defining_module_name) => {
CompilationTarget::Module(defining_module_name) => {
match self
.wam_prelude
.indices
@@ -1137,7 +1137,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
&exports,
&mut self.wam_prelude,
),
CompilationTarget::Module(ref defining_module_name) => {
CompilationTarget::Module(defining_module_name) => {
match self
.wam_prelude
.indices

View File

@@ -160,7 +160,7 @@ impl fmt::Display for CompilationTarget {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
CompilationTarget::User => write!(f, "user"),
CompilationTarget::Module(ref module_name) => write!(f, "{}", module_name.as_str()),
CompilationTarget::Module(module_name) => write!(f, "{}", module_name.as_str()),
}
}
}
@@ -821,7 +821,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
{
if let IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(
_,
ref mut v,
v,
..,
)) = &mut indexing_code[0]
{
@@ -1110,7 +1110,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
}
}
}
CompilationTarget::Module(ref module_name) => {
CompilationTarget::Module(module_name) => {
match self.wam_prelude.indices.modules.get_mut(module_name) {
Some(ref mut module) => match module.extensible_predicates.get_mut(&key) {
Some(ref mut skeleton) => {
@@ -1364,7 +1364,7 @@ impl<'a> MachinePreludeView<'a> {
) -> CompositeOpDir<'_, '_> {
match compilation_target {
CompilationTarget::User => CompositeOpDir::new(&self.indices.op_dir, None),
CompilationTarget::Module(ref module_name) => {
CompilationTarget::Module(module_name) => {
match self.indices.modules.get(module_name) {
Some(module) => CompositeOpDir::new(&self.indices.op_dir, Some(&module.op_dir)),
None => {
@@ -2374,7 +2374,7 @@ impl Machine {
MetaSpec::Plus => atom_as_cell!(atom!("-")),
MetaSpec::Either => atom_as_cell!(atom!("?")),
MetaSpec::Colon => atom_as_cell!(atom!(":")),
MetaSpec::RequiresExpansionWithArgument(ref arg_num) => {
MetaSpec::RequiresExpansionWithArgument(arg_num) => {
fixnum_as_cell!(/* FIXME this is not safe */ unsafe {
Fixnum::build_with_unchecked(*arg_num as i64)
})

View File

@@ -900,7 +900,7 @@ impl CompilationError {
CompilationError::InvalidUseModuleDecl => {
functor!(atom!("invalid_use_module_declaration"))
}
CompilationError::ParserError(ref err) => {
CompilationError::ParserError(err) => {
functor!(err.as_atom())
}
CompilationError::FiniteMemoryInHeap(_) => {

View File

@@ -292,7 +292,7 @@ impl IndexStore {
) -> Option<&mut PredicateSkeleton> {
match compilation_target {
CompilationTarget::User => self.extensible_predicates.get_mut(key),
CompilationTarget::Module(ref module_name) => {
CompilationTarget::Module(module_name) => {
if let Some(module) = self.modules.get_mut(module_name) {
module.extensible_predicates.get_mut(key)
} else {
@@ -309,7 +309,7 @@ impl IndexStore {
) -> Option<&PredicateSkeleton> {
match compilation_target {
CompilationTarget::User => self.extensible_predicates.get(key),
CompilationTarget::Module(ref module_name) => {
CompilationTarget::Module(module_name) => {
if let Some(module) = self.modules.get(module_name) {
module.extensible_predicates.get(key)
} else {
@@ -380,7 +380,7 @@ impl IndexStore {
) -> Option<PredicateSkeleton> {
match compilation_target {
CompilationTarget::User => self.extensible_predicates.swap_remove(key),
CompilationTarget::Module(ref module_name) => {
CompilationTarget::Module(module_name) => {
if let Some(module) = self.modules.get_mut(module_name) {
module.extensible_predicates.swap_remove(key)
} else {
@@ -413,7 +413,7 @@ impl IndexStore {
) -> Option<&Vec<MetaSpec>> {
match compilation_target {
CompilationTarget::User => self.meta_predicates.get(&(name, arity)),
CompilationTarget::Module(ref module_name) => match self.modules.get(module_name) {
CompilationTarget::Module(module_name) => match self.modules.get(module_name) {
Some(module) => module
.meta_predicates
.get(&(name, arity))

View File

@@ -1133,7 +1133,7 @@ impl CWIL {
limit = limit.strict_add(self.local_count);
match self.limits.last() {
Some((ref inner_limit, _)) if *inner_limit <= limit => {}
Some((inner_limit, _)) if *inner_limit <= limit => {}
_ => self.limits.push((limit, block)),
}

View File

@@ -1224,7 +1224,7 @@ impl Machine {
let key = Atom::from(h as u64);
match self.indices.global_variables.get_mut(&key) {
Some((_, ref mut loc)) => *loc = None,
Some((_, loc)) => *loc = None,
None => unreachable!(),
}
}
@@ -1233,7 +1233,7 @@ impl Machine {
let value_cell = HeapCellValue::from(u64::from(self.machine_st.trail[i + 1]));
match self.indices.global_variables.get_mut(&key) {
Some((_, ref mut loc)) => *loc = Some(value_cell),
Some((_, loc)) => *loc = Some(value_cell),
None => unreachable!(),
}
}

View File

@@ -82,7 +82,7 @@ fn setup_op_decl(mut terms: Vec<Term>) -> Result<OpDecl, CompilationError> {
fn setup_predicate_indicator(term: &mut Term) -> Result<PredicateKey, CompilationError> {
match term {
Term::Clause(_, slash, ref mut terms)
Term::Clause(_, slash, terms)
if (*slash == atom!("/") || *slash == atom!("//")) && terms.len() == 2 =>
{
let arity = terms.pop().unwrap();

View File

@@ -175,7 +175,7 @@ impl Stack {
}
#[inline(always)]
unsafe fn alloc(&mut self, frame_size: usize) -> Result<NonNull<u8>, AllocError> {
unsafe fn alloc(&mut self, frame_size: usize) -> Result<NonNull<u8>, AllocError> { unsafe {
loop {
let ptr = self.buf.alloc(frame_size);
if let Some(ptr) = NonNull::new(ptr) {
@@ -183,7 +183,7 @@ impl Stack {
}
self.buf.grow()?;
}
}
}}
pub(crate) fn allocate_and_frame(&mut self, num_cells: usize) -> Result<usize, AllocError> {
let frame_size = AndFrame::size_of(num_cells);

View File

@@ -750,49 +750,49 @@ impl Stream {
pub fn options(&self) -> &StreamOptions {
match self {
Stream::Byte(ref ptr) => &ptr.options,
Stream::InputFile(ref ptr) => &ptr.options,
Stream::OutputFile(ref ptr) => &ptr.options,
Stream::StaticString(ref ptr) => &ptr.options,
Stream::NamedTcp(ref ptr) => &ptr.options,
Stream::Byte(ptr) => &ptr.options,
Stream::InputFile(ptr) => &ptr.options,
Stream::OutputFile(ptr) => &ptr.options,
Stream::StaticString(ptr) => &ptr.options,
Stream::NamedTcp(ptr) => &ptr.options,
#[cfg(feature = "tls")]
Stream::NamedTls(ref ptr) => &ptr.options,
Stream::NamedTls(ptr) => &ptr.options,
#[cfg(feature = "http")]
Stream::HttpRead(ref ptr) => &ptr.options,
Stream::HttpRead(ptr) => &ptr.options,
#[cfg(feature = "http")]
Stream::HttpWrite(ref ptr) => &ptr.options,
Stream::Null(ref options) => options,
Stream::Readline(ref ptr) => &ptr.options,
Stream::StandardOutput(ref ptr) => &ptr.options,
Stream::StandardError(ref ptr) => &ptr.options,
Stream::Callback(ref ptr) => &ptr.options,
Stream::InputChannel(ref ptr) => &ptr.options,
Stream::PipeReader(ref ptr) => &ptr.options,
Stream::PipeWriter(ref ptr) => &ptr.options,
Stream::HttpWrite(ptr) => &ptr.options,
Stream::Null(options) => options,
Stream::Readline(ptr) => &ptr.options,
Stream::StandardOutput(ptr) => &ptr.options,
Stream::StandardError(ptr) => &ptr.options,
Stream::Callback(ptr) => &ptr.options,
Stream::InputChannel(ptr) => &ptr.options,
Stream::PipeReader(ptr) => &ptr.options,
Stream::PipeWriter(ptr) => &ptr.options,
}
}
pub(super) fn options_mut(&mut self) -> &mut StreamOptions {
match self {
Stream::Byte(ref mut ptr) => &mut ptr.options,
Stream::InputFile(ref mut ptr) => &mut ptr.options,
Stream::OutputFile(ref mut ptr) => &mut ptr.options,
Stream::StaticString(ref mut ptr) => &mut ptr.options,
Stream::NamedTcp(ref mut ptr) => &mut ptr.options,
Stream::Byte(ptr) => &mut ptr.options,
Stream::InputFile(ptr) => &mut ptr.options,
Stream::OutputFile(ptr) => &mut ptr.options,
Stream::StaticString(ptr) => &mut ptr.options,
Stream::NamedTcp(ptr) => &mut ptr.options,
#[cfg(feature = "tls")]
Stream::NamedTls(ref mut ptr) => &mut ptr.options,
Stream::NamedTls(ptr) => &mut ptr.options,
#[cfg(feature = "http")]
Stream::HttpRead(ref mut ptr) => &mut ptr.options,
Stream::HttpRead(ptr) => &mut ptr.options,
#[cfg(feature = "http")]
Stream::HttpWrite(ref mut ptr) => &mut ptr.options,
Stream::Null(ref mut options) => options,
Stream::Readline(ref mut ptr) => &mut ptr.options,
Stream::StandardOutput(ref mut ptr) => &mut ptr.options,
Stream::StandardError(ref mut ptr) => &mut ptr.options,
Stream::Callback(ref mut ptr) => &mut ptr.options,
Stream::InputChannel(ref mut ptr) => &mut ptr.options,
Stream::PipeReader(ref mut ptr) => &mut ptr.options,
Stream::PipeWriter(ref mut ptr) => &mut ptr.options,
Stream::HttpWrite(ptr) => &mut ptr.options,
Stream::Null(options) => options,
Stream::Readline(ptr) => &mut ptr.options,
Stream::StandardOutput(ptr) => &mut ptr.options,
Stream::StandardError(ptr) => &mut ptr.options,
Stream::Callback(ptr) => &mut ptr.options,
Stream::InputChannel(ptr) => &mut ptr.options,
Stream::PipeReader(ptr) => &mut ptr.options,
Stream::PipeWriter(ptr) => &mut ptr.options,
}
}
@@ -960,17 +960,17 @@ impl CharRead for Stream {
fn consume(&mut self, nread: usize) {
match self {
Stream::InputFile(ref mut file) => file.consume(nread),
Stream::NamedTcp(ref mut tcp_stream) => tcp_stream.consume(nread),
Stream::InputFile(file) => file.consume(nread),
Stream::NamedTcp(tcp_stream) => tcp_stream.consume(nread),
#[cfg(feature = "tls")]
Stream::NamedTls(ref mut tls_stream) => tls_stream.consume(nread),
Stream::NamedTls(tls_stream) => tls_stream.consume(nread),
#[cfg(feature = "http")]
Stream::HttpRead(ref mut http_stream) => http_stream.consume(nread),
Stream::Readline(ref mut rl_stream) => rl_stream.consume(nread),
Stream::StaticString(ref mut src) => src.consume(nread),
Stream::Byte(ref mut cursor) => cursor.consume(nread),
Stream::InputChannel(ref mut cursor) => cursor.consume(nread),
Stream::PipeReader(ref mut cursor) => cursor.consume(nread),
Stream::HttpRead(http_stream) => http_stream.consume(nread),
Stream::Readline(rl_stream) => rl_stream.consume(nread),
Stream::StaticString(src) => src.consume(nread),
Stream::Byte(cursor) => cursor.consume(nread),
Stream::InputChannel(cursor) => cursor.consume(nread),
Stream::PipeReader(cursor) => cursor.consume(nread),
#[cfg(feature = "http")]
Stream::HttpWrite(_) => {}
Stream::OutputFile(_)
@@ -1019,17 +1019,17 @@ impl Read for Stream {
impl Write for Stream {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
match self {
Stream::OutputFile(ref mut file) => file.write(buf),
Stream::NamedTcp(ref mut tcp_stream) => tcp_stream.get_mut().write(buf),
Stream::OutputFile(file) => file.write(buf),
Stream::NamedTcp(tcp_stream) => tcp_stream.get_mut().write(buf),
#[cfg(feature = "tls")]
Stream::NamedTls(ref mut tls_stream) => tls_stream.get_mut().write(buf),
Stream::Byte(ref mut cursor) => cursor.get_mut().write(buf),
Stream::Callback(ref mut callback_stream) => callback_stream.get_mut().write(buf),
Stream::NamedTls(tls_stream) => tls_stream.get_mut().write(buf),
Stream::Byte(cursor) => cursor.get_mut().write(buf),
Stream::Callback(callback_stream) => callback_stream.get_mut().write(buf),
Stream::StandardOutput(stream) => stream.write(buf),
Stream::StandardError(stream) => stream.write(buf),
#[cfg(feature = "http")]
Stream::HttpWrite(ref mut stream) => stream.get_mut().write(buf),
Stream::PipeWriter(ref mut stream) => stream.get_mut().write(buf),
Stream::HttpWrite(stream) => stream.get_mut().write(buf),
Stream::PipeWriter(stream) => stream.get_mut().write(buf),
#[cfg(feature = "http")]
Stream::HttpRead(_) => Err(std::io::Error::new(
ErrorKind::PermissionDenied,
@@ -1049,17 +1049,17 @@ impl Write for Stream {
fn flush(&mut self) -> std::io::Result<()> {
match self {
Stream::OutputFile(ref mut file) => file.stream.flush(),
Stream::NamedTcp(ref mut tcp_stream) => tcp_stream.stream.get_mut().flush(),
Stream::OutputFile(file) => file.stream.flush(),
Stream::NamedTcp(tcp_stream) => tcp_stream.stream.get_mut().flush(),
#[cfg(feature = "tls")]
Stream::NamedTls(ref mut tls_stream) => tls_stream.stream.get_mut().flush(),
Stream::Byte(ref mut cursor) => cursor.stream.get_mut().flush(),
Stream::Callback(ref mut callback_stream) => callback_stream.stream.get_mut().flush(),
Stream::NamedTls(tls_stream) => tls_stream.stream.get_mut().flush(),
Stream::Byte(cursor) => cursor.stream.get_mut().flush(),
Stream::Callback(callback_stream) => callback_stream.stream.get_mut().flush(),
Stream::StandardError(stream) => stream.stream.flush(),
Stream::StandardOutput(stream) => stream.stream.flush(),
Stream::PipeWriter(ref mut stream) => stream.stream.get_mut().flush(),
Stream::PipeWriter(stream) => stream.stream.get_mut().flush(),
#[cfg(feature = "http")]
Stream::HttpWrite(ref mut stream) => stream.stream.get_mut().flush(),
Stream::HttpWrite(stream) => stream.stream.get_mut().flush(),
#[cfg(feature = "http")]
Stream::HttpRead(_) => Err(std::io::Error::new(
ErrorKind::PermissionDenied,
@@ -1530,58 +1530,58 @@ impl Stream {
#[inline]
pub(crate) fn close(&mut self) -> Result<(), std::io::Error> {
match self {
Stream::NamedTcp(ref mut tcp_stream) => {
Stream::NamedTcp(tcp_stream) => {
tcp_stream.inner_mut().tcp_stream.shutdown(Shutdown::Both)
}
#[cfg(feature = "tls")]
Stream::NamedTls(ref mut tls_stream) => tls_stream.inner_mut().tls_stream.shutdown(),
Stream::NamedTls(tls_stream) => tls_stream.inner_mut().tls_stream.shutdown(),
#[cfg(feature = "http")]
Stream::HttpRead(ref mut http_stream) => {
Stream::HttpRead(http_stream) => {
http_stream.drop_payload();
Ok(())
}
#[cfg(feature = "http")]
Stream::HttpWrite(mut http_stream) => {
&mut Stream::HttpWrite(mut http_stream) => {
http_stream.drop_payload();
Ok(())
}
Stream::InputFile(mut file_stream) => {
&mut Stream::InputFile(mut file_stream) => {
// close the stream by dropping the inner File.
file_stream.drop_payload();
Ok(())
}
Stream::OutputFile(mut file_stream) => {
&mut Stream::OutputFile(mut file_stream) => {
// close the stream by dropping the inner File.
file_stream.drop_payload();
Ok(())
}
Stream::Byte(mut stream) => {
&mut Stream::Byte(mut stream) => {
stream.drop_payload();
Ok(())
}
Stream::Callback(mut stream) => {
&mut Stream::Callback(mut stream) => {
stream.drop_payload();
Ok(())
}
Stream::InputChannel(mut stream) => {
&mut Stream::InputChannel(mut stream) => {
stream.drop_payload();
Ok(())
}
Stream::StaticString(mut stream) => {
&mut Stream::StaticString(mut stream) => {
stream.drop_payload();
Ok(())
}
Stream::PipeReader(mut stream) => {
&mut Stream::PipeReader(mut stream) => {
stream.drop_payload();
Ok(())
}
Stream::PipeWriter(mut stream) => {
&mut Stream::PipeWriter(mut stream) => {
stream.drop_payload();
Ok(())
}
@@ -1644,11 +1644,11 @@ impl Stream {
self.set_past_end_of_stream(false);
match self {
Stream::Byte(ref mut cursor) => {
Stream::Byte(cursor) => {
cursor.stream.get_mut().0.set_position(0);
true
}
Stream::InputFile(ref mut file_stream) => {
Stream::InputFile(file_stream) => {
file_stream
.stream
.get_mut()
@@ -1657,11 +1657,11 @@ impl Stream {
.unwrap();
true
}
Stream::Readline(ref mut readline_stream) => {
Stream::Readline(readline_stream) => {
readline_stream.reset();
true
}
Stream::InputChannel(ref mut input_channel_stream) => {
Stream::InputChannel(input_channel_stream) => {
input_channel_stream.stream.get_mut().inner.set_position(0);
true
}
@@ -1672,7 +1672,7 @@ impl Stream {
#[inline]
pub(crate) fn peek_byte(&mut self) -> std::io::Result<u8> {
match self {
Stream::Byte(ref mut cursor) => {
Stream::Byte(cursor) => {
let mut b = [0u8; 1];
let pos = cursor.stream.get_mut().0.position();
@@ -1684,15 +1684,15 @@ impl Stream {
_ => Err(std::io::Error::new(ErrorKind::UnexpectedEof, "end of file")),
}
}
Stream::InputFile(ref mut file) => match file.peek_byte() {
Stream::InputFile(file) => match file.peek_byte() {
Some(result) => Ok(result?),
_ => Err(std::io::Error::new(
ErrorKind::UnexpectedEof,
StreamError::PeekByteFailed,
)),
},
Stream::Readline(ref mut stream) => stream.stream.peek_byte(),
Stream::NamedTcp(ref mut stream) => {
Stream::Readline(stream) => stream.stream.peek_byte(),
Stream::NamedTcp(stream) => {
let mut b = [0u8; 1];
stream.stream.get_mut().tcp_stream.peek(&mut b)?;
Ok(b[0])

View File

@@ -1252,7 +1252,7 @@ impl Machine {
loop {
match &self.code[bp] {
Instruction::IndexingCode(ref indexing_code) => {
Instruction::IndexingCode(indexing_code) => {
let indexing_code_ptr = match &indexing_code[0] {
&IndexingLine::Indexing(IndexingInstruction::SwitchOnTerm(
_,
@@ -1275,10 +1275,10 @@ impl Machine {
let boip = extract_ptr!(indexing_code_ptr);
let boip = match &indexing_code[boip] {
IndexingLine::Indexing(IndexingInstruction::SwitchOnStructure(ref hm)) => {
IndexingLine::Indexing(IndexingInstruction::SwitchOnStructure(hm)) => {
boip + extract_ptr!(hm.get(&key).cloned().unwrap())
}
IndexingLine::Indexing(IndexingInstruction::SwitchOnConstant(ref hm)) => {
IndexingLine::Indexing(IndexingInstruction::SwitchOnConstant(hm)) => {
boip + extract_ptr!(hm.get(&atom_as_cell!(key.0)).cloned().unwrap())
}
_ => boip,
@@ -3138,7 +3138,7 @@ impl Machine {
let addr = self.machine_st.registers[2];
match self.indices.global_variables.get_mut(&key) {
Some((ref ball, ref mut loc)) => match loc {
Some(&mut (ref ball, ref mut loc)) => match loc {
Some(value_loc) => {
unify_fn!(self.machine_st, addr, *value_loc);
}
@@ -4319,7 +4319,7 @@ impl Machine {
#[inline(always)]
pub(crate) fn maybe(&mut self) {
self.machine_st.fail = self.rng.gen();
self.machine_st.fail = self.rng.r#gen();
}
#[cfg(not(target_arch = "wasm32"))]
@@ -7522,8 +7522,8 @@ impl Machine {
let new_value = self.deref_register(2);
match self.indices.global_variables.get_mut(&key) {
Some((_, ref mut loc)) => match loc {
Some(ref mut value) => {
Some((_, loc)) => match loc {
Some(value) => {
self.machine_st
.trail(TrailRef::BlackboardOffset(key, *value));
*value = new_value;
@@ -8667,7 +8667,8 @@ impl Machine {
.value_to_str_like(self.machine_st.registers[2])
.unwrap();
env::set_var(&*key.as_str(), &*value.as_str());
// TODO: Audit that the environment access only happens in single-threaded code.
unsafe { env::set_var(&*key.as_str(), &*value.as_str()) };
}
#[inline(always)]
@@ -8676,7 +8677,8 @@ impl Machine {
.machine_st
.value_to_str_like(self.machine_st.registers[1])
.unwrap();
env::remove_var(&*key.as_str());
// TODO: Audit that the environment access only happens in single-threaded code.
unsafe { env::remove_var(&*key.as_str()) };
}
#[inline(always)]

View File

@@ -211,7 +211,7 @@ impl<T: RawBlockTraits> SerialOffsetTable<T> {
})
}
unsafe fn build_with(&mut self, value: T) -> usize {
unsafe fn build_with(&mut self, value: T) -> usize { unsafe {
let mut ptr;
loop {
@@ -228,17 +228,17 @@ impl<T: RawBlockTraits> SerialOffsetTable<T> {
ptr::write(ptr as *mut T, value);
// SAFETY: `ptr` was obtained from `self.block.alloc()`
self.block.get_offset(ptr)
}
}}
#[inline]
unsafe fn lookup(&self, offset: usize) -> &T {
unsafe fn lookup(&self, offset: usize) -> &T { unsafe {
&*self.block.get_unchecked(offset).cast::<T>()
}
}}
#[inline]
unsafe fn lookup_mut(&mut self, offset: usize) -> &mut T {
unsafe fn lookup_mut(&mut self, offset: usize) -> &mut T { unsafe {
&mut *self.block.get_unchecked(offset).cast::<T>().cast_mut()
}
}}
#[allow(clippy::wrong_self_convention)]
fn to_concurrent(&mut self) -> ConcurrentOffsetTable<T>

View File

@@ -877,7 +877,7 @@ pub enum Term {
impl Term {
pub fn first_arg(&self) -> Option<&Term> {
match self {
Term::Clause(_, _, ref terms) => terms.first(),
Term::Clause(_, _, terms) => terms.first(),
_ => None,
}
}
@@ -892,14 +892,14 @@ impl Term {
pub fn arity(&self) -> usize {
match self {
Term::Clause(_, _, ref child_terms, ..) => child_terms.len(),
Term::Clause(_, _, child_terms, ..) => child_terms.len(),
_ => 0,
}
}
}
pub(crate) fn unfold_by_str_once(term: &mut Term, s: Atom) -> Option<(Term, Term)> {
if let Term::Clause(_, ref name, ref mut subterms) = term {
if let &mut Term::Clause(_, ref name, ref mut subterms) = term {
if let Some(Term::Literal(_, Literal::CodeIndexOffset(_))) = subterms.last() {
subterms.pop();
}

View File

@@ -761,9 +761,9 @@ impl UntypedArenaPtr {
pub unsafe fn as_typed_ptr<T: ?Sized + ArenaAllocated>(self) -> TypedArenaPtr<T>
where
T::Payload: Sized,
{
{ unsafe {
T::typed_ptr(self)
}
}}
#[inline]
pub fn get_mark_bit(self) -> bool {

View File

@@ -105,9 +105,9 @@ impl VarAlloc {
#[inline]
pub(crate) fn set_register(&mut self, reg_num: usize) {
match self {
VarAlloc::Perm(ref mut p, _) => *p = reg_num,
VarAlloc::Perm(p, _) => *p = reg_num,
VarAlloc::Temp {
ref mut temp_reg, ..
temp_reg, ..
} => *temp_reg = reg_num,
};
}