Development · Evolving reference
Deprecated
Marks an API declaration as deprecated for source use.
Sn is under heavy development. This reference includes the intended 1.0 design; features may be incomplete in the current compiler. Read the status →
Module std.diagnostics
import std.diagnostics;Public declaration contracts and authored examples. A page can document several related symbols. Implementation bodies are excluded.
Deprecated
pub attribute DeprecatedMarks an API declaration as deprecated for source use.
Message and replacement text are immutable metadata and never inject source or alter overload selection.
Example
module example.diagnostic_attributes;
import std.diagnostics as diagnostics;
[diagnostics.Deprecated("Use CurrentValue", Replacement = "CurrentValue")]
pub fn LegacyValue() -> i32 { return CurrentValue(); }
pub fn CurrentValue() -> i32 { return 7; }
[return: diagnostics.NoDiscard("Check the status before continuing")]
pub fn ComputeStatus() -> i32 { return CurrentValue(); }
fn Main() -> i32 {
let Status = ComputeStatus();
if Status != 7 { return 1; }
return 0;
}Deprecated.Message
pub Message: str?;Stores optional human-readable migration guidance.
Deprecated.Replacement
pub Replacement: str?;Stores optional replacement source spelling.
Documentation snapshot: October 24, 2026 About versions ↗