Skip to content

Commit 852891b

Browse files
committed
Fix parsing error in desugared specifications
Type asccription has been removed by RFC 803: rust-lang/rfcs#3307
1 parent fe877bd commit 852891b

File tree

3 files changed

+7
-18
lines changed

3 files changed

+7
-18
lines changed

prusti-contracts/prusti-contracts/tests/pass/true.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

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

prusti-contracts/prusti-specs/src/rewriter.rs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,30 +105,21 @@ impl AstRewriter {
105105
// - `item_span` is set to `expr.span()` so that any errors reported
106106
// for the spec item will be reported on the span of the expression
107107
// written by the user
108-
// - `((#expr) : bool)` syntax is used to report type errors in the
108+
// - `let ...: bool = #expr` syntax is used to report type errors in the
109109
// expression with the correct error message, i.e. that the expected
110110
// type is `bool`, not that the expected *return* type is `bool`
111-
// - `!!(...)` is used to fix an edge-case when the expression consists
112-
// of a single identifier; without the double negation, the `Return`
113-
// terminator in MIR has a span set to the one character just after
114-
// the identifier
115-
let (return_type, return_modifier) = match &spec_type {
116-
SpecItemType::Termination => (
117-
quote_spanned! {item_span => Int},
118-
quote_spanned! {item_span => Int::new(0) + },
119-
),
120-
SpecItemType::Predicate(return_type) => (return_type.clone(), TokenStream::new()),
121-
_ => (
122-
quote_spanned! {item_span => bool},
123-
quote_spanned! {item_span => !!},
124-
),
111+
let return_type = match &spec_type {
112+
SpecItemType::Termination => quote_spanned! {item_span => Int},
113+
SpecItemType::Predicate(return_type) => return_type.clone(),
114+
_ => quote_spanned! {item_span => bool},
125115
};
126116
let mut spec_item: syn::ItemFn = parse_quote_spanned! {item_span=>
127117
#[allow(unused_must_use, unused_parens, unused_variables, dead_code, non_snake_case)]
128118
#[prusti::spec_only]
129119
#[prusti::spec_id = #spec_id_str]
130120
fn #item_name() -> #return_type {
131-
#return_modifier ((#expr) : #return_type)
121+
let prusti_result: #return_type = #expr;
122+
prusti_result
132123
}
133124
};
134125

prusti/src/driver.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ fn main() {
209209
}
210210

211211
rustc_args.push("-Zalways-encode-mir".to_owned());
212-
rustc_args.push("-Zcrate-attr=feature(type_ascription)".to_owned());
213212
rustc_args.push("-Zcrate-attr=feature(stmt_expr_attributes)".to_owned());
214213
rustc_args.push("-Zcrate-attr=feature(register_tool)".to_owned());
215214
rustc_args.push("-Zcrate-attr=register_tool(prusti)".to_owned());

0 commit comments

Comments
 (0)