Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ impl Callbacks for CompilerCalls {
.push((pass.to_owned(), false));
}

// A call inlined by the MIR inliner leaves no `Call` terminator behind, so the
// arguments are never checked against the callee's specification.
config.opts.unstable_opts.inline_mir = Some(false);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Account for the mandatory force-inlining pass

When a verified crate enables rustc_attrs and marks a specified or trusted callee with #[rustc_force_inline], this setting does not preserve its Call terminator: rustc runs a separate mandatory ForceInline pass whose is_enabled always returns true and which cannot be overridden (rustc source). Consequently, such a callee's precondition can still disappear and an invalid call can verify as safe; account for this pass or reject specifications on force-inlined functions rather than claiming all calls remain visible.

Useful? React with 👍 / 👎.


config.override_queries = Some(|_sess, providers| {
providers.mir_borrowck = thrust::mir_borrowck_skip_formula_fn;
});
Expand Down
11 changes: 11 additions & 0 deletions tests/ui/fail/trusted_requires_opt_level.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//@error-in-other-file: Unsat
//@compile-flags: -C debug-assertions=off -C opt-level=3

#[thrust::trusted]
#[thrust_macros::requires(x != 0)]
#[thrust_macros::ensures(true)]
fn assume_nonzero(x: i32) {}

fn main() {
assume_nonzero(0);
}
11 changes: 11 additions & 0 deletions tests/ui/pass/trusted_requires_opt_level.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//@check-pass
//@compile-flags: -C debug-assertions=off -C opt-level=3

#[thrust::trusted]
#[thrust_macros::requires(x != 0)]
#[thrust_macros::ensures(true)]
fn assume_nonzero(x: i32) {}

fn main() {
assume_nonzero(1);
}
Loading