Skip to content

Commit 8071961

Browse files
committed
port to rust 1.79.0
1 parent b6e766e commit 8071961

35 files changed

+560
-228
lines changed

rust-toolchain.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[toolchain]
2-
channel = "1.76.0"
3-
# channel = "nightly-2023-09-29" # (not officially supported)
2+
channel = "1.79.0"
3+
# channel = "nightly-2023-09-29" # TODO update to match 1.79.0 (not officially supported)
44
components = [ "rustc", "rust-std", "cargo", "rustfmt", "rustc-dev", "llvm-tools" ]

source/builtin/src/lib.rs

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,7 @@ pub fn opens_invariants_except<A>(_a: A) {
145145
#[cfg(verus_keep_ghost)]
146146
#[rustc_diagnostic_item = "verus::builtin::reveal_hide"]
147147
#[verifier::proof]
148-
pub fn reveal_hide_(_f: fn(), _n: u32) {
149-
unimplemented!();
150-
}
148+
pub const fn reveal_hide_(_f: fn(), _n: u32) {}
151149

152150
#[cfg(verus_keep_ghost)]
153151
#[rustc_diagnostic_item = "verus::builtin::reveal_hide_internal_path"]
@@ -348,14 +346,15 @@ impl<A> Ghost<A> {
348346
#[rustc_diagnostic_item = "verus::builtin::Ghost::view"]
349347
#[verifier::spec]
350348
pub fn view(self) -> A {
351-
unimplemented!()
349+
unsafe { core::mem::MaybeUninit::uninit().assume_init() }
352350
}
353351

354352
#[cfg(verus_keep_ghost)]
355353
#[rustc_diagnostic_item = "verus::builtin::Ghost::new"]
356354
#[verifier::spec]
357355
#[verifier::external_body]
358-
pub fn new(_a: A) -> Ghost<A> {
356+
pub const fn new(_a: A) -> Ghost<A> {
357+
core::mem::forget(_a);
359358
Ghost { phantom: PhantomData }
360359
}
361360

@@ -382,7 +381,10 @@ impl<A> Ghost<A> {
382381
#[verifier::spec]
383382
#[verifier::external_body]
384383
pub fn borrow(&self) -> &A {
385-
unimplemented!()
384+
#[allow(deref_nullptr)]
385+
unsafe {
386+
&*(0 as *const A)
387+
}
386388
}
387389

388390
// note that because we return #[verifier::spec], not #[verifier::exec], we do not implement the BorrowMut trait
@@ -391,7 +393,10 @@ impl<A> Ghost<A> {
391393
#[verifier::proof]
392394
#[verifier::external]
393395
pub fn borrow_mut(#[verifier::proof] &mut self) -> &mut A {
394-
unimplemented!()
396+
#[allow(deref_nullptr)]
397+
unsafe {
398+
&mut *(0 as *mut A)
399+
}
395400
}
396401
}
397402

@@ -400,14 +405,15 @@ impl<A> Tracked<A> {
400405
#[rustc_diagnostic_item = "verus::builtin::Tracked::view"]
401406
#[verifier::spec]
402407
pub fn view(self) -> A {
403-
unimplemented!()
408+
unsafe { core::mem::MaybeUninit::uninit().assume_init() }
404409
}
405410

406411
#[cfg(verus_keep_ghost)]
407412
#[rustc_diagnostic_item = "verus::builtin::Tracked::new"]
408413
#[verifier::proof]
409414
#[verifier::external_body]
410-
pub fn new(#[verifier::proof] _a: A) -> Tracked<A> {
415+
pub const fn new(#[verifier::proof] _a: A) -> Tracked<A> {
416+
core::mem::forget(_a);
411417
Tracked { phantom: PhantomData }
412418
}
413419

@@ -430,8 +436,8 @@ impl<A> Tracked<A> {
430436
#[verifier::proof]
431437
#[verifier::external_body]
432438
#[verifier::returns(proof)]
433-
pub fn get(#[verifier::proof] self) -> A {
434-
unimplemented!()
439+
pub const fn get(#[verifier::proof] self) -> A {
440+
unsafe { core::mem::MaybeUninit::uninit().assume_init() }
435441
}
436442

437443
// note that because we return #[verifier::proof], not #[verifier::exec], we do not implement the Borrow trait
@@ -441,7 +447,10 @@ impl<A> Tracked<A> {
441447
#[verifier::external_body]
442448
#[verifier::returns(proof)]
443449
pub fn borrow(#[verifier::proof] &self) -> &A {
444-
unimplemented!()
450+
#[allow(deref_nullptr)]
451+
unsafe {
452+
&*(0 as *const A)
453+
}
445454
}
446455

447456
// note that because we return #[verifier::proof], not #[verifier::exec], we do not implement the BorrowMut trait
@@ -451,7 +460,10 @@ impl<A> Tracked<A> {
451460
#[verifier::external_body]
452461
#[verifier::returns(proof)]
453462
pub fn borrow_mut(#[verifier::proof] &mut self) -> &mut A {
454-
unimplemented!()
463+
#[allow(deref_nullptr)]
464+
unsafe {
465+
&mut *(0 as *mut A)
466+
}
455467
}
456468
}
457469

@@ -478,14 +490,16 @@ impl<A: Copy> Copy for Tracked<A> {}
478490
#[cfg(verus_keep_ghost)]
479491
#[rustc_diagnostic_item = "verus::builtin::ghost_exec"]
480492
#[verifier::external_body]
481-
pub fn ghost_exec<A>(#[verifier::spec] _a: A) -> Ghost<A> {
493+
pub const fn ghost_exec<A>(#[verifier::spec] _a: A) -> Ghost<A> {
494+
core::mem::forget(_a);
482495
Ghost::assume_new()
483496
}
484497

485498
#[cfg(verus_keep_ghost)]
486499
#[rustc_diagnostic_item = "verus::builtin::tracked_exec"]
487500
#[verifier::external_body]
488-
pub fn tracked_exec<A>(#[verifier::proof] _a: A) -> Tracked<A> {
501+
pub const fn tracked_exec<A>(#[verifier::proof] _a: A) -> Tracked<A> {
502+
core::mem::forget(_a);
489503
Tracked::assume_new()
490504
}
491505

@@ -1427,9 +1441,7 @@ pub fn infer_spec_for_loop_iter<A>(_: A, _print_hint: bool) -> Option<A> {
14271441
#[cfg(verus_keep_ghost)]
14281442
#[rustc_diagnostic_item = "verus::builtin::global_size_of"]
14291443
#[verifier::spec]
1430-
pub const fn global_size_of<T>(_bytes: usize) {
1431-
unimplemented!()
1432-
}
1444+
pub const fn global_size_of<T>(_bytes: usize) {}
14331445

14341446
#[cfg(verus_keep_ghost)]
14351447
#[rustc_diagnostic_item = "verus::builtin::inline_air_stmt"]

0 commit comments

Comments
 (0)