Skip to main content

Module promote_consts

Module promote_consts 

Source
Expand description

A pass that promotes borrows of constant rvalues.

The rvalues considered constant are trees of temps, each with exactly one initialization, and holding a constant value with no interior mutability. They are placed into a new MIR constant body in promoted and the borrow rvalue is replaced with a Literal::Promoted using the index into promoted of that constant MIR.

This pass assumes that every use is dominated by an initialization and can otherwise silence errors, if move analysis runs after promotion on broken MIR.

Re-exportsΒ§

use std::cell::Cell; πŸ”’
use std::assert_matches; πŸ”’
use std::cmp; πŸ”’
use std::iter; πŸ”’
use std::mem; πŸ”’
use either::Left; πŸ”’
use either::Right; πŸ”’
use rustc_const_eval::check_consts::ConstCx; πŸ”’
use rustc_const_eval::check_consts::qualifs; πŸ”’
use rustc_data_structures::fx::FxHashSet; πŸ”’
use rustc_hir as hir; πŸ”’
use rustc_hir::def::DefKind; πŸ”’
use rustc_index::IndexSlice; πŸ”’
use rustc_index::IndexVec; πŸ”’
use rustc_middle::mir; πŸ”’
use rustc_middle::mir::visit::MutVisitor; πŸ”’
use rustc_middle::mir::visit::MutatingUseContext; πŸ”’
use rustc_middle::mir::visit::PlaceContext; πŸ”’
use rustc_middle::mir::visit::Visitor; πŸ”’
use rustc_middle::ty; πŸ”’
use rustc_middle::ty::GenericArgs; πŸ”’
use rustc_middle::ty::List; πŸ”’
use rustc_middle::ty::Ty; πŸ”’
use rustc_middle::ty::TyCtxt; πŸ”’
use rustc_middle::ty::TypeVisitableExt; πŸ”’
use rustc_span::Span; πŸ”’
use rustc_span::Spanned; πŸ”’
use rustc_span::bug; πŸ”’
use rustc_span::span_bug; πŸ”’
use tracing::debug; πŸ”’
use tracing::instrument; πŸ”’
use tracing::instrument; πŸ”’
use crate::PassPolicy; πŸ”’
use rustc_middle::mir::*; πŸ”’

StructsΒ§

Candidate πŸ”’
A β€œroot candidate” for promotion, which will become the returned value in a promoted MIR, unless it’s a subset of a larger candidate.
Collector πŸ”’
PromoteTemps πŸ”’
A MirPass for promotion.
Promoter πŸ”’
Unpromotable πŸ”’
Validator πŸ”’
Checks whether locals that appear in a promotion context (Candidate) are actually promotable.

EnumsΒ§

TempState πŸ”’
State of a temporary during collection and promotion.

FunctionsΒ§

collect_temps_and_candidates πŸ”’
promote_candidates πŸ”’
validate_candidates πŸ”’