Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on May 28, 2025. It is now read-only.
/rustPublic archive
forked fromrust-lang/rust

Commite9cfac3

Browse files
authored
Unrolled build forrust-lang#123714
Rollup merge ofrust-lang#123714 - cjgillot:static-fnptr, r=wesleywiserAdd test for fn pointer duplication.I managed to make it fail when removing provenance checks in GVN.ccrust-lang#123670r? ``````@oli-obk``````
2 parents9ed2ab3 +4c779d7 commite9cfac3

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ compile-flags:-O
2+
3+
#[inline]
4+
fnfoo(){}
5+
6+
pubstaticADDR:fn() = foo;
7+
8+
#[inline(always)]
9+
pubfnbar(x:fn()) ->bool{
10+
x ==ADDR
11+
}

‎tests/ui/mir/static_fnptr.rs‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//! Verify that we correctly handle fn pointer provenance in MIR optimizations.
2+
//! By asking to inline `static_fnptr::bar`, we have two copies of `static_fnptr::foo`, one in the
3+
//! auxiliary crate and one in the local crate CGU.
4+
//! `baz` must only consider the versions from upstream crate, and not try to compare with the
5+
//! address of the CGU-local copy.
6+
//! Related issue: #123670
7+
8+
//@ run-pass
9+
//@ compile-flags:-Cno-prepopulate-passes -Copt-level=0
10+
//@ aux-build:static_fnptr.rs
11+
12+
externcrate static_fnptr;
13+
use static_fnptr::{ADDR, bar};
14+
15+
fnbaz() ->bool{
16+
bar(ADDR)
17+
}
18+
19+
fnmain(){
20+
assert!(baz())
21+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp