Skip to content

Commit cbac10c

Browse files
authored
Ignore generator function parameters (rust-lang#1130)
1 parent 0aada0c commit cbac10c

File tree

3 files changed

+30
-0
lines changed
  • kani-compiler/src/codegen_cprover_gotoc/codegen
  • tests/expected/generators/as_parameter

3 files changed

+30
-0
lines changed

kani-compiler/src/codegen_cprover_gotoc/codegen/typ.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,10 @@ impl<'tcx> GotocCtx<'tcx> {
13151315
pub fn ignore_var_ty(&self, ty: Ty<'tcx>) -> bool {
13161316
match ty.kind() {
13171317
ty::FnDef(_, _) => true,
1318+
// Ignore variables of the generator type until we add support for
1319+
// them:
1320+
// https://github.com/model-checking/kani/issues/416
1321+
ty::Generator(..) => true,
13181322
_ => false,
13191323
}
13201324
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Status: FAILURE\
2+
Description: "ty::Generator is not currently supported by Kani. Please post your example at https://github.com/model-checking/kani/issues/416"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
// Test that includes a generator as a parameter to a function
5+
// Codegen should succeed, but verification should fail (codegen_unimplemented)
6+
7+
#![feature(generators, generator_trait)]
8+
9+
use std::ops::Generator;
10+
11+
fn foo<T>(g: T)
12+
where
13+
T: Generator,
14+
{
15+
let _ = g;
16+
}
17+
18+
#[kani::proof]
19+
fn main() {
20+
foo(|| {
21+
yield 1;
22+
return 2;
23+
});
24+
}

0 commit comments

Comments
 (0)