Skip to content

Commit c0118b6

Browse files
committed
Merge remote-tracking branch 'upstream/main' into overflowing
2 parents 50c748e + e80d477 commit c0118b6

File tree

11 files changed

+668
-103
lines changed

11 files changed

+668
-103
lines changed

source/builtin/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,12 @@ pub struct Tracked<A> {
370370
phantom: PhantomData<A>,
371371
}
372372

373+
impl<A> core::fmt::Debug for Tracked<A> {
374+
fn fmt(&self, _: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
375+
Ok(())
376+
}
377+
}
378+
373379
impl<A> Ghost<A> {
374380
#[cfg(verus_keep_ghost)]
375381
#[rustc_diagnostic_item = "verus::builtin::Ghost::view"]

source/rust_verify/src/attributes.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,21 @@ pub(crate) fn get_external_attrs(
978978
pub(crate) fn get_verifier_attrs(
979979
attrs: &[Attribute],
980980
diagnostics: Option<&mut Vec<VirErrAs>>,
981+
) -> Result<VerifierAttrs, VirErr> {
982+
get_verifier_attrs_maybe_check(attrs, diagnostics, true)
983+
}
984+
985+
pub(crate) fn get_verifier_attrs_no_check(
986+
attrs: &[Attribute],
987+
diagnostics: Option<&mut Vec<VirErrAs>>,
988+
) -> Result<VerifierAttrs, VirErr> {
989+
get_verifier_attrs_maybe_check(attrs, diagnostics, false)
990+
}
991+
992+
pub(crate) fn get_verifier_attrs_maybe_check(
993+
attrs: &[Attribute],
994+
diagnostics: Option<&mut Vec<VirErrAs>>,
995+
do_check: bool,
981996
) -> Result<VerifierAttrs, VirErr> {
982997
let mut vs = VerifierAttrs {
983998
verus_macro: false,
@@ -1096,8 +1111,10 @@ pub(crate) fn get_verifier_attrs(
10961111
_ => {}
10971112
}
10981113
}
1099-
if let Some((rustc_attr, span)) = unsupported_rustc_attr {
1100-
return err_span(span, format!("The attribute `{rustc_attr:}` is not supported"));
1114+
if do_check {
1115+
if let Some((rustc_attr, span)) = unsupported_rustc_attr {
1116+
return err_span(span, format!("The attribute `{rustc_attr:}` is not supported"));
1117+
}
11011118
}
11021119
Ok(vs)
11031120
}

source/rust_verify/src/context.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ impl<'tcx> ContextX<'tcx> {
5858
crate::attributes::get_verifier_attrs(attrs, Some(&mut *self.diagnostics.borrow_mut()))
5959
}
6060

61+
pub(crate) fn get_verifier_attrs_no_check(
62+
&self,
63+
attrs: &[Attribute],
64+
) -> Result<crate::attributes::VerifierAttrs, vir::ast::VirErr> {
65+
crate::attributes::get_verifier_attrs_no_check(
66+
attrs,
67+
Some(&mut *self.diagnostics.borrow_mut()),
68+
)
69+
}
70+
6171
pub(crate) fn get_external_attrs(
6272
&self,
6373
attrs: &[Attribute],

source/rust_verify/src/rust_to_vir_global.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub(crate) fn process_const_early<'tcx>(
2222
item: &Item<'tcx>,
2323
) -> Result<(), VirErr> {
2424
let attrs = ctxt.tcx.hir().attrs(item.hir_id());
25-
let vattrs = ctxt.get_verifier_attrs(attrs)?;
25+
let vattrs = ctxt.get_verifier_attrs_no_check(attrs)?;
2626
if vattrs.size_of_global {
2727
let err = crate::util::err_span(item.span, "invalid global size_of");
2828
let ItemKind::Const(_ty, generics, body_id) = item.kind else {

source/rust_verify_test/tests/sets.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ test_verify_one_file! {
111111

112112
proof fn test() {
113113
let s: Set<nat> = set![9];
114-
reveal_with_fuel(Set::fold, 10);
114+
broadcast use fold::lemma_fold_insert, fold::lemma_fold_empty;
115115
assert(s.finite());
116116
assert(s.len() > 0);
117117
assert(s.fold(0, |p: nat, a: nat| p + a) == 9);

source/vir/src/ast.rs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use crate::messages::{Message, Span};
1010
pub use air::ast::{Binder, Binders};
1111
use num_bigint::BigInt;
1212
use serde::{Deserialize, Serialize};
13-
use std::fmt::Display;
1413
use std::sync::Arc;
1514
use vir_macros::{to_node_impl, ToDebugSNode};
1615

@@ -585,12 +584,6 @@ pub struct SpannedTyped<X> {
585584
pub x: X,
586585
}
587586

588-
impl<X: Display> Display for SpannedTyped<X> {
589-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
590-
write!(f, "{}", self.x)
591-
}
592-
}
593-
594587
/// Patterns for match expressions
595588
pub type Pattern = Arc<SpannedTyped<PatternX>>;
596589
pub type Patterns = Arc<Vec<Pattern>>;
@@ -1280,21 +1273,6 @@ pub enum ArchWordBits {
12801273
Exactly(u32),
12811274
}
12821275

1283-
impl ArchWordBits {
1284-
pub fn min_bits(&self) -> u32 {
1285-
match self {
1286-
ArchWordBits::Either32Or64 => 32,
1287-
ArchWordBits::Exactly(v) => *v,
1288-
}
1289-
}
1290-
pub fn num_bits(&self) -> Option<u32> {
1291-
match self {
1292-
ArchWordBits::Either32Or64 => None,
1293-
ArchWordBits::Exactly(v) => Some(*v),
1294-
}
1295-
}
1296-
}
1297-
12981276
#[derive(Clone, Debug, Serialize, Deserialize)]
12991277
pub struct Arch {
13001278
pub word_bits: ArchWordBits,
@@ -1327,16 +1305,3 @@ pub struct KrateX {
13271305
/// Arch info
13281306
pub arch: Arch,
13291307
}
1330-
1331-
impl FunctionKind {
1332-
pub(crate) fn inline_okay(&self) -> bool {
1333-
match self {
1334-
FunctionKind::Static | FunctionKind::TraitMethodImpl { .. } => true,
1335-
// We don't want to do inlining for MethodDecls. If a MethodDecl has a body,
1336-
// it's a *default* body, so we can't know for sure it hasn't been overridden.
1337-
FunctionKind::TraitMethodDecl { .. } | FunctionKind::ForeignTraitMethodImpl { .. } => {
1338-
false
1339-
}
1340-
}
1341-
}
1342-
}

source/vir/src/ast_util.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ impl fmt::Display for Mode {
7575
}
7676
}
7777

78+
impl<X: fmt::Display> fmt::Display for SpannedTyped<X> {
79+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
80+
write!(f, "{}", self.x)
81+
}
82+
}
83+
7884
pub fn type_is_bool(typ: &Typ) -> bool {
7985
matches!(&**typ, TypX::Bool)
8086
}
@@ -908,6 +914,34 @@ impl<A: Clone> VarBinderX<A> {
908914
}
909915
}
910916

917+
impl FunctionKind {
918+
pub(crate) fn inline_okay(&self) -> bool {
919+
match self {
920+
FunctionKind::Static | FunctionKind::TraitMethodImpl { .. } => true,
921+
// We don't want to do inlining for MethodDecls. If a MethodDecl has a body,
922+
// it's a *default* body, so we can't know for sure it hasn't been overridden.
923+
FunctionKind::TraitMethodDecl { .. } | FunctionKind::ForeignTraitMethodImpl { .. } => {
924+
false
925+
}
926+
}
927+
}
928+
}
929+
930+
impl ArchWordBits {
931+
pub fn min_bits(&self) -> u32 {
932+
match self {
933+
ArchWordBits::Either32Or64 => 32,
934+
ArchWordBits::Exactly(v) => *v,
935+
}
936+
}
937+
pub fn num_bits(&self) -> Option<u32> {
938+
match self {
939+
ArchWordBits::Either32Or64 => None,
940+
ArchWordBits::Exactly(v) => Some(*v),
941+
}
942+
}
943+
}
944+
911945
pub fn str_unique_var(s: &str, dis: crate::ast::VarIdentDisambiguate) -> VarIdent {
912946
VarIdent(Arc::new(s.to_string()), dis)
913947
}

source/vstd/map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ impl<K, V> Map<K, V> {
4141

4242
/// Gives a `Map<K, V>` whose domain contains every key, and maps each key
4343
/// to the value given by `fv`.
44-
pub open spec fn total(fv: impl Fn(K) -> V) -> Map<K, V> {
44+
pub open spec fn total(fv: spec_fn(K) -> V) -> Map<K, V> {
4545
Set::full().mk_map(fv)
4646
}
4747

4848
/// Gives a `Map<K, V>` whose domain is given by the boolean predicate on keys `fk`,
4949
/// and maps each key to the value given by `fv`.
50-
pub open spec fn new(fk: impl Fn(K) -> bool, fv: impl Fn(K) -> V) -> Map<K, V> {
50+
pub open spec fn new(fk: spec_fn(K) -> bool, fv: spec_fn(K) -> V) -> Map<K, V> {
5151
Set::new(fk).mk_map(fv)
5252
}
5353

0 commit comments

Comments
 (0)