rust/tests/ui/mir/static_fnptr.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
617 B
Rust
Raw Permalink Normal View History

2024-04-10 05:15:26 -05:00
//! Verify that we correctly handle fn pointer provenance in MIR optimizations.
//! By asking to inline `static_fnptr::bar`, we have two copies of `static_fnptr::foo`, one in the
//! auxiliary crate and one in the local crate CGU.
//! `baz` must only consider the versions from upstream crate, and not try to compare with the
//! address of the CGU-local copy.
//! Related issue: #123670
2024-04-09 18:17:45 -05:00
//@ run-pass
//@ compile-flags:-Cno-prepopulate-passes -Copt-level=0
//@ aux-build:static_fnptr.rs
extern crate static_fnptr;
use static_fnptr::{ADDR, bar};
fn baz() -> bool {
bar(ADDR)
}
fn main() {
assert!(baz())
}