Skip to content

fix: vGPU borrow-ergonomics follow-ups from #130 - #144

Merged
brayniac merged 1 commit into
rust-nvml:mainfrom
brayniac:fix/vgpu-followup-nits
Aug 31, 2026
Merged

fix: vGPU borrow-ergonomics follow-ups from #130#144
brayniac merged 1 commit into
rust-nvml:mainfrom
brayniac:fix/vgpu-followup-nits

Conversation

@brayniac

@brayniac brayniac commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Follow-ups to the review discussion on #130 — no behavior changes, all API-loosening:

  • VgpuInstance::instance_type() now takes &self instead of &'dev self. The old receiver borrowed the instance for 'dev, so keeping the returned VgpuType beyond the instance's scope (e.g. querying the type, dropping the instance, then using the type) failed with E0597: does not live long enough. (Patterns where the VgpuType stayed inside the instance's scope already compiled, since covariance let 'dev shrink at the call site.)
  • Device::active_vgpus() drops the unnecessary <'a> ... where 'a: 'nvml clause and returns VgpuInstance<'_> tied to the device borrow. The old clause forced 'a == 'nvml; the new signature accepts a strict superset of caller patterns (Device is covariant in 'nvml).
  • VgpuInstance::new is now public with docs, mirroring VgpuType::new. This gives non-Linux builds a constructor story and removes the dead_code warning there, where the Linux-gated active_vgpus() was its only caller. A garbage instance ID is safe: every FFI path checks the NVML return status, so it yields Err(NotFound)/Err(InvalidArg), never UB.

Verified: compile probes for the fixed patterns pass on Linux and macOS targets (and reproduce E0597 against main as a negative control); cargo check --all-features (lib + tests) is warning-free on both; cargo fmt --check passes; clippy and cargo doc show only pre-existing warnings. No post-1.60 constructs.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FVPWxFN8rioYb8JhreYQmJ

- instance_type() now takes &self instead of &'dev self, so calling it
  no longer borrows the VgpuInstance for the rest of the device's
  lifetime (e.g. iterating active_vgpus() and querying each instance's
  type now compiles)
- active_vgpus() drops the unnecessary <'a> ... where 'a: 'nvml clause
  and returns VgpuInstance<'_> tied to the device borrow
- VgpuInstance::new is now public with docs, mirroring VgpuType::new;
  this also removes the dead-code warning on non-Linux builds where the
  Linux-gated active_vgpus() was its only caller

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FVPWxFN8rioYb8JhreYQmJ
@brayniac
brayniac merged commit c5dedc7 into rust-nvml:main Aug 31, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant