From 1bc48434e0a264d02ec3e649229629798b334a23 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Sun, 12 Jul 2026 18:37:59 +0200 Subject: [PATCH 1/3] Optimize comparison operators --- crates/rue-hir/src/lower.rs | 20 ++++++++------------ tests/operators.rue | 12 ++++++++++++ tests/operators.yaml | 16 ++++++++-------- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/crates/rue-hir/src/lower.rs b/crates/rue-hir/src/lower.rs index cfde1f30..c57283e7 100644 --- a/crates/rue-hir/src/lower.rs +++ b/crates/rue-hir/src/lower.rs @@ -259,26 +259,22 @@ impl<'d, 'a, 'g> Lowerer<'d, 'a, 'g> { BinaryOp::Gt => self.arena.alloc(Lir::Gt(left, right)), BinaryOp::Lt => self.arena.alloc(Lir::Gt(right, left)), BinaryOp::Gte => { - let gt = self.arena.alloc(Lir::Gt(left, right)); - let eq = self.arena.alloc(Lir::Eq(left, right)); - self.arena.alloc(Lir::Any(vec![gt, eq])) + let lt = self.arena.alloc(Lir::Gt(right, left)); + self.arena.alloc(Lir::Not(lt)) } BinaryOp::Lte => { - let lt = self.arena.alloc(Lir::Gt(right, left)); - let eq = self.arena.alloc(Lir::Eq(left, right)); - self.arena.alloc(Lir::Any(vec![lt, eq])) + let gt = self.arena.alloc(Lir::Gt(left, right)); + self.arena.alloc(Lir::Not(gt)) } BinaryOp::GtBytes => self.arena.alloc(Lir::GtBytes(left, right)), BinaryOp::LtBytes => self.arena.alloc(Lir::GtBytes(right, left)), BinaryOp::GteBytes => { - let gt = self.arena.alloc(Lir::GtBytes(left, right)); - let eq = self.arena.alloc(Lir::Eq(left, right)); - self.arena.alloc(Lir::Any(vec![gt, eq])) + let lt = self.arena.alloc(Lir::GtBytes(right, left)); + self.arena.alloc(Lir::Not(lt)) } BinaryOp::LteBytes => { - let lt = self.arena.alloc(Lir::GtBytes(right, left)); - let eq = self.arena.alloc(Lir::Eq(left, right)); - self.arena.alloc(Lir::Any(vec![lt, eq])) + let gt = self.arena.alloc(Lir::GtBytes(left, right)); + self.arena.alloc(Lir::Not(gt)) } BinaryOp::Eq => self.arena.alloc(Lir::Eq(left, right)), BinaryOp::Ne => { diff --git a/tests/operators.rue b/tests/operators.rue index 1c21d8e5..5d201aa2 100644 --- a/tests/operators.rue +++ b/tests/operators.rue @@ -33,8 +33,14 @@ test fn comparison() { assert 50 < 100; assert 100 >= 50; assert 100 >= 100; + assert !(50 >= 100); + assert 101 >= 100; + assert !(99 >= 100); assert 50 <= 100; assert 100 <= 100; + assert !(100 <= 50); + assert 99 <= 100; + assert !(101 <= 100); assert "a" == "a"; assert !("a" == "b"); @@ -45,8 +51,14 @@ test fn comparison() { assert "a" < "b"; assert "b" >= "a"; assert "b" >= "b"; + assert !("a" >= "b"); + assert "ab" >= "aa"; + assert !("aa" >= "ab"); assert "a" <= "b"; assert "a" <= "a"; + assert !("b" <= "a"); + assert "aa" <= "ab"; + assert !("ab" <= "aa"); assert true; assert !false; diff --git a/tests/operators.yaml b/tests/operators.yaml index fbfb4731..8532a17f 100644 --- a/tests/operators.yaml +++ b/tests/operators.yaml @@ -7,20 +7,20 @@ tests: byte_cost: 7236000 total_cost: 23775931 - name: comparison - program: (a (i (= (q . 100) (q . 100)) (q 2 (i (= (q . 100) (q . 101)) (q 8) (q 2 (i (= (q . 100) (q . 101)) (q 8) (q 2 (i (= (q . 100) (q . 100)) (q 2 (i (> (q . 100) (q . 50)) (q 2 (i (> (q . 100) (q . 50)) (q 2 (i (any (> (q . 100) (q . 50)) (= (q . 100) (q . 50))) (q 2 (i (any (> (q . 100) (q . 100)) (= (q . 100) (q . 100))) (q 2 (i (any (> (q . 100) (q . 50)) (= (q . 50) (q . 100))) (q 2 (i (any (> (q . 100) (q . 100)) (= (q . 100) (q . 100))) (q 2 (i (= (q . 97) (q . 97)) (q 2 (i (= (q . 97) (q . 98)) (q 8) (q 2 (i (= (q . 97) (q . 98)) (q 8) (q 2 (i (= (q . 97) (q . 97)) (q 2 (i (>s (q . 98) (q . 97)) (q 2 (i (>s (q . 98) (q . 97)) (q 2 (i (any (>s (q . 98) (q . 97)) (= (q . 98) (q . 97))) (q 2 (i (any (>s (q . 98) (q . 98)) (= (q . 98) (q . 98))) (q 2 (i (any (>s (q . 98) (q . 97)) (= (q . 97) (q . 98))) (q 2 (i (any (>s (q . 97) (q . 97)) (= (q . 97) (q . 97))) (q 2 (i (all) (q 2 (i (any (q . 1)) (q 2 (i (any (q . 1)) (q) (q 8)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1)) 1)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1)) 1)) 1) (q 8)) 1) - debug_program: (a (i (= (q . 100) (q . 100)) (q 2 (i (not (= (q . 100) (q . 101))) (q 2 (i (not (= (q . 100) (q . 101))) (q 2 (i (not (not (= (q . 100) (q . 100)))) (q 2 (i (> (q . 100) (q . 50)) (q 2 (i (> (q . 100) (q . 50)) (q 2 (i (any (> (q . 100) (q . 50)) (= (q . 100) (q . 50))) (q 2 (i (any (> (q . 100) (q . 100)) (= (q . 100) (q . 100))) (q 2 (i (any (> (q . 100) (q . 50)) (= (q . 50) (q . 100))) (q 2 (i (any (> (q . 100) (q . 100)) (= (q . 100) (q . 100))) (q 2 (i (= (q . 97) (q . 97)) (q 2 (i (not (= (q . 97) (q . 98))) (q 2 (i (not (= (q . 97) (q . 98))) (q 2 (i (not (not (= (q . 97) (q . 97)))) (q 2 (i (>s (q . 98) (q . 97)) (q 2 (i (>s (q . 98) (q . 97)) (q 2 (i (any (>s (q . 98) (q . 97)) (= (q . 98) (q . 97))) (q 2 (i (any (>s (q . 98) (q . 98)) (= (q . 98) (q . 98))) (q 2 (i (any (>s (q . 98) (q . 97)) (= (q . 97) (q . 98))) (q 2 (i (any (>s (q . 97) (q . 97)) (= (q . 97) (q . 97))) (q 2 (i (q . 1) (q 2 (i (not ()) (q 2 (i (a (i (q . 1) (q 2 (i (q . 1) (q 1 . 1) (q)) 1) (q)) 1) (q 2 (i (all (q . 1) (q . 1)) (q 2 (i (a (i (q . 1) (q 1 . 1) (q 2 (i () (q 1 . 1) (q)) 1)) 1) (q 2 (i (any (q . 1) ()) (q 2 (i (a (i () (q 1 . 1) (q 2 (i (q . 1) (q 1 . 1) (q)) 1)) 1) (q 2 (i (any () (q . 1)) (q) (q 8 (q . "assertion failed at operators.rue:58:5"))) 1) (q 8 (q . "assertion failed at operators.rue:57:5"))) 1) (q 8 (q . "assertion failed at operators.rue:56:5"))) 1) (q 8 (q . "assertion failed at operators.rue:55:5"))) 1) (q 8 (q . "assertion failed at operators.rue:54:5"))) 1) (q 8 (q . "assertion failed at operators.rue:53:5"))) 1) (q 8 (q . "assertion failed at operators.rue:52:5"))) 1) (q 8 (q . "assertion failed at operators.rue:51:5"))) 1) (q 8 (q . "assertion failed at operators.rue:49:5"))) 1) (q 8 (q . "assertion failed at operators.rue:48:5"))) 1) (q 8 (q . "assertion failed at operators.rue:47:5"))) 1) (q 8 (q . "assertion failed at operators.rue:46:5"))) 1) (q 8 (q . "assertion failed at operators.rue:45:5"))) 1) (q 8 (q . "assertion failed at operators.rue:44:5"))) 1) (q 8 (q . "assertion failed at operators.rue:42:5"))) 1) (q 8 (q . "assertion failed at operators.rue:41:5"))) 1) (q 8 (q . "assertion failed at operators.rue:40:5"))) 1) (q 8 (q . "assertion failed at operators.rue:39:5"))) 1) (q 8 (q . "assertion failed at operators.rue:37:5"))) 1) (q 8 (q . "assertion failed at operators.rue:36:5"))) 1) (q 8 (q . "assertion failed at operators.rue:35:5"))) 1) (q 8 (q . "assertion failed at operators.rue:34:5"))) 1) (q 8 (q . "assertion failed at operators.rue:33:5"))) 1) (q 8 (q . "assertion failed at operators.rue:32:5"))) 1) (q 8 (q . "assertion failed at operators.rue:30:5"))) 1) (q 8 (q . "assertion failed at operators.rue:29:5"))) 1) (q 8 (q . "assertion failed at operators.rue:28:5"))) 1) (q 8 (q . "assertion failed at operators.rue:27:5"))) 1) + program: (a (i (= (q . 100) (q . 100)) (q 2 (i (= (q . 100) (q . 101)) (q 8) (q 2 (i (= (q . 100) (q . 101)) (q 8) (q 2 (i (= (q . 100) (q . 100)) (q 2 (i (> (q . 100) (q . 50)) (q 2 (i (> (q . 100) (q . 50)) (q 2 (i (> (q . 50) (q . 100)) (q 8) (q 2 (i (> (q . 100) (q . 100)) (q 8) (q 2 (i (> (q . 100) (q . 50)) (q 2 (i (> (q . 100) (q . 101)) (q 8) (q 2 (i (> (q . 100) (q . 99)) (q 2 (i (> (q . 50) (q . 100)) (q 8) (q 2 (i (> (q . 100) (q . 100)) (q 8) (q 2 (i (> (q . 100) (q . 50)) (q 2 (i (> (q . 99) (q . 100)) (q 8) (q 2 (i (> (q . 101) (q . 100)) (q 2 (i (= (q . 97) (q . 97)) (q 2 (i (= (q . 97) (q . 98)) (q 8) (q 2 (i (= (q . 97) (q . 98)) (q 8) (q 2 (i (= (q . 97) (q . 97)) (q 2 (i (>s (q . 98) (q . 97)) (q 2 (i (>s (q . 98) (q . 97)) (q 2 (i (>s (q . 97) (q . 98)) (q 8) (q 2 (i (>s (q . 98) (q . 98)) (q 8) (q 2 (i (>s (q . 98) (q . 97)) (q 2 (i (>s (q . 24929) (q . 24930)) (q 8) (q 2 (i (>s (q . 24930) (q . 24929)) (q 2 (i (>s (q . 97) (q . 98)) (q 8) (q 2 (i (>s (q . 97) (q . 97)) (q 8) (q 2 (i (>s (q . 98) (q . 97)) (q 2 (i (>s (q . 24929) (q . 24930)) (q 8) (q 2 (i (>s (q . 24930) (q . 24929)) (q 2 (i (all) (q 2 (i (any (q . 1)) (q 2 (i (any (q . 1)) (q) (q 8)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1)) 1) (q 8)) 1)) 1)) 1) (q 8)) 1)) 1) (q 8)) 1)) 1)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1)) 1)) 1) (q 8)) 1) (q 8)) 1)) 1) (q 8)) 1)) 1)) 1) (q 8)) 1)) 1) (q 8)) 1)) 1)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1)) 1)) 1) (q 8)) 1) + debug_program: (a (i (= (q . 100) (q . 100)) (q 2 (i (not (= (q . 100) (q . 101))) (q 2 (i (not (= (q . 100) (q . 101))) (q 2 (i (not (not (= (q . 100) (q . 100)))) (q 2 (i (> (q . 100) (q . 50)) (q 2 (i (> (q . 100) (q . 50)) (q 2 (i (not (> (q . 50) (q . 100))) (q 2 (i (not (> (q . 100) (q . 100))) (q 2 (i (not (not (> (q . 100) (q . 50)))) (q 2 (i (not (> (q . 100) (q . 101))) (q 2 (i (not (not (> (q . 100) (q . 99)))) (q 2 (i (not (> (q . 50) (q . 100))) (q 2 (i (not (> (q . 100) (q . 100))) (q 2 (i (not (not (> (q . 100) (q . 50)))) (q 2 (i (not (> (q . 99) (q . 100))) (q 2 (i (not (not (> (q . 101) (q . 100)))) (q 2 (i (= (q . 97) (q . 97)) (q 2 (i (not (= (q . 97) (q . 98))) (q 2 (i (not (= (q . 97) (q . 98))) (q 2 (i (not (not (= (q . 97) (q . 97)))) (q 2 (i (>s (q . 98) (q . 97)) (q 2 (i (>s (q . 98) (q . 97)) (q 2 (i (not (>s (q . 97) (q . 98))) (q 2 (i (not (>s (q . 98) (q . 98))) (q 2 (i (not (not (>s (q . 98) (q . 97)))) (q 2 (i (not (>s (q . 24929) (q . 24930))) (q 2 (i (not (not (>s (q . 24930) (q . 24929)))) (q 2 (i (not (>s (q . 97) (q . 98))) (q 2 (i (not (>s (q . 97) (q . 97))) (q 2 (i (not (not (>s (q . 98) (q . 97)))) (q 2 (i (not (>s (q . 24929) (q . 24930))) (q 2 (i (not (not (>s (q . 24930) (q . 24929)))) (q 2 (i (q . 1) (q 2 (i (not ()) (q 2 (i (a (i (q . 1) (q 2 (i (q . 1) (q 1 . 1) (q)) 1) (q)) 1) (q 2 (i (all (q . 1) (q . 1)) (q 2 (i (a (i (q . 1) (q 1 . 1) (q 2 (i () (q 1 . 1) (q)) 1)) 1) (q 2 (i (any (q . 1) ()) (q 2 (i (a (i () (q 1 . 1) (q 2 (i (q . 1) (q 1 . 1) (q)) 1)) 1) (q 2 (i (any () (q . 1)) (q) (q 8 (q . "assertion failed at operators.rue:70:5"))) 1) (q 8 (q . "assertion failed at operators.rue:69:5"))) 1) (q 8 (q . "assertion failed at operators.rue:68:5"))) 1) (q 8 (q . "assertion failed at operators.rue:67:5"))) 1) (q 8 (q . "assertion failed at operators.rue:66:5"))) 1) (q 8 (q . "assertion failed at operators.rue:65:5"))) 1) (q 8 (q . "assertion failed at operators.rue:64:5"))) 1) (q 8 (q . "assertion failed at operators.rue:63:5"))) 1) (q 8 (q . "assertion failed at operators.rue:61:5"))) 1) (q 8 (q . "assertion failed at operators.rue:60:5"))) 1) (q 8 (q . "assertion failed at operators.rue:59:5"))) 1) (q 8 (q . "assertion failed at operators.rue:58:5"))) 1) (q 8 (q . "assertion failed at operators.rue:57:5"))) 1) (q 8 (q . "assertion failed at operators.rue:56:5"))) 1) (q 8 (q . "assertion failed at operators.rue:55:5"))) 1) (q 8 (q . "assertion failed at operators.rue:54:5"))) 1) (q 8 (q . "assertion failed at operators.rue:53:5"))) 1) (q 8 (q . "assertion failed at operators.rue:52:5"))) 1) (q 8 (q . "assertion failed at operators.rue:51:5"))) 1) (q 8 (q . "assertion failed at operators.rue:50:5"))) 1) (q 8 (q . "assertion failed at operators.rue:48:5"))) 1) (q 8 (q . "assertion failed at operators.rue:47:5"))) 1) (q 8 (q . "assertion failed at operators.rue:46:5"))) 1) (q 8 (q . "assertion failed at operators.rue:45:5"))) 1) (q 8 (q . "assertion failed at operators.rue:43:5"))) 1) (q 8 (q . "assertion failed at operators.rue:42:5"))) 1) (q 8 (q . "assertion failed at operators.rue:41:5"))) 1) (q 8 (q . "assertion failed at operators.rue:40:5"))) 1) (q 8 (q . "assertion failed at operators.rue:39:5"))) 1) (q 8 (q . "assertion failed at operators.rue:38:5"))) 1) (q 8 (q . "assertion failed at operators.rue:37:5"))) 1) (q 8 (q . "assertion failed at operators.rue:36:5"))) 1) (q 8 (q . "assertion failed at operators.rue:35:5"))) 1) (q 8 (q . "assertion failed at operators.rue:34:5"))) 1) (q 8 (q . "assertion failed at operators.rue:33:5"))) 1) (q 8 (q . "assertion failed at operators.rue:32:5"))) 1) (q 8 (q . "assertion failed at operators.rue:30:5"))) 1) (q 8 (q . "assertion failed at operators.rue:29:5"))) 1) (q 8 (q . "assertion failed at operators.rue:28:5"))) 1) (q 8 (q . "assertion failed at operators.rue:27:5"))) 1) output: () - runtime_cost: 19280 - byte_cost: 9636000 - total_cost: 9655280 + runtime_cost: 18326 + byte_cost: 12612000 + total_cost: 12630326 - name: bitwise program: (a (i (= (lognot (q . 10)) (q . -11)) (q 2 (i (= (ash (q . 50) (q . -2)) (q . 12)) (q 2 (i (= (ash (q . 50) (q . 2)) (q . 200)) (q 2 (i (= (lsh (q . -50) (q . -1)) (q . 103)) (q 2 (i (= (lsh (q . 50) (q . -1)) (q . 25)) (q 2 (i (= (lsh (q . -50) (q . 1)) (q . 412)) (q 2 (i (= (lsh (q . 50) (q . 1)) (q . 100)) (q 2 (i (= (q . 15) (q . 15)) (q 2 (i (= (logxor (q . 10) (q . 5)) (q . 15)) (q) (q 8)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1) (q 8)) 1) - debug_program: (a (i (= (lognot (q . 10)) (- () (q . 11))) (q 2 (i (= (ash (q . 50) (- () (q . 2))) (q . 12)) (q 2 (i (= (ash (q . 50) (q . 2)) (q . 200)) (q 2 (i (= (lsh (- () (q . 50)) (- () (q . 1))) (q . 103)) (q 2 (i (= (lsh (q . 50) (- () (q . 1))) (q . 25)) (q 2 (i (= (lsh (- () (q . 50)) (- () (- () (q . 1)))) (q . 412)) (q 2 (i (= (lsh (q . 50) (- () (- () (q . 1)))) (q . 100)) (q 2 (i (= (logand (q . 10) (q . 5)) ()) (q 2 (i (= (logior (q . 10) (q . 5)) (q . 15)) (q 2 (i (= (logxor (q . 10) (q . 5)) (q . 15)) (q) (q 8 (q . "assertion failed at operators.rue:71:5"))) 1) (q 8 (q . "assertion failed at operators.rue:70:5"))) 1) (q 8 (q . "assertion failed at operators.rue:69:5"))) 1) (q 8 (q . "assertion failed at operators.rue:68:5"))) 1) (q 8 (q . "assertion failed at operators.rue:67:5"))) 1) (q 8 (q . "assertion failed at operators.rue:66:5"))) 1) (q 8 (q . "assertion failed at operators.rue:65:5"))) 1) (q 8 (q . "assertion failed at operators.rue:64:5"))) 1) (q 8 (q . "assertion failed at operators.rue:63:5"))) 1) (q 8 (q . "assertion failed at operators.rue:62:5"))) 1) + debug_program: (a (i (= (lognot (q . 10)) (- () (q . 11))) (q 2 (i (= (ash (q . 50) (- () (q . 2))) (q . 12)) (q 2 (i (= (ash (q . 50) (q . 2)) (q . 200)) (q 2 (i (= (lsh (- () (q . 50)) (- () (q . 1))) (q . 103)) (q 2 (i (= (lsh (q . 50) (- () (q . 1))) (q . 25)) (q 2 (i (= (lsh (- () (q . 50)) (- () (- () (q . 1)))) (q . 412)) (q 2 (i (= (lsh (q . 50) (- () (- () (q . 1)))) (q . 100)) (q 2 (i (= (logand (q . 10) (q . 5)) ()) (q 2 (i (= (logior (q . 10) (q . 5)) (q . 15)) (q 2 (i (= (logxor (q . 10) (q . 5)) (q . 15)) (q) (q 8 (q . "assertion failed at operators.rue:83:5"))) 1) (q 8 (q . "assertion failed at operators.rue:82:5"))) 1) (q 8 (q . "assertion failed at operators.rue:81:5"))) 1) (q 8 (q . "assertion failed at operators.rue:80:5"))) 1) (q 8 (q . "assertion failed at operators.rue:79:5"))) 1) (q 8 (q . "assertion failed at operators.rue:78:5"))) 1) (q 8 (q . "assertion failed at operators.rue:77:5"))) 1) (q 8 (q . "assertion failed at operators.rue:76:5"))) 1) (q 8 (q . "assertion failed at operators.rue:75:5"))) 1) (q 8 (q . "assertion failed at operators.rue:74:5"))) 1) output: () runtime_cost: 6924 byte_cost: 4092000 total_cost: 4098924 diagnostics: - Unnecessary `+` operator, since it has no effect at operators.rue:2:12 -- Condition always evaluates to `true` at operators.rue:51:12 -- Condition always evaluates to `true` at operators.rue:52:12 +- Condition always evaluates to `true` at operators.rue:63:12 +- Condition always evaluates to `true` at operators.rue:64:12 From 6d3b66b5d27f7946046f94826f9db82491d60bcd Mon Sep 17 00:00:00 2001 From: Rigidity Date: Sun, 12 Jul 2026 18:39:08 +0200 Subject: [PATCH 2/3] Bump version --- Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 18 +++++++++--------- crates/rue-ast/Cargo.toml | 2 +- crates/rue-cli/Cargo.toml | 2 +- crates/rue-compiler/Cargo.toml | 2 +- crates/rue-diagnostic/Cargo.toml | 2 +- crates/rue-hir/Cargo.toml | 2 +- crates/rue-lexer/Cargo.toml | 2 +- crates/rue-lir/Cargo.toml | 2 +- crates/rue-lsp/Cargo.toml | 2 +- crates/rue-options/Cargo.toml | 2 +- crates/rue-parser/Cargo.toml | 2 +- crates/rue-tests/Cargo.toml | 2 +- crates/rue-types/Cargo.toml | 2 +- wasm/Cargo.toml | 2 +- 15 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5ac25abd..47b438ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1712,7 +1712,7 @@ dependencies = [ [[package]] name = "rue-ast" -version = "0.8.4" +version = "0.8.5" dependencies = [ "paste", "rue-parser", @@ -1720,7 +1720,7 @@ dependencies = [ [[package]] name = "rue-cli" -version = "0.8.4" +version = "0.8.5" dependencies = [ "anyhow", "chialisp", @@ -1738,7 +1738,7 @@ dependencies = [ [[package]] name = "rue-compiler" -version = "0.8.4" +version = "0.8.5" dependencies = [ "clvmr", "expect-test", @@ -1763,14 +1763,14 @@ dependencies = [ [[package]] name = "rue-diagnostic" -version = "0.8.4" +version = "0.8.5" dependencies = [ "thiserror 2.0.14", ] [[package]] name = "rue-hir" -version = "0.8.4" +version = "0.8.5" dependencies = [ "derive_more", "expect-test", @@ -1787,14 +1787,14 @@ dependencies = [ [[package]] name = "rue-lexer" -version = "0.8.4" +version = "0.8.5" dependencies = [ "expect-test", ] [[package]] name = "rue-lir" -version = "0.8.4" +version = "0.8.5" dependencies = [ "chialisp", "clvm-traits", @@ -1811,7 +1811,7 @@ dependencies = [ [[package]] name = "rue-lsp" -version = "0.8.4" +version = "0.8.5" dependencies = [ "indexmap", "rowan", @@ -1827,7 +1827,7 @@ dependencies = [ [[package]] name = "rue-options" -version = "0.8.4" +version = "0.8.5" dependencies = [ "serde", "thiserror 2.0.14", @@ -1836,7 +1836,7 @@ dependencies = [ [[package]] name = "rue-parser" -version = "0.8.4" +version = "0.8.5" dependencies = [ "derive_more", "expect-test", @@ -1851,7 +1851,7 @@ dependencies = [ [[package]] name = "rue-tests" -version = "0.8.4" +version = "0.8.5" dependencies = [ "anyhow", "chialisp", @@ -1868,7 +1868,7 @@ dependencies = [ [[package]] name = "rue-types" -version = "0.8.4" +version = "0.8.5" dependencies = [ "clvmr", "derive_more", @@ -1883,7 +1883,7 @@ dependencies = [ [[package]] name = "rue-wasm" -version = "0.8.4" +version = "0.8.5" dependencies = [ "chialisp", "clvmr", diff --git a/Cargo.toml b/Cargo.toml index b989b425..fcbd5703 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,15 +42,15 @@ cast_possible_truncation = "allow" case_sensitive_file_extension_comparisons = "allow" [workspace.dependencies] -rue-lexer = { path = "crates/rue-lexer", version = "0.8.4" } -rue-parser = { path = "crates/rue-parser", version = "0.8.4" } -rue-diagnostic = { path = "crates/rue-diagnostic", version = "0.8.4" } -rue-ast = { path = "crates/rue-ast", version = "0.8.4" } -rue-compiler = { path = "crates/rue-compiler", version = "0.8.4" } -rue-options = { path = "crates/rue-options", version = "0.8.4" } -rue-lir = { path = "crates/rue-lir", version = "0.8.4" } -rue-hir = { path = "crates/rue-hir", version = "0.8.4" } -rue-types = { path = "crates/rue-types", version = "0.8.4" } +rue-lexer = { path = "crates/rue-lexer", version = "0.8.5" } +rue-parser = { path = "crates/rue-parser", version = "0.8.5" } +rue-diagnostic = { path = "crates/rue-diagnostic", version = "0.8.5" } +rue-ast = { path = "crates/rue-ast", version = "0.8.5" } +rue-compiler = { path = "crates/rue-compiler", version = "0.8.5" } +rue-options = { path = "crates/rue-options", version = "0.8.5" } +rue-lir = { path = "crates/rue-lir", version = "0.8.5" } +rue-hir = { path = "crates/rue-hir", version = "0.8.5" } +rue-types = { path = "crates/rue-types", version = "0.8.5" } anyhow = "1.0.98" clvm-traits = "0.28.1" clvm-utils = "0.28.1" diff --git a/crates/rue-ast/Cargo.toml b/crates/rue-ast/Cargo.toml index 079f905e..7c1b2519 100644 --- a/crates/rue-ast/Cargo.toml +++ b/crates/rue-ast/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-ast" -version = "0.8.4" +version = "0.8.5" edition = "2024" license = "Apache-2.0" description = "An implementation of the Abstract Syntax Tree for the Rue compiler." diff --git a/crates/rue-cli/Cargo.toml b/crates/rue-cli/Cargo.toml index abbb93b4..cb21bb3b 100644 --- a/crates/rue-cli/Cargo.toml +++ b/crates/rue-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-cli" -version = "0.8.4" +version = "0.8.5" edition = "2024" license = "Apache-2.0" description = "A CLI tool for invoking the Rue compiler." diff --git a/crates/rue-compiler/Cargo.toml b/crates/rue-compiler/Cargo.toml index 3a3dad1a..be8c8275 100644 --- a/crates/rue-compiler/Cargo.toml +++ b/crates/rue-compiler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-compiler" -version = "0.8.4" +version = "0.8.5" edition = "2024" license = "Apache-2.0" description = "A compiler for the Rue programming language." diff --git a/crates/rue-diagnostic/Cargo.toml b/crates/rue-diagnostic/Cargo.toml index a51fd4b6..00c4dfbd 100644 --- a/crates/rue-diagnostic/Cargo.toml +++ b/crates/rue-diagnostic/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-diagnostic" -version = "0.8.4" +version = "0.8.5" edition = "2024" license = "Apache-2.0" description = "All of the potential diagnostics that can be emitted by the Rue compiler." diff --git a/crates/rue-hir/Cargo.toml b/crates/rue-hir/Cargo.toml index d51359ae..ea781721 100644 --- a/crates/rue-hir/Cargo.toml +++ b/crates/rue-hir/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-hir" -version = "0.8.4" +version = "0.8.5" edition = "2024" license = "Apache-2.0" description = "Provides a high-level intermediate representation of the Rue programming language." diff --git a/crates/rue-lexer/Cargo.toml b/crates/rue-lexer/Cargo.toml index 786352e4..20e2d2f7 100644 --- a/crates/rue-lexer/Cargo.toml +++ b/crates/rue-lexer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-lexer" -version = "0.8.4" +version = "0.8.5" edition = "2024" license = "Apache-2.0" description = "A lexer for the Rue programming language." diff --git a/crates/rue-lir/Cargo.toml b/crates/rue-lir/Cargo.toml index 9b9598c6..d0c9943f 100644 --- a/crates/rue-lir/Cargo.toml +++ b/crates/rue-lir/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-lir" -version = "0.8.4" +version = "0.8.5" edition = "2024" license = "Apache-2.0" description = "Provides a low-level intermediate representation that compiles to CLVM." diff --git a/crates/rue-lsp/Cargo.toml b/crates/rue-lsp/Cargo.toml index 73efc62b..1d10ff2d 100644 --- a/crates/rue-lsp/Cargo.toml +++ b/crates/rue-lsp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-lsp" -version = "0.8.4" +version = "0.8.5" edition = "2024" license = "Apache-2.0" description = "A language server protocol (LSP) implementation for the Rue programming language." diff --git a/crates/rue-options/Cargo.toml b/crates/rue-options/Cargo.toml index 0af4fd8a..5a98bb9d 100644 --- a/crates/rue-options/Cargo.toml +++ b/crates/rue-options/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-options" -version = "0.8.4" +version = "0.8.5" edition = "2024" license = "Apache-2.0" description = "Provides a way to configure the Rue compiler." diff --git a/crates/rue-parser/Cargo.toml b/crates/rue-parser/Cargo.toml index 64fc0ec8..fc082b5b 100644 --- a/crates/rue-parser/Cargo.toml +++ b/crates/rue-parser/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-parser" -version = "0.8.4" +version = "0.8.5" edition = "2024" license = "Apache-2.0" description = "A parser for the Rue programming language." diff --git a/crates/rue-tests/Cargo.toml b/crates/rue-tests/Cargo.toml index 4eb688bc..6e0318fb 100644 --- a/crates/rue-tests/Cargo.toml +++ b/crates/rue-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-tests" -version = "0.8.4" +version = "0.8.5" edition = "2024" publish = false license = "Apache-2.0" diff --git a/crates/rue-types/Cargo.toml b/crates/rue-types/Cargo.toml index 879e7e4f..7de36401 100644 --- a/crates/rue-types/Cargo.toml +++ b/crates/rue-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-types" -version = "0.8.4" +version = "0.8.5" edition = "2024" license = "Apache-2.0" description = "A type system for the Rue programming language." diff --git a/wasm/Cargo.toml b/wasm/Cargo.toml index deadf136..f55d6136 100644 --- a/wasm/Cargo.toml +++ b/wasm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-wasm" -version = "0.8.4" +version = "0.8.5" edition = "2024" publish = false license = "Apache-2.0" From 6e80f9fc1dde1229b29bb283644f30b6be1b79b1 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Sun, 12 Jul 2026 18:46:51 +0200 Subject: [PATCH 3/3] Toolchain --- crates/rue-hir/src/environment.rs | 4 +++- rust-toolchain.toml | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 rust-toolchain.toml diff --git a/crates/rue-hir/src/environment.rs b/crates/rue-hir/src/environment.rs index 047e520a..7d10429d 100644 --- a/crates/rue-hir/src/environment.rs +++ b/crates/rue-hir/src/environment.rs @@ -1,3 +1,5 @@ +use std::cmp::Reverse; + use indexmap::IndexMap; use crate::SymbolId; @@ -44,7 +46,7 @@ impl Environment { // Sort symbols by reference count in descending order let mut symbols: Vec<_> = referenced_symbols.into_iter().collect(); - symbols.sort_by(|a, b| b.1.cmp(&a.1)); + symbols.sort_by_key(|b| Reverse(b.1)); // Split symbols into two groups, trying to balance: // 1. Total reference counts between groups diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 00000000..2c202d45 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.97.0" +components = ["rustfmt", "clippy"]