diff options
| author | Ralf Jung <post@ralfj.de> | 2025-05-12 05:40:31 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-12 05:40:31 +0000 |
| commit | 8bfc88f057206d79618ded5b6b6156c6a9daaaa8 (patch) | |
| tree | 646043ebdc679f5d8da3ae7c5858a0ad2a8a38e5 /compiler/rustc_codegen_llvm/src/llvm/mod.rs | |
| parent | cbd4db0b7c680258e17517e31efc04b6afe22464 (diff) | |
| parent | 7479482e2166e82b46d621b2759c6af0dda820e8 (diff) | |
| download | rust-8bfc88f057206d79618ded5b6b6156c6a9daaaa8.tar.gz rust-8bfc88f057206d79618ded5b6b6156c6a9daaaa8.zip | |
Merge pull request #4319 from rust-lang/rustup-2025-05-12
Automatic Rustup
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/llvm/mod.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/llvm/mod.rs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_llvm/src/llvm/mod.rs b/compiler/rustc_codegen_llvm/src/llvm/mod.rs index d14aab06073..606d97619a0 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/mod.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/mod.rs @@ -363,12 +363,13 @@ pub(crate) fn last_error() -> Option<String> { } } -/// Owns an [`OperandBundle`], and will dispose of it when dropped. -pub(crate) struct OperandBundleOwned<'a> { +/// Owning pointer to an [`OperandBundle`] that will dispose of the bundle +/// when dropped. +pub(crate) struct OperandBundleBox<'a> { raw: ptr::NonNull<OperandBundle<'a>>, } -impl<'a> OperandBundleOwned<'a> { +impl<'a> OperandBundleBox<'a> { pub(crate) fn new(name: &str, vals: &[&'a Value]) -> Self { let raw = unsafe { LLVMCreateOperandBundle( @@ -378,21 +379,21 @@ impl<'a> OperandBundleOwned<'a> { vals.len() as c_uint, ) }; - OperandBundleOwned { raw: ptr::NonNull::new(raw).unwrap() } + Self { raw: ptr::NonNull::new(raw).unwrap() } } - /// Returns inner `OperandBundle` type. + /// Dereferences to the underlying `&OperandBundle`. /// - /// This could be a `Deref` implementation, but `OperandBundle` contains an extern type and - /// `Deref::Target: ?Sized`. - pub(crate) fn raw(&self) -> &OperandBundle<'a> { + /// This can't be a `Deref` implementation because `OperandBundle` transitively + /// contains an extern type, which is incompatible with `Deref::Target: ?Sized`. + pub(crate) fn as_ref(&self) -> &OperandBundle<'a> { // SAFETY: The returned reference is opaque and can only used for FFI. // It is valid for as long as `&self` is. unsafe { self.raw.as_ref() } } } -impl Drop for OperandBundleOwned<'_> { +impl Drop for OperandBundleBox<'_> { fn drop(&mut self) { unsafe { LLVMDisposeOperandBundle(self.raw); |
