mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-28 20:16:58 +03:00
contracts: fix lowering final declaration without trailing semicolon
Lowering for contract delcarations incorrectly handled the final declaration statement when it didn't end in a semicolon. This change fixes the issue.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
//@ run-pass
|
||||
//@ compile-flags: -Zcontract-checks=yes
|
||||
|
||||
#![expect(incomplete_features)]
|
||||
#![feature(contracts)]
|
||||
extern crate core;
|
||||
use core::contracts::requires;
|
||||
|
||||
// Compound statements (those using [ExpressionWithBlock]
|
||||
// (https://doc.rust-lang.org/beta/reference/expressions.html#railroad-ExpressionWithBlock))
|
||||
// like blocks, if-expressions, and loops require no trailing semicolon. This
|
||||
// regression test captures the case where the last statement in the contract
|
||||
// declarations has no trailing semicolon.
|
||||
#[requires(
|
||||
{}
|
||||
true
|
||||
)]
|
||||
fn foo() {}
|
||||
|
||||
fn main() {
|
||||
foo()
|
||||
}
|
||||
Reference in New Issue
Block a user