Skip to content

Commit

Permalink
Ignore generator function parameters (rust-lang#1130)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhassan-aws authored Apr 29, 2022
1 parent 0aada0c commit cbac10c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kani-compiler/src/codegen_cprover_gotoc/codegen/typ.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,10 @@ impl<'tcx> GotocCtx<'tcx> {
pub fn ignore_var_ty(&self, ty: Ty<'tcx>) -> bool {
match ty.kind() {
ty::FnDef(_, _) => true,
// Ignore variables of the generator type until we add support for
// them:
// https://github.com/model-checking/kani/issues/416
ty::Generator(..) => true,
_ => false,
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/expected/generators/as_parameter/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Status: FAILURE\
Description: "ty::Generator is not currently supported by Kani. Please post your example at https://github.com/model-checking/kani/issues/416"
24 changes: 24 additions & 0 deletions tests/expected/generators/as_parameter/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR MIT

// Test that includes a generator as a parameter to a function
// Codegen should succeed, but verification should fail (codegen_unimplemented)

#![feature(generators, generator_trait)]

use std::ops::Generator;

fn foo<T>(g: T)
where
T: Generator,
{
let _ = g;
}

#[kani::proof]
fn main() {
foo(|| {
yield 1;
return 2;
});
}

0 comments on commit cbac10c

Please sign in to comment.