Skip to content
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

Spurious "infinitely recursive" not ffi-safe warning #130757

Closed
ChrisDenton opened this issue Sep 23, 2024 · 3 comments · Fixed by #130758
Closed

Spurious "infinitely recursive" not ffi-safe warning #130757

ChrisDenton opened this issue Sep 23, 2024 · 3 comments · Fixed by #130758
Assignees
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. L-improper_ctypes Lint: improper_ctypes T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ChrisDenton
Copy link
Member

ChrisDenton commented Sep 23, 2024

The windows-rs crate is getting a whole bunch of spurious FFI-safe warnings:

 error: `extern` block uses type `*mut CRYPT_PROVIDER_FUNCTIONS`, which is not FFI-safe
  --> crates/libs/sys/src/Windows/Win32/Security/WinTrust/mod.rs:23:131
   |
23 | ...ionid : *mut windows_sys::core::GUID, ppfns : *mut CRYPT_PROVIDER_FUNCTIONS) -> super::super::Foundation:: BOOL);
   |                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
   |
   = note: type is infinitely recursive

error: could not compile `windows-sys` (lib) due to 668 previous errors

See: https://github.com/microsoft/windows-rs/actions/runs/10997420795/job/30532923854?pr=3291

@ChrisDenton ChrisDenton added the C-bug Category: This is a bug. label Sep 23, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 23, 2024
@jieyouxu jieyouxu added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. L-improper_ctypes Lint: improper_ctypes T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 23, 2024
@jieyouxu
Copy link
Member

cc #130598 which introduced the recursion limit.

@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 23, 2024
@compiler-errors
Copy link
Member

Repro:

#![recursion_limit = "5"]
#![deny(improper_ctypes)]

#[repr(C)]
struct F1(*const ());
#[repr(C)]
struct F2(*const ());
#[repr(C)]
struct F3(*const ());
#[repr(C)]
struct F4(*const ());
#[repr(C)]
struct F5(*const ());
#[repr(C)]
struct F6(*const ());

#[repr(C)]
struct B {
    f1: F1,
    f2: F2,
    f3: F3,
    f4: F4,
    f5: F5,
    f6: F6,
}

extern "C" fn foo(_: B) {}

@compiler-errors
Copy link
Member

Anyways I'll put up a revert PR

@rustbot claim

compiler-errors added a commit to compiler-errors/rust that referenced this issue Sep 24, 2024
…mit, r=jieyouxu

Revert "Add recursion limit to FFI safety lint"

It's not necessarily clear if warning when we hit the recursion limit is the right thing to do, first of all.

**More importantly**, this PR was implemented incorrectly in the first place; it was not decrementing the recursion limit when stepping out of a type, so it would trigger when a ctype has more than RECURSION_LIMIT fields *anywhere* in the type's set of recursively reachable fields.

Reverts rust-lang#130598
Reopens rust-lang#130310
Fixes rust-lang#130757
@bors bors closed this as completed in fa1bd9b Sep 24, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Sep 24, 2024
Rollup merge of rust-lang#130758 - compiler-errors:ctype-recursion-limit, r=jieyouxu

Revert "Add recursion limit to FFI safety lint"

It's not necessarily clear if warning when we hit the recursion limit is the right thing to do, first of all.

**More importantly**, this PR was implemented incorrectly in the first place; it was not decrementing the recursion limit when stepping out of a type, so it would trigger when a ctype has more than RECURSION_LIMIT fields *anywhere* in the type's set of recursively reachable fields.

Reverts rust-lang#130598
Reopens rust-lang#130310
Fixes rust-lang#130757
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. L-improper_ctypes Lint: improper_ctypes T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants