fix: vGPU borrow-ergonomics follow-ups from #130 - #144
Merged
Conversation
- 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
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-ups to the review discussion on #130 — no behavior changes, all API-loosening:
VgpuInstance::instance_type()now takes&selfinstead of&'dev self. The old receiver borrowed the instance for'dev, so keeping the returnedVgpuTypebeyond the instance's scope (e.g. querying the type, dropping the instance, then using the type) failed withE0597: does not live long enough. (Patterns where theVgpuTypestayed inside the instance's scope already compiled, since covariance let'devshrink at the call site.)Device::active_vgpus()drops the unnecessary<'a> ... where 'a: 'nvmlclause and returnsVgpuInstance<'_>tied to the device borrow. The old clause forced'a == 'nvml; the new signature accepts a strict superset of caller patterns (Deviceis covariant in'nvml).VgpuInstance::newis now public with docs, mirroringVgpuType::new. This gives non-Linux builds a constructor story and removes thedead_codewarning there, where the Linux-gatedactive_vgpus()was its only caller. A garbage instance ID is safe: every FFI path checks the NVML return status, so it yieldsErr(NotFound)/Err(InvalidArg), never UB.Verified: compile probes for the fixed patterns pass on Linux and macOS targets (and reproduce
E0597against main as a negative control);cargo check --all-features(lib + tests) is warning-free on both;cargo fmt --checkpasses; clippy andcargo docshow only pre-existing warnings. No post-1.60 constructs.🤖 Generated with Claude Code
https://claude.ai/code/session_01FVPWxFN8rioYb8JhreYQmJ