Skip to content

Commit da77fab

Browse files
authored
Rollup merge of rust-lang#115540 - cjgillot:custom-debuginfo, r=oli-obk
Support debuginfo for custom MIR.
2 parents 27599f9 + d041ae8 commit da77fab

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

core/src/intrinsics/mir.rs

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
//!
1313
//! Typical usage will look like this:
1414
//!
15-
//! ```rust
15+
#![cfg_attr(bootstrap, doc = "```rust,ignore")]
16+
#![cfg_attr(not(bootstrap), doc = "```rust")]
1617
//! #![feature(core_intrinsics, custom_mir)]
1718
//! #![allow(internal_features)]
1819
//!
@@ -62,7 +63,8 @@
6263
//!
6364
//! # Examples
6465
//!
65-
//! ```rust
66+
#![cfg_attr(bootstrap, doc = "```rust,ignore")]
67+
#![cfg_attr(not(bootstrap), doc = "```rust")]
6668
//! #![feature(core_intrinsics, custom_mir)]
6769
//! #![allow(internal_features)]
6870
//!
@@ -317,7 +319,8 @@ define!(
317319
///
318320
/// # Examples
319321
///
320-
/// ```rust
322+
#[cfg_attr(bootstrap, doc = "```rust,ignore")]
323+
#[cfg_attr(not(bootstrap), doc = "```rust")]
321324
/// #![allow(internal_features)]
322325
/// #![feature(custom_mir, core_intrinsics)]
323326
///
@@ -361,6 +364,11 @@ define!(
361364
#[doc(hidden)]
362365
fn __internal_make_place<T>(place: T) -> *mut T
363366
);
367+
define!(
368+
"mir_debuginfo",
369+
#[doc(hidden)]
370+
fn __debuginfo<T>(name: &'static str, s: T)
371+
);
364372

365373
/// Macro for generating custom MIR.
366374
///
@@ -371,6 +379,7 @@ pub macro mir {
371379
(
372380
$(type RET = $ret_ty:ty ;)?
373381
$(let $local_decl:ident $(: $local_decl_ty:ty)? ;)*
382+
$(debug $dbg_name:ident => $dbg_data:expr ;)*
374383

375384
{
376385
$($entry:tt)*
@@ -394,26 +403,32 @@ pub macro mir {
394403
$(
395404
let $local_decl $(: $local_decl_ty)? ;
396405
)*
397-
398406
::core::intrinsics::mir::__internal_extract_let!($($entry)*);
399407
$(
400408
::core::intrinsics::mir::__internal_extract_let!($($block)*);
401409
)*
402410

403411
{
404-
// Finally, the contents of the basic blocks
405-
::core::intrinsics::mir::__internal_remove_let!({
406-
{}
407-
{ $($entry)* }
408-
});
412+
// Now debuginfo
409413
$(
414+
__debuginfo(stringify!($dbg_name), $dbg_data);
415+
)*
416+
417+
{
418+
// Finally, the contents of the basic blocks
410419
::core::intrinsics::mir::__internal_remove_let!({
411420
{}
412-
{ $($block)* }
421+
{ $($entry)* }
413422
});
414-
)*
423+
$(
424+
::core::intrinsics::mir::__internal_remove_let!({
425+
{}
426+
{ $($block)* }
427+
});
428+
)*
415429

416-
RET
430+
RET
431+
}
417432
}
418433
}
419434
}}

0 commit comments

Comments
 (0)