Skip to content

Commit a143be7

Browse files
RalfJunggitbot
authored and
gitbot
committed
refine mir debuginfo docs
1 parent bc66500 commit a143be7

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

core/src/intrinsics/mir.rs

+14-5
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,13 @@
252252
//!
253253
//! #### Debuginfo
254254
//!
255-
//! - A debuginfo name can be given to a local using `debug my_name => contents;`.
256-
//! For `contents`, we use the same syntax as operands, to support both places and constants.
255+
//! Debuginfo associates source code variable names (of variables that may not exist any more) with
256+
//! MIR expressions that indicate where the value of that variable is stored. The syntax to do so
257+
//! is:
258+
//! ```text
259+
//! debug source_var_name => expression;
260+
//! ```
261+
//! Both places and constants are supported in the `expression`.
257262
//!
258263
//! ```rust
259264
//! #![allow(internal_features)]
@@ -262,10 +267,14 @@
262267
//! use core::intrinsics::mir::*;
263268
//!
264269
//! #[custom_mir(dialect = "built")]
265-
//! fn debuginfo(option: Option<&i32>) {
270+
//! fn debuginfo(arg: Option<&i32>) {
266271
//! mir!(
267-
//! debug option => option;
268-
//! debug projection => *Field::<&i32>(Variant(option, 1), 0);
272+
//! // Debuginfo for a source variable `plain_local` that just duplicates `arg`.
273+
//! debug plain_local => arg;
274+
//! // Debuginfo for a source variable `projection` that can be computed by dereferencing
275+
//! // a field of `arg`.
276+
//! debug projection => *Field::<&i32>(Variant(arg, 1), 0);
277+
//! // Debuginfo for a source variable `constant` that always holds the value `5`.
269278
//! debug constant => 5_usize;
270279
//! {
271280
//! Return()

0 commit comments

Comments
 (0)