Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0812fcc

Browse files
committedOct 21, 2023
Add example.
1 parent 23052ad commit 0812fcc

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
 

‎library/core/src/intrinsics/mir.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,24 @@
254254
//! - A debuginfo name can be given to a local using `debug my_name => contents;`.
255255
//! For `contents`, we use the same syntax as operands, to support both places and constants.
256256
//!
257+
//! ```rust
258+
//! #![allow(internal_features)]
259+
//! #![feature(core_intrinsics, custom_mir)]
260+
//!
261+
//! use core::intrinsics::mir::*;
262+
//!
263+
//! #[custom_mir(dialect = "built")]
264+
//! fn debuginfo(option: Option<&i32>) {
265+
//! mir!(
266+
//! debug option => option;
267+
//! debug projection => *Field::<&i32>(Variant(option, 1), 0);
268+
//! debug constant => 5_usize;
269+
//! {
270+
//! Return()
271+
//! }
272+
//! )
273+
//! }
274+
//! ```
257275
258276
#![unstable(
259277
feature = "custom_mir",

‎tests/mir-opt/building/custom/debuginfo.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,22 @@ fn variant_deref(opt: Option<&i32>) {
6363
)
6464
}
6565

66+
// EMIT_MIR debuginfo.constant.built.after.mir
67+
#[custom_mir(dialect = "built")]
68+
fn constant() {
69+
mir!(
70+
debug scalar => 5_usize;
71+
{
72+
Return()
73+
}
74+
)
75+
}
76+
6677
fn main() {
6778
numbered((5, 6));
6879
structured(S { x: 5. });
6980
variant(Some(5));
7081
variant_deref(Some(&5));
7182
pointee(&mut Some(5));
83+
constant();
7284
}

0 commit comments

Comments
 (0)
Please sign in to comment.