-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Fix clashing_extern_declarations stack overflow for recursive types. #75554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bors
merged 10 commits into
rust-lang:master
from
jumbatm:fix-clashing-extern-decl-overflow
Aug 19, 2020
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b0eb55a
Add test demonstrating the issue.
jumbatm db75313
Fix stack overflow for recursive types.
jumbatm 154b74e
Actually introduce a cycle in Reffy test.
jumbatm a1fa4e0
Remove unnecessary rebinding of def ids.
jumbatm 80c2c80
Remove structural equiv check for Array const.
jumbatm bca48ad
Reduce indentation by replacing match arm w/ early return.
jumbatm 6c57de1
Don't memoize seen types.
jumbatm 7708abb
Avoid double hashset lookup.
jumbatm 1321a2d
Also accept Refs for is_primitive_or_pointer
jumbatm bc15dd6
Wrap recursion in `ensure_sufficient_stack`.
jumbatm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,119 @@ | ||
// check-pass | ||
// | ||
// This tests checks that clashing_extern_declarations handles types that are recursive through a | ||
// pointer or ref argument. See #75512. | ||
|
||
#![crate_type = "lib"] | ||
|
||
mod raw_ptr_recursion { | ||
mod a { | ||
#[repr(C)] | ||
struct Pointy { | ||
pointy: *const Pointy, | ||
} | ||
|
||
extern "C" { | ||
fn run_pointy(pointy: Pointy); | ||
} | ||
} | ||
mod b { | ||
#[repr(C)] | ||
struct Pointy { | ||
pointy: *const Pointy, | ||
} | ||
|
||
extern "C" { | ||
fn run_pointy(pointy: Pointy); | ||
} | ||
} | ||
} | ||
|
||
mod raw_ptr_recursion_once_removed { | ||
mod a { | ||
#[repr(C)] | ||
struct Pointy1 { | ||
pointy_two: *const Pointy2, | ||
} | ||
|
||
#[repr(C)] | ||
struct Pointy2 { | ||
pointy_one: *const Pointy1, | ||
} | ||
|
||
extern "C" { | ||
fn run_pointy2(pointy: Pointy2); | ||
} | ||
} | ||
|
||
mod b { | ||
#[repr(C)] | ||
struct Pointy1 { | ||
pointy_two: *const Pointy2, | ||
} | ||
|
||
#[repr(C)] | ||
struct Pointy2 { | ||
pointy_one: *const Pointy1, | ||
} | ||
|
||
extern "C" { | ||
fn run_pointy2(pointy: Pointy2); | ||
} | ||
} | ||
} | ||
|
||
mod ref_recursion { | ||
mod a { | ||
#[repr(C)] | ||
struct Reffy<'a> { | ||
reffy: &'a Reffy<'a>, | ||
} | ||
|
||
extern "C" { | ||
fn reffy_recursion(reffy: Reffy); | ||
} | ||
} | ||
mod b { | ||
#[repr(C)] | ||
struct Reffy<'a> { | ||
reffy: &'a Reffy<'a>, | ||
} | ||
|
||
extern "C" { | ||
fn reffy_recursion(reffy: Reffy); | ||
} | ||
} | ||
} | ||
|
||
mod ref_recursion_once_removed { | ||
mod a { | ||
#[repr(C)] | ||
struct Reffy1<'a> { | ||
reffy: &'a Reffy2<'a>, | ||
} | ||
|
||
struct Reffy2<'a> { | ||
reffy: &'a Reffy1<'a>, | ||
} | ||
jumbatm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
extern "C" { | ||
#[allow(improper_ctypes)] | ||
fn reffy_once_removed(reffy: Reffy1); | ||
} | ||
} | ||
mod b { | ||
#[repr(C)] | ||
struct Reffy1<'a> { | ||
reffy: &'a Reffy2<'a>, | ||
} | ||
|
||
struct Reffy2<'a> { | ||
reffy: &'a Reffy1<'a>, | ||
} | ||
|
||
extern "C" { | ||
#[allow(improper_ctypes)] | ||
fn reffy_once_removed(reffy: Reffy1); | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.