Skip to content

Commit 47c5a0b

Browse files
committed
Add flag to add experimental iterator support
1 parent 9144bfa commit 47c5a0b

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

docs/dev-guide/src/config/flags.md

+7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
| [`DUMP_VIPER_PROGRAM`](#dump_viper_program) | `bool` | `false` |
2222
| [`ENABLE_CACHE`](#enable_cache) | `bool` | `true` |
2323
| [`ENABLE_GHOST_CONSTRAINTS`](#enable_ghost_constraints) | `bool` | `false` |
24+
| [`ENABLE_ITERATORS`](#enable_iterators) | `bool` | `false` |
2425
| [`ENABLE_PURIFICATION_OPTIMIZATION`](#enable_purification_optimization) | `bool` | `false` |
2526
| [`ENABLE_VERIFY_ONLY_BASIC_BLOCK_PATH`](#enable_verify_only_basic_block_path) | `bool` | `false` |
2627
| [`ENCODE_BITVECTORS`](#encode_bitvectors) | `bool` | `false` |
@@ -141,6 +142,12 @@ on a generic type parameter) is satisfied.
141142

142143
**This is an experimental feature**, because it is currently possible to introduce unsound verification behavior.
143144

145+
## `ENABLE_ITERATORS`
146+
147+
Enables support for iterators.
148+
149+
**This is an experimental feature**, iterator support is still experimental.
150+
144151
## `ENABLE_PURIFICATION_OPTIMIZATION`
145152

146153
When enabled, impure methods are optimized using the purification optimization, which tries to convert heap operations to pure (snapshot-based) operations.

prusti-common/src/config.rs

+6
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ lazy_static! {
113113
settings.set_default("print_hash", false).unwrap();
114114
settings.set_default("enable_cache", true).unwrap();
115115
settings.set_default("enable_ghost_constraints", false).unwrap();
116+
settings.set_default("enable_iterators", false).unwrap();
116117

117118
// Flags for debugging Prusti that can change verification results.
118119
settings.set_default("disable_name_mangling", false).unwrap();
@@ -599,4 +600,9 @@ pub fn intern_names() -> bool {
599600
/// Enables ghost constraint parsing and resolving.
600601
pub fn enable_ghost_constraints() -> bool {
601602
read_setting("enable_ghost_constraints")
603+
}
604+
605+
/// Enables (experimental) iterator support
606+
pub fn enable_iterators() -> bool {
607+
read_setting("enable_iterators")
602608
}

prusti-viper/src/encoder/procedure_encoder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2196,9 +2196,9 @@ impl<'p, 'v: 'p, 'tcx: 'v> ProcedureEncoder<'p, 'v, 'tcx> {
21962196
}
21972197

21982198
"std::iter::Iterator::next" |
2199-
"core::iter::Iterator::next" => {
2199+
"core::iter::Iterator::next" if !config::enable_iterators() => {
22002200
return Err(SpannedEncodingError::unsupported(
2201-
"iterators are not fully supported yet",
2201+
"iterators are not fully supported yet, enable them with a feature flag",
22022202
term.source_info.span,
22032203
));
22042204
}

0 commit comments

Comments
 (0)