This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
library/core/src/intrinsics Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change 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)]
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()
You can’t perform that action at this time.
0 commit comments