summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/lean/Base/Primitives/Base.lean2
-rw-r--r--compiler/ExtractBuiltin.ml2
-rw-r--r--tests/lean/External/FunsExternal_Template.lean6
3 files changed, 4 insertions, 6 deletions
diff --git a/backends/lean/Base/Primitives/Base.lean b/backends/lean/Base/Primitives/Base.lean
index 62546ac3..94134d86 100644
--- a/backends/lean/Base/Primitives/Base.lean
+++ b/backends/lean/Base/Primitives/Base.lean
@@ -132,6 +132,8 @@ def Result.attach {α: Type} (o : Result α): Result { x : α // o = ok x } :=
@[simp] def core.mem.replace (a : Type) (x : a) (_ : a) : a × a := (x, x)
/- [core::option::Option::take] -/
@[simp] def Option.take (T: Type) (self: Option T): Option T × Option T := (self, .none)
+/- [core::mem::swap] -/
+@[simp] def core.mem.swap (T: Type) (a b: T): T × T := (b, a)
/-- Aeneas-translated function -- useful to reduce non-recursive definitions.
Use with `simp [ aeneas ]` -/
diff --git a/compiler/ExtractBuiltin.ml b/compiler/ExtractBuiltin.ml
index 3e96c320..531f1d8b 100644
--- a/compiler/ExtractBuiltin.ml
+++ b/compiler/ExtractBuiltin.ml
@@ -287,6 +287,7 @@ let builtin_funs () : (pattern * bool list option * builtin_fun_info) list =
in
[
mk_fun "core::mem::replace" None None;
+ mk_fun "core::mem::swap" None None;
mk_fun "core::slice::{[@T]}::len"
(Some (backend_choice "slice::len" "Slice::len"))
None;
@@ -517,6 +518,7 @@ let builtin_fun_effects =
"alloc::vec::{alloc::vec::Vec<@T, alloc::alloc::Global>}::new";
"alloc::vec::{alloc::vec::Vec<@T, @A>}::len";
"core::mem::replace";
+ "core::mem::swap";
"core::mem::take";
"core::option::{core::option::Option<@T>}::take";
"core::clone::impls::{core::clone::Clone<bool>}::clone";
diff --git a/tests/lean/External/FunsExternal_Template.lean b/tests/lean/External/FunsExternal_Template.lean
index 38151dc9..f0e771f7 100644
--- a/tests/lean/External/FunsExternal_Template.lean
+++ b/tests/lean/External/FunsExternal_Template.lean
@@ -6,12 +6,6 @@ import External.Types
open Primitives
open external
-/- [core::mem::swap]:
- Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/mem/mod.rs', lines 726:0-726:42
- Name pattern: core::mem::swap -/
-axiom core.mem.swap
- (T : Type) : T → T → State → Result (State × (T × T))
-
/- [core::num::nonzero::{core::num::nonzero::NonZeroU32#14}::new]:
Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/num/nonzero.rs', lines 79:16-79:57
Name pattern: core::num::nonzero::{core::num::nonzero::NonZeroU32}::new -/