Skip to content

Commit ad7d754

Browse files
borsgitbot
authored and
gitbot
committed
Auto merge of rust-lang#135465 - jhpratt:rollup-7p93bct, r=jhpratt
Rollup of 10 pull requests Successful merges: - rust-lang#134498 (Fix cycle error only occurring with -Zdump-mir) - rust-lang#134977 (Detect `mut arg: &Ty` meant to be `arg: &mut Ty` and provide structured suggestion) - rust-lang#135390 (Re-added regression test for rust-lang#122638) - rust-lang#135393 (uefi: helpers: Introduce OwnedDevicePath) - rust-lang#135440 (rm unnecessary `OpaqueTypeDecl` wrapper) - rust-lang#135441 (Make sure to mark `IMPL_TRAIT_REDUNDANT_CAPTURES` as `Allow` in edition 2024) - rust-lang#135444 (Update books) - rust-lang#135450 (Fix emscripten-wasm-eh with unwind=abort) - rust-lang#135452 (bootstrap: fix outdated feature name in comment) - rust-lang#135454 (llvm: Allow sized-word rather than ymmword in tests) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9b7fbf1 + 3bc678c commit ad7d754

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

std/src/sys/pal/uefi/helpers.rs

+15-6
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,14 @@ pub(crate) fn runtime_services() -> Option<NonNull<r_efi::efi::RuntimeServices>>
222222
NonNull::new(runtime_services)
223223
}
224224

225-
pub(crate) struct DevicePath(NonNull<r_efi::protocols::device_path::Protocol>);
225+
pub(crate) struct OwnedDevicePath(NonNull<r_efi::protocols::device_path::Protocol>);
226226

227-
impl DevicePath {
227+
impl OwnedDevicePath {
228228
pub(crate) fn from_text(p: &OsStr) -> io::Result<Self> {
229229
fn inner(
230230
p: &OsStr,
231231
protocol: NonNull<r_efi::protocols::device_path_from_text::Protocol>,
232-
) -> io::Result<DevicePath> {
232+
) -> io::Result<OwnedDevicePath> {
233233
let path_vec = p.encode_wide().chain(Some(0)).collect::<Vec<u16>>();
234234
if path_vec[..path_vec.len() - 1].contains(&0) {
235235
return Err(const_error!(
@@ -242,7 +242,7 @@ impl DevicePath {
242242
unsafe { ((*protocol.as_ptr()).convert_text_to_device_path)(path_vec.as_ptr()) };
243243

244244
NonNull::new(path)
245-
.map(DevicePath)
245+
.map(OwnedDevicePath)
246246
.ok_or_else(|| const_error!(io::ErrorKind::InvalidFilename, "Invalid Device Path"))
247247
}
248248

@@ -275,12 +275,12 @@ impl DevicePath {
275275
))
276276
}
277277

278-
pub(crate) fn as_ptr(&self) -> *mut r_efi::protocols::device_path::Protocol {
278+
pub(crate) const fn as_ptr(&self) -> *mut r_efi::protocols::device_path::Protocol {
279279
self.0.as_ptr()
280280
}
281281
}
282282

283-
impl Drop for DevicePath {
283+
impl Drop for OwnedDevicePath {
284284
fn drop(&mut self) {
285285
if let Some(bt) = boot_services() {
286286
let bt: NonNull<r_efi::efi::BootServices> = bt.cast();
@@ -291,6 +291,15 @@ impl Drop for DevicePath {
291291
}
292292
}
293293

294+
impl crate::fmt::Debug for OwnedDevicePath {
295+
fn fmt(&self, f: &mut crate::fmt::Formatter<'_>) -> crate::fmt::Result {
296+
match device_path_to_text(self.0) {
297+
Ok(p) => p.fmt(f),
298+
Err(_) => f.debug_struct("OwnedDevicePath").finish_non_exhaustive(),
299+
}
300+
}
301+
}
302+
294303
pub(crate) struct OwnedProtocol<T> {
295304
guid: r_efi::efi::Guid,
296305
handle: NonNull<crate::ffi::c_void>,

std/src/sys/pal/uefi/process.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ mod uefi_command_internal {
326326

327327
impl Image {
328328
pub fn load_image(p: &OsStr) -> io::Result<Self> {
329-
let path = helpers::DevicePath::from_text(p)?;
329+
let path = helpers::OwnedDevicePath::from_text(p)?;
330330
let boot_services: NonNull<r_efi::efi::BootServices> = boot_services()
331331
.ok_or_else(|| const_error!(io::ErrorKind::NotFound, "Boot Services not found"))?
332332
.cast();

0 commit comments

Comments
 (0)