Skip to content

Commit b9c1b09

Browse files
authored
Support for unicode str, specs for std::str fns, specs for UTF-8 (#2238)
1 parent 922ef8c commit b9c1b09

File tree

19 files changed

+1312
-160
lines changed

19 files changed

+1312
-160
lines changed

source/builtin/src/lib.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,13 +1849,6 @@ pub fn f64_to_bits(_f: f64) -> u64 {
18491849
unimplemented!()
18501850
}
18511851

1852-
#[cfg(verus_keep_ghost)]
1853-
#[rustc_diagnostic_item = "verus::verus_builtin::strslice_is_ascii"]
1854-
#[verifier::spec]
1855-
pub fn strslice_is_ascii<A>(_a: A) -> bool {
1856-
unimplemented!()
1857-
}
1858-
18591852
#[cfg(verus_keep_ghost)]
18601853
#[rustc_diagnostic_item = "verus::verus_builtin::strslice_len"]
18611854
#[verifier::spec]

source/rust_verify/src/fn_call_to_vir.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -933,21 +933,6 @@ fn verus_item_to_vir<'tcx, 'a>(
933933
),
934934
}
935935
}
936-
ExprItem::StrSliceIsAscii => {
937-
record_spec_fn(bctx, expr);
938-
match &expr.kind {
939-
ExprKind::Call(_, args) => {
940-
assert!(args.len() == 1);
941-
let arg0 = args.first().unwrap();
942-
let arg0 = expr_to_vir_consume(bctx, arg0, ExprModifier::REGULAR)
943-
.expect("internal compiler error");
944-
mk_expr(ExprX::Unary(UnaryOp::StrIsAscii, arg0))
945-
}
946-
_ => panic!(
947-
"Expected a call for verus_builtin::strslice_is_ascii with one argument but did not receive it"
948-
),
949-
}
950-
}
951936
ExprItem::ArchWordBits => {
952937
record_spec_fn(bctx, expr);
953938
assert!(args.len() == 0);

source/rust_verify/src/verus_items.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ pub(crate) enum ExprItem {
138138
F64ToBits,
139139
StrSliceLen,
140140
StrSliceGetChar,
141-
StrSliceIsAscii,
142141
ArchWordBits,
143142
ClosureToFnSpec,
144143
ClosureToFnProof,
@@ -498,7 +497,6 @@ fn verus_items_map() -> Vec<(&'static str, VerusItem)> {
498497
("verus::verus_builtin::f64_to_bits", VerusItem::Expr(ExprItem::F64ToBits)),
499498
("verus::verus_builtin::strslice_len", VerusItem::Expr(ExprItem::StrSliceLen)),
500499
("verus::verus_builtin::strslice_get_char", VerusItem::Expr(ExprItem::StrSliceGetChar)),
501-
("verus::verus_builtin::strslice_is_ascii", VerusItem::Expr(ExprItem::StrSliceIsAscii)),
502500
("verus::verus_builtin::arch_word_bits", VerusItem::Expr(ExprItem::ArchWordBits)),
503501
("verus::verus_builtin::closure_to_fn_spec", VerusItem::Expr(ExprItem::ClosureToFnSpec)),
504502
("verus::verus_builtin::closure_to_fn_proof", VerusItem::Expr(ExprItem::ClosureToFnProof)),

source/vir/src/ast.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,6 @@ pub enum UnaryOp {
447447
HeightTrigger,
448448
/// Used only for handling verus_builtin::strslice_len
449449
StrLen,
450-
/// Used only for handling verus_builtin::strslice_is_ascii
451-
StrIsAscii,
452450
/// Given an exec/proof expression used to construct a loop iterator,
453451
/// try to infer a pure specification for the loop iterator.
454452
/// Evaluate to Some(spec) if successful, None otherwise.

source/vir/src/bitvector_to_air.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ fn bv_exp_to_expr(ctx: &Ctx, state: &mut State, exp: &Exp) -> Result<BvExpr, Vir
430430
UnaryOp::MustBeFinalized | UnaryOp::MustBeElaborated => {
431431
panic!("internal error: Exp not finalized: {:?}", arg)
432432
}
433-
UnaryOp::StrLen | UnaryOp::StrIsAscii => panic!(
433+
UnaryOp::StrLen => panic!(
434434
"internal error: matching for bit vector ops on this match should be impossible"
435435
),
436436
UnaryOp::InferSpecForLoopIter { .. } => {

source/vir/src/def.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ pub const QID_OPAQUE_TYPE_BOUND: &str = "opaque_type_bound";
244244

245245
pub const VERUS_SPEC: &str = "VERUS_SPEC__";
246246

247-
pub const STRSLICE_IS_ASCII: &str = "str%strslice_is_ascii";
248247
pub const STRSLICE_LEN: &str = "str%strslice_len";
249248
pub const STRSLICE_GET_CHAR: &str = "str%strslice_get_char";
250249
pub const STRSLICE_NEW_STRLIT: &str = "str%new_strlit";

source/vir/src/heuristics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn insert_auto_ext_equal(ctx: &Ctx, exp: &Exp) -> Exp {
5757
UnaryOp::RealToInt => exp.clone(),
5858
UnaryOp::FloatToBits => exp.clone(),
5959
UnaryOp::IeeeFloat(_) => exp.clone(),
60-
UnaryOp::StrLen | UnaryOp::StrIsAscii | UnaryOp::Length(_) => exp.clone(),
60+
UnaryOp::StrLen | UnaryOp::Length(_) => exp.clone(),
6161
UnaryOp::InferSpecForLoopIter { .. } => exp.clone(),
6262
UnaryOp::Trigger(_)
6363
| UnaryOp::CoerceMode { .. }

source/vir/src/interpreter.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,6 @@ fn eval_expr_internal(ctx: &Ctx, state: &mut State, exp: &Exp) -> Result<Exp, Vi
11791179
| CoerceMode { .. }
11801180
| StrLen
11811181
| Length(..)
1182-
| StrIsAscii
11831182
| MutRefCurrent
11841183
| MutRefFuture(_)
11851184
| MutRefFinal(_)
@@ -1300,7 +1299,6 @@ fn eval_expr_internal(ctx: &Ctx, state: &mut State, exp: &Exp) -> Result<Exp, Vi
13001299
| CoerceMode { .. }
13011300
| StrLen
13021301
| Length(..)
1303-
| StrIsAscii
13041302
| MutRefCurrent
13051303
| MutRefFuture(_)
13061304
| MutRefFinal(_)

source/vir/src/poly.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,7 @@ fn visit_exp(ctx: &Ctx, state: &mut State, exp: &Exp) -> Exp {
569569
| UnaryOp::FloatToBits
570570
| UnaryOp::IeeeFloat(..)
571571
| UnaryOp::BitNot(_)
572-
| UnaryOp::StrLen
573-
| UnaryOp::StrIsAscii => {
572+
| UnaryOp::StrLen => {
574573
let e1 = coerce_exp_to_native(ctx, &e1);
575574
mk_exp(ExpX::Unary(*op, e1))
576575
}

source/vir/src/prelude.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,14 +1119,12 @@ pub(crate) fn array_functions(box_array: &str) -> Vec<Node> {
11191119

11201120
pub(crate) fn strslice_functions(strslice_name: &str) -> Vec<Node> {
11211121
let strslice = str_to_node(strslice_name);
1122-
let strslice_is_ascii = str_to_node(STRSLICE_IS_ASCII);
11231122
let strslice_len = str_to_node(STRSLICE_LEN);
11241123
let strslice_get_char = str_to_node(STRSLICE_GET_CHAR);
11251124
let new_strlit = str_to_node(STRSLICE_NEW_STRLIT);
11261125
let from_strlit = str_to_node(STRSLICE_FROM_STRLIT);
11271126
nodes_vec!(
11281127
// Strings
1129-
(declare-fun [strslice_is_ascii] ([strslice]) Bool)
11301128
(declare-fun [strslice_len] ([strslice]) Int)
11311129
(declare-fun [strslice_get_char] ([strslice] Int) Int)
11321130
(declare-fun [new_strlit] (Int) [strslice])

0 commit comments

Comments
 (0)