Expand description

Structural const qualification.

See the Qualif trait for more info.

Structs

  • A constant that cannot be used as part of a pattern in a match expression.
  • Constant containing interior mutability (UnsafeCell<T>). This must be ruled out to make sure that evaluating the constant at compile-time and at any point during the run-time would produce the same result. In particular, promotion of temporaries must not change program behavior; if the promoted could be written to, that would be a problem.
  • Constant containing an ADT that implements Drop. This must be ruled out because implicit promotion would remove side-effects that occur as part of dropping that value. N.B., the implicit promotion has to reject const Drop implementations because even if side-effects are ruled out through other means, the execution of the drop could diverge.
  • Constant containing an ADT that implements non-const Drop. This must be ruled out because we cannot run Drop during compile-time.

Traits

  • A “qualif”(-ication) is a way to look for something “bad” in the MIR that would disqualify some code for promotion or prevent it from evaluating at compile time.

Functions