-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
6 changed files
with
63 additions
and
19 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 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,19 @@ | ||
// Regression test for #130310 | ||
// Tests that we do not fall into infinite | ||
// recursion while checking FFI safety of | ||
// recursive types like `A<T>` below | ||
|
||
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<()>); | ||
//~^ ERROR reached recursion limit while checking type `*const A<()>` for FFI safety | ||
} | ||
|
||
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,8 @@ | ||
error: reached recursion limit while checking type `*const A<()>` for FFI safety | ||
--> $DIR/improper-types-stack-overflow-130310.rs:15:13 | ||
| | ||
LL | fn f(a: *const A<()>); | ||
| ^^^^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|