forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add recursion limit to FFI safety lint
Fixes stack overflow in the case of recursive types
- Loading branch information
Showing
5 changed files
with
50 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Regression test for #130310 | ||
// Tests that we do not fall into infinite | ||
// recursion while checking FFI safety of | ||
// recursive types like `A<T>` below | ||
|
||
//@ build-pass | ||
use std::marker::PhantomData; | ||
|
||
#[repr(C)] | ||
struct A<T> { | ||
a: *const A<A<T>>, // Recursive because of this field | ||
p: PhantomData<T>, | ||
} | ||
|
||
extern "C" { | ||
fn f(a: *const A<()>); | ||
//~^ WARN `extern` block uses type `*const A<()>`, which is not FFI-safe | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
warning: `extern` block uses type `*const A<()>`, which is not FFI-safe | ||
--> $DIR/improper-types-stack-overflow-130310.rs:16:13 | ||
| | ||
LL | fn f(a: *const A<()>); | ||
| ^^^^^^^^^^^^ not FFI-safe | ||
| | ||
= note: type is infinitely recursive | ||
= note: `#[warn(improper_ctypes)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|