about summary refs log tree commit diff
path: root/library/core/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-09-05 15:16:51 +0200
committerGitHub <noreply@github.com>2023-09-05 15:16:51 +0200
commit9381e5bf58db6c8fecdcf1ad9a5fb8efbfc4b5c3 (patch)
treedd02d0830e0313e3b47da8a8d5562ce986c95f5f /library/core/src
parent09974dfc69c4dedb711cdc2feca195f62b01666f (diff)
parent905fd1ba17617c273f7ff04fbb23e7253ccd77c4 (diff)
downloadrust-9381e5bf58db6c8fecdcf1ad9a5fb8efbfc4b5c3.tar.gz
rust-9381e5bf58db6c8fecdcf1ad9a5fb8efbfc4b5c3.zip
Rollup merge of #115540 - cjgillot:custom-debuginfo, r=oli-obk
Support debuginfo for custom MIR.
Diffstat (limited to 'library/core/src')
-rw-r--r--library/core/src/intrinsics/mir.rs39
1 files changed, 27 insertions, 12 deletions
diff --git a/library/core/src/intrinsics/mir.rs b/library/core/src/intrinsics/mir.rs
index b99346b6ba6..cab195dad9b 100644
--- a/library/core/src/intrinsics/mir.rs
+++ b/library/core/src/intrinsics/mir.rs
@@ -12,7 +12,8 @@
 //!
 //! Typical usage will look like this:
 //!
-//! ```rust
+#![cfg_attr(bootstrap, doc = "```rust,ignore")]
+#![cfg_attr(not(bootstrap), doc = "```rust")]
 //! #![feature(core_intrinsics, custom_mir)]
 //! #![allow(internal_features)]
 //!
@@ -62,7 +63,8 @@
 //!
 //! # Examples
 //!
-//! ```rust
+#![cfg_attr(bootstrap, doc = "```rust,ignore")]
+#![cfg_attr(not(bootstrap), doc = "```rust")]
 //! #![feature(core_intrinsics, custom_mir)]
 //! #![allow(internal_features)]
 //!
@@ -317,7 +319,8 @@ define!(
     ///
     /// # Examples
     ///
-    /// ```rust
+    #[cfg_attr(bootstrap, doc = "```rust,ignore")]
+    #[cfg_attr(not(bootstrap), doc = "```rust")]
     /// #![allow(internal_features)]
     /// #![feature(custom_mir, core_intrinsics)]
     ///
@@ -361,6 +364,11 @@ define!(
     #[doc(hidden)]
     fn __internal_make_place<T>(place: T) -> *mut T
 );
+define!(
+    "mir_debuginfo",
+    #[doc(hidden)]
+    fn __debuginfo<T>(name: &'static str, s: T)
+);
 
 /// Macro for generating custom MIR.
 ///
@@ -371,6 +379,7 @@ pub macro mir {
     (
         $(type RET = $ret_ty:ty ;)?
         $(let $local_decl:ident $(: $local_decl_ty:ty)? ;)*
+        $(debug $dbg_name:ident => $dbg_data:expr ;)*
 
         {
             $($entry:tt)*
@@ -394,26 +403,32 @@ pub macro mir {
             $(
                 let $local_decl $(: $local_decl_ty)? ;
             )*
-
             ::core::intrinsics::mir::__internal_extract_let!($($entry)*);
             $(
                 ::core::intrinsics::mir::__internal_extract_let!($($block)*);
             )*
 
             {
-                // Finally, the contents of the basic blocks
-                ::core::intrinsics::mir::__internal_remove_let!({
-                    {}
-                    { $($entry)* }
-                });
+                // Now debuginfo
                 $(
+                    __debuginfo(stringify!($dbg_name), $dbg_data);
+                )*
+
+                {
+                    // Finally, the contents of the basic blocks
                     ::core::intrinsics::mir::__internal_remove_let!({
                         {}
-                        { $($block)* }
+                        { $($entry)* }
                     });
-                )*
+                    $(
+                        ::core::intrinsics::mir::__internal_remove_let!({
+                            {}
+                            { $($block)* }
+                        });
+                    )*
 
-                RET
+                    RET
+                }
             }
         }
     }}