Skip to content

Commit

Permalink
Fix parsing error in desugared specifications
Browse files Browse the repository at this point in the history
Type ascription has been removed by RFC 803: rust-lang/rfcs#3307
  • Loading branch information
fpoli authored and vakaras committed Jul 20, 2023
1 parent 1494c9d commit fc54888
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
1 change: 0 additions & 1 deletion prusti-contracts/prusti-contracts/tests/pass/true.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

// These feature flags are not needed when executing under Prusti
// because it generates them for us.
#![cfg_attr(feature = "prusti", feature(type_ascription))]
#![cfg_attr(feature = "prusti", feature(register_tool))]
#![cfg_attr(feature = "prusti", register_tool(prusti))]

Expand Down
23 changes: 7 additions & 16 deletions prusti-contracts/prusti-specs/src/rewriter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,30 +105,21 @@ impl AstRewriter {
// - `item_span` is set to `expr.span()` so that any errors reported
// for the spec item will be reported on the span of the expression
// written by the user
// - `((#expr) : bool)` syntax is used to report type errors in the
// - `let ...: bool = #expr` syntax is used to report type errors in the
// expression with the correct error message, i.e. that the expected
// type is `bool`, not that the expected *return* type is `bool`
// - `!!(...)` is used to fix an edge-case when the expression consists
// of a single identifier; without the double negation, the `Return`
// terminator in MIR has a span set to the one character just after
// the identifier
let (return_type, return_modifier) = match &spec_type {
SpecItemType::Termination => (
quote_spanned! {item_span => Int},
quote_spanned! {item_span => Int::new(0) + },
),
SpecItemType::Predicate(return_type) => (return_type.clone(), TokenStream::new()),
_ => (
quote_spanned! {item_span => bool},
quote_spanned! {item_span => !!},
),
let return_type = match &spec_type {
SpecItemType::Termination => quote_spanned! {item_span => Int},
SpecItemType::Predicate(return_type) => return_type.clone(),
_ => quote_spanned! {item_span => bool},
};
let mut spec_item: syn::ItemFn = parse_quote_spanned! {item_span=>
#[allow(unused_must_use, unused_parens, unused_variables, dead_code, non_snake_case)]
#[prusti::spec_only]
#[prusti::spec_id = #spec_id_str]
fn #item_name() -> #return_type {
#return_modifier ((#expr) : #return_type)
let prusti_result: #return_type = #expr;
prusti_result
}
};

Expand Down
1 change: 0 additions & 1 deletion prusti/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ fn main() {
}

rustc_args.push("-Zalways-encode-mir".to_owned());
rustc_args.push("-Zcrate-attr=feature(type_ascription)".to_owned());
rustc_args.push("-Zcrate-attr=feature(stmt_expr_attributes)".to_owned());
rustc_args.push("-Zcrate-attr=feature(register_tool)".to_owned());
rustc_args.push("-Zcrate-attr=register_tool(prusti)".to_owned());
Expand Down

0 comments on commit fc54888

Please sign in to comment.