1
Fork 0

improve naming

This commit is contained in:
Bastian Kauschke 2020-07-15 10:50:54 +02:00
parent 805c44d5d3
commit a909eb6b65
44 changed files with 184 additions and 160 deletions

View file

@ -1536,7 +1536,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
pub fn const_eval_resolve( pub fn const_eval_resolve(
&self, &self,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
def: ty::WithOptParam<DefId>, def: ty::WithOptConstParam<DefId>,
substs: SubstsRef<'tcx>, substs: SubstsRef<'tcx>,
promoted: Option<mir::Promoted>, promoted: Option<mir::Promoted>,
span: Option<Span>, span: Option<Span>,

View file

@ -892,7 +892,7 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
if tcx.hir().body_const_context(def_id).is_some() { if tcx.hir().body_const_context(def_id).is_some() {
tcx.ensure() tcx.ensure()
.mir_drops_elaborated_and_const_checked(ty::WithOptParam::dummy(def_id)); .mir_drops_elaborated_and_const_checked(ty::WithOptConstParam::dummy(def_id));
} }
} }
}); });

View file

@ -34,7 +34,7 @@ impl<'tcx> TyCtxt<'tcx> {
pub fn const_eval_resolve( pub fn const_eval_resolve(
self, self,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
def: ty::WithOptParam<DefId>, def: ty::WithOptConstParam<DefId>,
substs: SubstsRef<'tcx>, substs: SubstsRef<'tcx>,
promoted: Option<mir::Promoted>, promoted: Option<mir::Promoted>,
span: Option<Span>, span: Option<Span>,

View file

@ -328,17 +328,20 @@ pub struct CoverageInfo {
impl<'tcx> TyCtxt<'tcx> { impl<'tcx> TyCtxt<'tcx> {
pub fn mir_borrowck_opt_const_arg( pub fn mir_borrowck_opt_const_arg(
self, self,
def: ty::WithOptParam<LocalDefId>, def: ty::WithOptConstParam<LocalDefId>,
) -> &'tcx BorrowCheckResult<'tcx> { ) -> &'tcx BorrowCheckResult<'tcx> {
if let Some(param_did) = def.param_did { if let Some(param_did) = def.const_param_did {
self.mir_borrowck_const_arg((def.did, param_did)) self.mir_borrowck_const_arg((def.did, param_did))
} else { } else {
self.mir_borrowck(def.did) self.mir_borrowck(def.did)
} }
} }
pub fn mir_const_qualif_opt_const_arg(self, def: ty::WithOptParam<LocalDefId>) -> ConstQualifs { pub fn mir_const_qualif_opt_const_arg(
if let Some(param_did) = def.param_did { self,
def: ty::WithOptConstParam<LocalDefId>,
) -> ConstQualifs {
if let Some(param_did) = def.const_param_did {
self.mir_const_qualif_const_arg((def.did, param_did)) self.mir_const_qualif_const_arg((def.did, param_did))
} else { } else {
self.mir_const_qualif(def.did) self.mir_const_qualif(def.did)
@ -347,7 +350,7 @@ impl<'tcx> TyCtxt<'tcx> {
pub fn promoted_mir_of_opt_const_arg( pub fn promoted_mir_of_opt_const_arg(
self, self,
def: ty::WithOptParam<DefId>, def: ty::WithOptConstParam<DefId>,
) -> &'tcx IndexVec<Promoted, Body<'tcx>> { ) -> &'tcx IndexVec<Promoted, Body<'tcx>> {
if let Some((did, param_did)) = def.as_const_arg() { if let Some((did, param_did)) = def.as_const_arg() {
self.promoted_mir_of_const_arg((did, param_did)) self.promoted_mir_of_const_arg((did, param_did))

View file

@ -105,7 +105,7 @@ rustc_queries! {
/// ``` /// ```
query opt_const_param_of(key: LocalDefId) -> Option<DefId> { query opt_const_param_of(key: LocalDefId) -> Option<DefId> {
desc { |tcx| "computing the optional const parameter of `{}`", tcx.def_path_str(key.to_def_id()) } desc { |tcx| "computing the optional const parameter of `{}`", tcx.def_path_str(key.to_def_id()) }
// FIXME: consider storing this query on disk. // FIXME(#74113): consider storing this query on disk.
} }
/// Records the type of every item. /// Records the type of every item.
@ -219,7 +219,7 @@ rustc_queries! {
/// Fetch the MIR for a given `DefId` right after it's built - this includes /// Fetch the MIR for a given `DefId` right after it's built - this includes
/// unreachable code. /// unreachable code.
query mir_built(key: ty::WithOptParam<LocalDefId>) -> &'tcx Steal<mir::Body<'tcx>> { query mir_built(key: ty::WithOptConstParam<LocalDefId>) -> &'tcx Steal<mir::Body<'tcx>> {
desc { |tcx| "building MIR for `{}`", tcx.def_path_str(key.did.to_def_id()) } desc { |tcx| "building MIR for `{}`", tcx.def_path_str(key.did.to_def_id()) }
} }
@ -227,23 +227,23 @@ rustc_queries! {
/// ready for const qualification. /// ready for const qualification.
/// ///
/// See the README for the `mir` module for details. /// See the README for the `mir` module for details.
query mir_const(key: ty::WithOptParam<LocalDefId>) -> &'tcx Steal<mir::Body<'tcx>> { query mir_const(key: ty::WithOptConstParam<LocalDefId>) -> &'tcx Steal<mir::Body<'tcx>> {
desc { desc {
|tcx| "processing MIR for {}`{}`", |tcx| "processing MIR for {}`{}`",
if key.param_did.is_some() { "the const argument " } else { "" }, if key.const_param_did.is_some() { "the const argument " } else { "" },
tcx.def_path_str(key.did.to_def_id()), tcx.def_path_str(key.did.to_def_id()),
} }
no_hash no_hash
} }
query mir_drops_elaborated_and_const_checked( query mir_drops_elaborated_and_const_checked(
key: ty::WithOptParam<LocalDefId> key: ty::WithOptConstParam<LocalDefId>
) -> &'tcx Steal<mir::Body<'tcx>> { ) -> &'tcx Steal<mir::Body<'tcx>> {
no_hash no_hash
desc { |tcx| "elaborating drops for `{}`", tcx.def_path_str(key.did.to_def_id()) } desc { |tcx| "elaborating drops for `{}`", tcx.def_path_str(key.did.to_def_id()) }
} }
query mir_validated(key: ty::WithOptParam<LocalDefId>) -> query mir_validated(key: ty::WithOptConstParam<LocalDefId>) ->
( (
&'tcx Steal<mir::Body<'tcx>>, &'tcx Steal<mir::Body<'tcx>>,
&'tcx Steal<IndexVec<mir::Promoted, mir::Body<'tcx>>> &'tcx Steal<IndexVec<mir::Promoted, mir::Body<'tcx>>>
@ -251,7 +251,7 @@ rustc_queries! {
no_hash no_hash
desc { desc {
|tcx| "processing {}`{}`", |tcx| "processing {}`{}`",
if key.param_did.is_some() { "the const argument " } else { "" }, if key.const_param_did.is_some() { "the const argument " } else { "" },
tcx.def_path_str(key.did.to_def_id()), tcx.def_path_str(key.did.to_def_id()),
} }
} }

View file

@ -982,9 +982,9 @@ pub struct GlobalCtxt<'tcx> {
impl<'tcx> TyCtxt<'tcx> { impl<'tcx> TyCtxt<'tcx> {
pub fn typeck_tables_of_opt_const_arg( pub fn typeck_tables_of_opt_const_arg(
self, self,
def: ty::WithOptParam<LocalDefId>, def: ty::WithOptConstParam<LocalDefId>,
) -> &'tcx TypeckTables<'tcx> { ) -> &'tcx TypeckTables<'tcx> {
if let Some(param_did) = def.param_did { if let Some(param_did) = def.const_param_did {
self.typeck_tables_of_const_arg((def.did, param_did)) self.typeck_tables_of_const_arg((def.did, param_did))
} else { } else {
self.typeck_tables_of(def.did) self.typeck_tables_of(def.did)

View file

@ -29,7 +29,7 @@ pub enum InstanceDef<'tcx> {
/// - `fn` items /// - `fn` items
/// - closures /// - closures
/// - generators /// - generators
Item(ty::WithOptParam<DefId>), Item(ty::WithOptConstParam<DefId>),
/// An intrinsic `fn` item (with `"rust-intrinsic"` or `"platform-intrinsic"` ABI). /// An intrinsic `fn` item (with `"rust-intrinsic"` or `"platform-intrinsic"` ABI).
/// ///
@ -186,7 +186,7 @@ impl<'tcx> InstanceDef<'tcx> {
} }
#[inline] #[inline]
pub fn with_opt_param(self) -> ty::WithOptParam<DefId> { pub fn with_opt_param(self) -> ty::WithOptConstParam<DefId> {
match self { match self {
InstanceDef::Item(def) => def, InstanceDef::Item(def) => def,
InstanceDef::VtableShim(def_id) InstanceDef::VtableShim(def_id)
@ -196,7 +196,7 @@ impl<'tcx> InstanceDef<'tcx> {
| InstanceDef::Intrinsic(def_id) | InstanceDef::Intrinsic(def_id)
| InstanceDef::ClosureOnceShim { call_once: def_id } | InstanceDef::ClosureOnceShim { call_once: def_id }
| InstanceDef::DropGlue(def_id, _) | InstanceDef::DropGlue(def_id, _)
| InstanceDef::CloneShim(def_id, _) => ty::WithOptParam::dummy(def_id), | InstanceDef::CloneShim(def_id, _) => ty::WithOptConstParam::dummy(def_id),
} }
} }
@ -298,7 +298,7 @@ impl<'tcx> Instance<'tcx> {
def_id, def_id,
substs substs
); );
Instance { def: InstanceDef::Item(ty::WithOptParam::dummy(def_id)), substs } Instance { def: InstanceDef::Item(ty::WithOptConstParam::dummy(def_id)), substs }
} }
pub fn mono(tcx: TyCtxt<'tcx>, def_id: DefId) -> Instance<'tcx> { pub fn mono(tcx: TyCtxt<'tcx>, def_id: DefId) -> Instance<'tcx> {
@ -355,7 +355,7 @@ impl<'tcx> Instance<'tcx> {
pub fn resolve_const_arg( pub fn resolve_const_arg(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
def: ty::WithOptParam<DefId>, def: ty::WithOptConstParam<DefId>,
substs: SubstsRef<'tcx>, substs: SubstsRef<'tcx>,
) -> Result<Option<Instance<'tcx>>, ErrorReported> { ) -> Result<Option<Instance<'tcx>>, ErrorReported> {
let substs = tcx.erase_regions(&substs); let substs = tcx.erase_regions(&substs);

View file

@ -1099,7 +1099,7 @@ pub enum PredicateKind<'tcx> {
Subtype(PolySubtypePredicate<'tcx>), Subtype(PolySubtypePredicate<'tcx>),
/// Constant initializer must evaluate successfully. /// Constant initializer must evaluate successfully.
ConstEvaluatable(ty::WithOptParam<DefId>, SubstsRef<'tcx>), ConstEvaluatable(ty::WithOptConstParam<DefId>, SubstsRef<'tcx>),
/// Constants must be equal. The first component is the const that is expected. /// Constants must be equal. The first component is the const that is expected.
ConstEquate(&'tcx Const<'tcx>, &'tcx Const<'tcx>), ConstEquate(&'tcx Const<'tcx>, &'tcx Const<'tcx>),
@ -1601,40 +1601,42 @@ pub type PlaceholderConst = Placeholder<BoundVar>;
#[derive(Copy, Clone, Debug, TypeFoldable, Lift, RustcEncodable, RustcDecodable)] #[derive(Copy, Clone, Debug, TypeFoldable, Lift, RustcEncodable, RustcDecodable)]
#[derive(PartialEq, Eq, PartialOrd, Ord)] #[derive(PartialEq, Eq, PartialOrd, Ord)]
#[derive(Hash, HashStable)] #[derive(Hash, HashStable)]
pub struct WithOptParam<T> { pub struct WithOptConstParam<T> {
pub did: T, pub did: T,
/// The `DefId` of the corresponding generic paramter in case `did` is /// The `DefId` of the corresponding generic paramter in case `did` is
/// a const argument. /// a const argument.
/// ///
/// Note that even if `did` is a const argument, this may still be `None`. /// Note that even if `did` is a const argument, this may still be `None`.
/// All queries taking `WithOptParam` start by calling `tcx.opt_const_param_of(def.did)` /// All queries taking `WithOptConstParam` start by calling `tcx.opt_const_param_of(def.did)`
/// to potentially update `param_did` in case it `None`. /// to potentially update `param_did` in case it `None`.
pub param_did: Option<DefId>, pub const_param_did: Option<DefId>,
} }
impl<T> WithOptParam<T> { impl<T> WithOptConstParam<T> {
pub fn dummy(did: T) -> WithOptParam<T> { pub fn dummy(did: T) -> WithOptConstParam<T> {
WithOptParam { did, param_did: None } WithOptConstParam { did, const_param_did: None }
} }
} }
impl WithOptParam<LocalDefId> { impl WithOptConstParam<LocalDefId> {
pub fn to_global(self) -> WithOptParam<DefId> { pub fn to_global(self) -> WithOptConstParam<DefId> {
WithOptParam { did: self.did.to_def_id(), param_did: self.param_did } WithOptConstParam { did: self.did.to_def_id(), const_param_did: self.const_param_did }
} }
pub fn ty_def_id(self) -> DefId { pub fn ty_def_id(self) -> DefId {
if let Some(did) = self.param_did { did } else { self.did.to_def_id() } if let Some(did) = self.const_param_did { did } else { self.did.to_def_id() }
} }
} }
impl WithOptParam<DefId> { impl WithOptConstParam<DefId> {
pub fn as_local(self) -> Option<WithOptParam<LocalDefId>> { pub fn as_local(self) -> Option<WithOptConstParam<LocalDefId>> {
self.did.as_local().map(|did| WithOptParam { did, param_did: self.param_did }) self.did
.as_local()
.map(|did| WithOptConstParam { did, const_param_did: self.const_param_did })
} }
pub fn as_const_arg(self) -> Option<(LocalDefId, DefId)> { pub fn as_const_arg(self) -> Option<(LocalDefId, DefId)> {
if let Some(param_did) = self.param_did { if let Some(param_did) = self.const_param_did {
if let Some(did) = self.did.as_local() { if let Some(did) = self.did.as_local() {
return Some((did, param_did)); return Some((did, param_did));
} }
@ -1643,7 +1645,7 @@ impl WithOptParam<DefId> {
None None
} }
pub fn expect_local(self) -> WithOptParam<LocalDefId> { pub fn expect_local(self) -> WithOptConstParam<LocalDefId> {
self.as_local().unwrap() self.as_local().unwrap()
} }
@ -1652,7 +1654,7 @@ impl WithOptParam<DefId> {
} }
pub fn ty_def_id(self) -> DefId { pub fn ty_def_id(self) -> DefId {
self.param_did.unwrap_or(self.did) self.const_param_did.unwrap_or(self.did)
} }
} }

View file

@ -105,7 +105,7 @@ impl Key for DefId {
} }
} }
impl Key for ty::WithOptParam<LocalDefId> { impl Key for ty::WithOptConstParam<LocalDefId> {
type CacheSelector = DefaultCacheSelector; type CacheSelector = DefaultCacheSelector;
fn query_crate(&self) -> CrateNum { fn query_crate(&self) -> CrateNum {

View file

@ -2210,12 +2210,12 @@ impl<'tcx> Const<'tcx> {
/// Literals and const generic parameters are eagerly converted to a constant, everything else /// Literals and const generic parameters are eagerly converted to a constant, everything else
/// becomes `Unevaluated`. /// becomes `Unevaluated`.
pub fn from_anon_const(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx Self { pub fn from_anon_const(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx Self {
Self::const_arg_from_anon_const(tcx, ty::WithOptParam::dummy(def_id)) Self::from_opt_const_arg_anon_const(tcx, ty::WithOptConstParam::dummy(def_id))
} }
pub fn const_arg_from_anon_const( pub fn from_opt_const_arg_anon_const(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
def: ty::WithOptParam<LocalDefId>, def: ty::WithOptConstParam<LocalDefId>,
) -> &'tcx Self { ) -> &'tcx Self {
debug!("Const::from_anon_const(def={:?})", def); debug!("Const::from_anon_const(def={:?})", def);
@ -2433,7 +2433,7 @@ pub enum ConstKind<'tcx> {
/// Used in the HIR by using `Unevaluated` everywhere and later normalizing to one of the other /// Used in the HIR by using `Unevaluated` everywhere and later normalizing to one of the other
/// variants when the code is monomorphic enough for that. /// variants when the code is monomorphic enough for that.
Unevaluated(ty::WithOptParam<DefId>, SubstsRef<'tcx>, Option<Promoted>), Unevaluated(ty::WithOptConstParam<DefId>, SubstsRef<'tcx>, Option<Promoted>),
/// Used to hold computed value. /// Used to hold computed value.
Value(ConstValue<'tcx>), Value(ConstValue<'tcx>),

View file

@ -88,9 +88,9 @@ const DEREF_PROJECTION: &[PlaceElem<'_>; 1] = &[ProjectionElem::Deref];
pub fn provide(providers: &mut Providers) { pub fn provide(providers: &mut Providers) {
*providers = Providers { *providers = Providers {
mir_borrowck: |tcx, did| mir_borrowck(tcx, ty::WithOptParam::dummy(did)), mir_borrowck: |tcx, did| mir_borrowck(tcx, ty::WithOptConstParam::dummy(did)),
mir_borrowck_const_arg: |tcx, (did, param_did)| { mir_borrowck_const_arg: |tcx, (did, param_did)| {
mir_borrowck(tcx, ty::WithOptParam { did, param_did: Some(param_did) }) mir_borrowck(tcx, ty::WithOptConstParam { did, const_param_did: Some(param_did) })
}, },
..*providers ..*providers
}; };
@ -98,9 +98,9 @@ pub fn provide(providers: &mut Providers) {
fn mir_borrowck<'tcx>( fn mir_borrowck<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
def: ty::WithOptParam<LocalDefId>, def: ty::WithOptConstParam<LocalDefId>,
) -> &'tcx BorrowCheckResult<'tcx> { ) -> &'tcx BorrowCheckResult<'tcx> {
if def.param_did.is_none() { if def.const_param_did.is_none() {
if let Some(param_did) = tcx.opt_const_param_of(def.did) { if let Some(param_did) = tcx.opt_const_param_of(def.did) {
return tcx.mir_borrowck_const_arg((def.did, param_did)); return tcx.mir_borrowck_const_arg((def.did, param_did));
} }
@ -123,7 +123,7 @@ fn do_mir_borrowck<'a, 'tcx>(
infcx: &InferCtxt<'a, 'tcx>, infcx: &InferCtxt<'a, 'tcx>,
input_body: &Body<'tcx>, input_body: &Body<'tcx>,
input_promoted: &IndexVec<Promoted, Body<'tcx>>, input_promoted: &IndexVec<Promoted, Body<'tcx>>,
def: ty::WithOptParam<LocalDefId>, def: ty::WithOptConstParam<LocalDefId>,
) -> BorrowCheckResult<'tcx> { ) -> BorrowCheckResult<'tcx> {
debug!("do_mir_borrowck(def = {:?})", def); debug!("do_mir_borrowck(def = {:?})", def);

View file

@ -59,7 +59,7 @@ crate struct NllOutput<'tcx> {
/// `compute_regions`. /// `compute_regions`.
pub(in crate::borrow_check) fn replace_regions_in_mir<'cx, 'tcx>( pub(in crate::borrow_check) fn replace_regions_in_mir<'cx, 'tcx>(
infcx: &InferCtxt<'cx, 'tcx>, infcx: &InferCtxt<'cx, 'tcx>,
def: ty::WithOptParam<LocalDefId>, def: ty::WithOptConstParam<LocalDefId>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
body: &mut Body<'tcx>, body: &mut Body<'tcx>,
promoted: &mut IndexVec<Promoted, Body<'tcx>>, promoted: &mut IndexVec<Promoted, Body<'tcx>>,

View file

@ -227,7 +227,7 @@ impl<'tcx> UniversalRegions<'tcx> {
/// known between those regions. /// known between those regions.
pub fn new( pub fn new(
infcx: &InferCtxt<'_, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
mir_def: ty::WithOptParam<LocalDefId>, mir_def: ty::WithOptConstParam<LocalDefId>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
) -> Self { ) -> Self {
let tcx = infcx.tcx; let tcx = infcx.tcx;
@ -388,7 +388,7 @@ impl<'tcx> UniversalRegions<'tcx> {
struct UniversalRegionsBuilder<'cx, 'tcx> { struct UniversalRegionsBuilder<'cx, 'tcx> {
infcx: &'cx InferCtxt<'cx, 'tcx>, infcx: &'cx InferCtxt<'cx, 'tcx>,
mir_def: ty::WithOptParam<LocalDefId>, mir_def: ty::WithOptConstParam<LocalDefId>,
mir_hir_id: HirId, mir_hir_id: HirId,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
} }

View file

@ -491,10 +491,13 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
pub(crate) fn provide(providers: &mut Providers) { pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers { *providers = Providers {
unsafety_check_result: |tcx, def_id| { unsafety_check_result: |tcx, def_id| {
unsafety_check_result(tcx, ty::WithOptParam::dummy(def_id)) unsafety_check_result(tcx, ty::WithOptConstParam::dummy(def_id))
}, },
unsafety_check_result_const_arg: |tcx, (did, param_did)| { unsafety_check_result_const_arg: |tcx, (did, param_did)| {
unsafety_check_result(tcx, ty::WithOptParam { did, param_did: Some(param_did) }) unsafety_check_result(
tcx,
ty::WithOptConstParam { did, const_param_did: Some(param_did) },
)
}, },
unsafe_derive_on_repr_packed, unsafe_derive_on_repr_packed,
..*providers ..*providers
@ -546,9 +549,9 @@ fn check_unused_unsafe(
fn unsafety_check_result<'tcx>( fn unsafety_check_result<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
def: ty::WithOptParam<LocalDefId>, def: ty::WithOptConstParam<LocalDefId>,
) -> &'tcx UnsafetyCheckResult { ) -> &'tcx UnsafetyCheckResult {
if def.param_did.is_none() { if def.const_param_did.is_none() {
if let Some(param_did) = tcx.opt_const_param_of(def.did) { if let Some(param_did) = tcx.opt_const_param_of(def.did) {
return tcx.unsafety_check_result_const_arg((def.did, param_did)); return tcx.unsafety_check_result_const_arg((def.did, param_did));
} }

View file

@ -49,10 +49,10 @@ pub(crate) fn provide(providers: &mut Providers) {
mir_keys, mir_keys,
mir_const, mir_const,
mir_const_qualif: |tcx, did| { mir_const_qualif: |tcx, did| {
mir_const_qualif(tcx, ty::WithOptParam::dummy(did.expect_local())) mir_const_qualif(tcx, ty::WithOptConstParam::dummy(did.expect_local()))
}, },
mir_const_qualif_const_arg: |tcx, (did, param_did)| { mir_const_qualif_const_arg: |tcx, (did, param_did)| {
mir_const_qualif(tcx, ty::WithOptParam { did, param_did: Some(param_did) }) mir_const_qualif(tcx, ty::WithOptConstParam { did, const_param_did: Some(param_did) })
}, },
mir_validated, mir_validated,
mir_drops_elaborated_and_const_checked, mir_drops_elaborated_and_const_checked,
@ -60,10 +60,10 @@ pub(crate) fn provide(providers: &mut Providers) {
optimized_mir_of_const_arg, optimized_mir_of_const_arg,
is_mir_available, is_mir_available,
promoted_mir: |tcx, def_id| { promoted_mir: |tcx, def_id| {
promoted_mir(tcx, ty::WithOptParam::dummy(def_id.expect_local())) promoted_mir(tcx, ty::WithOptConstParam::dummy(def_id.expect_local()))
}, },
promoted_mir_of_const_arg: |tcx, (did, param_did)| { promoted_mir_of_const_arg: |tcx, (did, param_did)| {
promoted_mir(tcx, ty::WithOptParam { did, param_did: Some(param_did) }) promoted_mir(tcx, ty::WithOptConstParam { did, const_param_did: Some(param_did) })
}, },
..*providers ..*providers
}; };
@ -127,10 +127,13 @@ pub struct MirSource<'tcx> {
impl<'tcx> MirSource<'tcx> { impl<'tcx> MirSource<'tcx> {
pub fn item(def_id: DefId) -> Self { pub fn item(def_id: DefId) -> Self {
MirSource { instance: InstanceDef::Item(ty::WithOptParam::dummy(def_id)), promoted: None } MirSource {
instance: InstanceDef::Item(ty::WithOptConstParam::dummy(def_id)),
promoted: None,
}
} }
pub fn with_opt_param(self) -> ty::WithOptParam<DefId> { pub fn with_opt_param(self) -> ty::WithOptConstParam<DefId> {
self.instance.with_opt_param() self.instance.with_opt_param()
} }
@ -217,8 +220,8 @@ pub fn run_passes(
} }
} }
fn mir_const_qualif(tcx: TyCtxt<'_>, def: ty::WithOptParam<LocalDefId>) -> ConstQualifs { fn mir_const_qualif(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> ConstQualifs {
if def.param_did.is_none() { if def.const_param_did.is_none() {
if let Some(param_did) = tcx.opt_const_param_of(def.did) { if let Some(param_did) = tcx.opt_const_param_of(def.did) {
return tcx.mir_const_qualif_const_arg((def.did, param_did)); return tcx.mir_const_qualif_const_arg((def.did, param_did));
} }
@ -261,16 +264,16 @@ fn mir_const_qualif(tcx: TyCtxt<'_>, def: ty::WithOptParam<LocalDefId>) -> Const
/// Make MIR ready for const evaluation. This is run on all MIR, not just on consts! /// Make MIR ready for const evaluation. This is run on all MIR, not just on consts!
fn mir_const<'tcx>( fn mir_const<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
def: ty::WithOptParam<LocalDefId>, def: ty::WithOptConstParam<LocalDefId>,
) -> &'tcx Steal<Body<'tcx>> { ) -> &'tcx Steal<Body<'tcx>> {
if def.param_did.is_none() { if def.const_param_did.is_none() {
if let param_did @ Some(_) = tcx.opt_const_param_of(def.did) { if let const_param_did @ Some(_) = tcx.opt_const_param_of(def.did) {
return tcx.mir_const(ty::WithOptParam { param_did, ..def }); return tcx.mir_const(ty::WithOptConstParam { const_param_did, ..def });
} }
} }
// Unsafety check uses the raw mir, so make sure it is run. // Unsafety check uses the raw mir, so make sure it is run.
if let Some(param_did) = def.param_did { if let Some(param_did) = def.const_param_did {
tcx.ensure().unsafety_check_result_const_arg((def.did, param_did)); tcx.ensure().unsafety_check_result_const_arg((def.did, param_did));
} else { } else {
tcx.ensure().unsafety_check_result(def.did); tcx.ensure().unsafety_check_result(def.did);
@ -307,11 +310,11 @@ fn mir_const<'tcx>(
fn mir_validated( fn mir_validated(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
def: ty::WithOptParam<LocalDefId>, def: ty::WithOptConstParam<LocalDefId>,
) -> (&'tcx Steal<Body<'tcx>>, &'tcx Steal<IndexVec<Promoted, Body<'tcx>>>) { ) -> (&'tcx Steal<Body<'tcx>>, &'tcx Steal<IndexVec<Promoted, Body<'tcx>>>) {
if def.param_did.is_none() { if def.const_param_did.is_none() {
if let param_did @ Some(_) = tcx.opt_const_param_of(def.did) { if let const_param_did @ Some(_) = tcx.opt_const_param_of(def.did) {
return tcx.mir_validated(ty::WithOptParam { param_did, ..def }); return tcx.mir_validated(ty::WithOptConstParam { const_param_did, ..def });
} }
} }
@ -352,18 +355,20 @@ fn mir_validated(
fn mir_drops_elaborated_and_const_checked<'tcx>( fn mir_drops_elaborated_and_const_checked<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
def: ty::WithOptParam<LocalDefId>, def: ty::WithOptConstParam<LocalDefId>,
) -> &'tcx Steal<Body<'tcx>> { ) -> &'tcx Steal<Body<'tcx>> {
if def.param_did.is_none() { if def.const_param_did.is_none() {
if let param_did @ Some(_) = tcx.opt_const_param_of(def.did) { if let const_param_did @ Some(_) = tcx.opt_const_param_of(def.did) {
return tcx return tcx.mir_drops_elaborated_and_const_checked(ty::WithOptConstParam {
.mir_drops_elaborated_and_const_checked(ty::WithOptParam { param_did, ..def }); const_param_did,
..def
});
} }
} }
// (Mir-)Borrowck uses `mir_validated`, so we have to force it to // (Mir-)Borrowck uses `mir_validated`, so we have to force it to
// execute before we can steal. // execute before we can steal.
if let Some(param_did) = def.param_did { if let Some(param_did) = def.const_param_did {
tcx.ensure().mir_borrowck_const_arg((def.did, param_did)); tcx.ensure().mir_borrowck_const_arg((def.did, param_did));
} else { } else {
tcx.ensure().mir_borrowck(def.did); tcx.ensure().mir_borrowck(def.did);
@ -409,7 +414,7 @@ fn run_post_borrowck_cleanup_passes<'tcx>(
run_passes( run_passes(
tcx, tcx,
body, body,
InstanceDef::Item(ty::WithOptParam::dummy(def_id.to_def_id())), InstanceDef::Item(ty::WithOptConstParam::dummy(def_id.to_def_id())),
promoted, promoted,
MirPhase::DropElab, MirPhase::DropElab,
&[post_borrowck_cleanup], &[post_borrowck_cleanup],
@ -473,7 +478,7 @@ fn run_optimization_passes<'tcx>(
run_passes( run_passes(
tcx, tcx,
body, body,
InstanceDef::Item(ty::WithOptParam::dummy(def_id.to_def_id())), InstanceDef::Item(ty::WithOptConstParam::dummy(def_id.to_def_id())),
promoted, promoted,
MirPhase::Optimized, MirPhase::Optimized,
&[ &[
@ -488,7 +493,7 @@ fn optimized_mir<'tcx>(tcx: TyCtxt<'tcx>, did: DefId) -> &'tcx Body<'tcx> {
if let Some(param_did) = tcx.opt_const_param_of(did) { if let Some(param_did) = tcx.opt_const_param_of(did) {
tcx.optimized_mir_of_const_arg((did, param_did)) tcx.optimized_mir_of_const_arg((did, param_did))
} else { } else {
tcx.arena.alloc(inner_optimized_mir(tcx, ty::WithOptParam::dummy(did))) tcx.arena.alloc(inner_optimized_mir(tcx, ty::WithOptConstParam::dummy(did)))
} }
} }
@ -496,10 +501,13 @@ fn optimized_mir_of_const_arg<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
(did, param_did): (LocalDefId, DefId), (did, param_did): (LocalDefId, DefId),
) -> &'tcx Body<'tcx> { ) -> &'tcx Body<'tcx> {
tcx.arena.alloc(inner_optimized_mir(tcx, ty::WithOptParam { did, param_did: Some(param_did) })) tcx.arena.alloc(inner_optimized_mir(
tcx,
ty::WithOptConstParam { did, const_param_did: Some(param_did) },
))
} }
fn inner_optimized_mir(tcx: TyCtxt<'_>, def: ty::WithOptParam<LocalDefId>) -> Body<'_> { fn inner_optimized_mir(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_> {
if tcx.is_constructor(def.did.to_def_id()) { if tcx.is_constructor(def.did.to_def_id()) {
// There's no reason to run all of the MIR passes on constructors when // There's no reason to run all of the MIR passes on constructors when
// we can just output the MIR we want directly. This also saves const // we can just output the MIR we want directly. This also saves const
@ -518,9 +526,9 @@ fn inner_optimized_mir(tcx: TyCtxt<'_>, def: ty::WithOptParam<LocalDefId>) -> Bo
fn promoted_mir<'tcx>( fn promoted_mir<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
def: ty::WithOptParam<LocalDefId>, def: ty::WithOptConstParam<LocalDefId>,
) -> &'tcx IndexVec<Promoted, Body<'tcx>> { ) -> &'tcx IndexVec<Promoted, Body<'tcx>> {
if def.param_did.is_none() { if def.const_param_did.is_none() {
if let Some(param_did) = tcx.opt_const_param_of(def.did) { if let Some(param_did) = tcx.opt_const_param_of(def.did) {
return tcx.promoted_mir_of_const_arg((def.did, param_did)); return tcx.promoted_mir_of_const_arg((def.did, param_did));
} }
@ -530,7 +538,7 @@ fn promoted_mir<'tcx>(
return tcx.arena.alloc(IndexVec::new()); return tcx.arena.alloc(IndexVec::new());
} }
if let Some(param_did) = def.param_did { if let Some(param_did) = def.const_param_did {
tcx.ensure().mir_borrowck_const_arg((def.did, param_did)); tcx.ensure().mir_borrowck_const_arg((def.did, param_did));
} else { } else {
tcx.ensure().mir_borrowck(def.did); tcx.ensure().mir_borrowck(def.did);

View file

@ -936,7 +936,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
fn promote_candidate( fn promote_candidate(
mut self, mut self,
def: ty::WithOptParam<DefId>, def: ty::WithOptConstParam<DefId>,
candidate: Candidate, candidate: Candidate,
next_promoted_id: usize, next_promoted_id: usize,
) -> Option<Body<'tcx>> { ) -> Option<Body<'tcx>> {
@ -1099,7 +1099,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Promoter<'a, 'tcx> {
} }
pub fn promote_candidates<'tcx>( pub fn promote_candidates<'tcx>(
def: ty::WithOptParam<DefId>, def: ty::WithOptConstParam<DefId>,
body: &mut Body<'tcx>, body: &mut Body<'tcx>,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
mut temps: IndexVec<Local, TempState>, mut temps: IndexVec<Local, TempState>,

View file

@ -249,7 +249,7 @@ pub fn write_mir_pretty<'tcx>(
for (i, body) in tcx.promoted_mir(def_id).iter_enumerated() { for (i, body) in tcx.promoted_mir(def_id).iter_enumerated() {
writeln!(w)?; writeln!(w)?;
let src = MirSource { let src = MirSource {
instance: ty::InstanceDef::Item(ty::WithOptParam::dummy(def_id)), instance: ty::InstanceDef::Item(ty::WithOptConstParam::dummy(def_id)),
promoted: Some(i), promoted: Some(i),
}; };
write_mir_fn(tcx, src, body, &mut |_, _| Ok(()), w)?; write_mir_fn(tcx, src, body, &mut |_, _| Ok(()), w)?;

View file

@ -21,10 +21,10 @@ use rustc_target::spec::PanicStrategy;
use super::lints; use super::lints;
crate fn mir_built<'tcx>(tcx: TyCtxt<'tcx>, def: ty::WithOptParam<LocalDefId>) -> &'tcx ty::steal::Steal<Body<'tcx>> { crate fn mir_built<'tcx>(tcx: TyCtxt<'tcx>, def: ty::WithOptConstParam<LocalDefId>) -> &'tcx ty::steal::Steal<Body<'tcx>> {
if def.param_did.is_none() { if def.const_param_did.is_none() {
if let param_did @ Some(_) = tcx.opt_const_param_of(def.did) { if let const_param_did @ Some(_) = tcx.opt_const_param_of(def.did) {
return tcx.mir_built(ty::WithOptParam { param_did, ..def }); return tcx.mir_built(ty::WithOptConstParam { const_param_did, ..def });
} }
} }
@ -32,7 +32,7 @@ crate fn mir_built<'tcx>(tcx: TyCtxt<'tcx>, def: ty::WithOptParam<LocalDefId>) -
} }
/// Construct the MIR for a given `DefId`. /// Construct the MIR for a given `DefId`.
fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptParam<LocalDefId>) -> Body<'_> { fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_> {
let id = tcx.hir().as_local_hir_id(def.did); let id = tcx.hir().as_local_hir_id(def.did);
// Figure out what primary body this item has. // Figure out what primary body this item has.

View file

@ -601,7 +601,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
let substs = InternalSubsts::identity_for_item(cx.tcx(), did); let substs = InternalSubsts::identity_for_item(cx.tcx(), did);
let lhs = mk_const(cx.tcx().mk_const(ty::Const { let lhs = mk_const(cx.tcx().mk_const(ty::Const {
val: ty::ConstKind::Unevaluated( val: ty::ConstKind::Unevaluated(
ty::WithOptParam::dummy(did), ty::WithOptConstParam::dummy(did),
substs, substs,
None, None,
), ),
@ -800,7 +800,11 @@ fn convert_path_expr<'a, 'tcx>(
debug!("convert_path_expr: (const) user_ty={:?}", user_ty); debug!("convert_path_expr: (const) user_ty={:?}", user_ty);
ExprKind::Literal { ExprKind::Literal {
literal: cx.tcx.mk_const(ty::Const { literal: cx.tcx.mk_const(ty::Const {
val: ty::ConstKind::Unevaluated(ty::WithOptParam::dummy(def_id), substs, None), val: ty::ConstKind::Unevaluated(
ty::WithOptConstParam::dummy(def_id),
substs,
None,
),
ty: cx.tables().node_type(expr.hir_id), ty: cx.tables().node_type(expr.hir_id),
}), }),
user_ty, user_ty,

View file

@ -52,7 +52,7 @@ crate struct Cx<'a, 'tcx> {
impl<'a, 'tcx> Cx<'a, 'tcx> { impl<'a, 'tcx> Cx<'a, 'tcx> {
crate fn new( crate fn new(
infcx: &'a InferCtxt<'a, 'tcx>, infcx: &'a InferCtxt<'a, 'tcx>,
def: ty::WithOptParam<LocalDefId>, def: ty::WithOptConstParam<LocalDefId>,
src_id: hir::HirId, src_id: hir::HirId,
) -> Cx<'a, 'tcx> { ) -> Cx<'a, 'tcx> {
let tcx = infcx.tcx; let tcx = infcx.tcx;

View file

@ -21,24 +21,26 @@ fn resolve_instance<'tcx>(
} }
} }
inner_resolve_instance(tcx, param_env.and((ty::WithOptParam::dummy(did), substs))) inner_resolve_instance(tcx, param_env.and((ty::WithOptConstParam::dummy(did), substs)))
} }
fn resolve_instance_of_const_arg<'tcx>( fn resolve_instance_of_const_arg<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
key: ty::ParamEnvAnd<'tcx, (LocalDefId, DefId, SubstsRef<'tcx>)>, key: ty::ParamEnvAnd<'tcx, (LocalDefId, DefId, SubstsRef<'tcx>)>,
) -> Result<Option<Instance<'tcx>>, ErrorReported> { ) -> Result<Option<Instance<'tcx>>, ErrorReported> {
let (param_env, (did, param_did, substs)) = key.into_parts(); let (param_env, (did, const_param_did, substs)) = key.into_parts();
inner_resolve_instance( inner_resolve_instance(
tcx, tcx,
param_env param_env.and((
.and((ty::WithOptParam { did: did.to_def_id(), param_did: Some(param_did) }, substs)), ty::WithOptConstParam { did: did.to_def_id(), const_param_did: Some(const_param_did) },
substs,
)),
) )
} }
fn inner_resolve_instance<'tcx>( fn inner_resolve_instance<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
key: ty::ParamEnvAnd<'tcx, (ty::WithOptParam<DefId>, SubstsRef<'tcx>)>, key: ty::ParamEnvAnd<'tcx, (ty::WithOptConstParam<DefId>, SubstsRef<'tcx>)>,
) -> Result<Option<Instance<'tcx>>, ErrorReported> { ) -> Result<Option<Instance<'tcx>>, ErrorReported> {
let (param_env, (def, substs)) = key.into_parts(); let (param_env, (def, substs)) = key.into_parts();
@ -208,7 +210,9 @@ fn resolve_associated_item<'tcx>(
Some(ty::Instance::new(leaf_def.item.def_id, substs)) Some(ty::Instance::new(leaf_def.item.def_id, substs))
} }
traits::ImplSourceGenerator(generator_data) => Some(Instance { traits::ImplSourceGenerator(generator_data) => Some(Instance {
def: ty::InstanceDef::Item(ty::WithOptParam::dummy(generator_data.generator_def_id)), def: ty::InstanceDef::Item(ty::WithOptConstParam::dummy(
generator_data.generator_def_id,
)),
substs: generator_data.substs, substs: generator_data.substs,
}), }),
traits::ImplSourceClosure(closure_data) => { traits::ImplSourceClosure(closure_data) => {

View file

@ -886,11 +886,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
} }
} }
(GenericParamDefKind::Const, GenericArg::Const(ct)) => { (GenericParamDefKind::Const, GenericArg::Const(ct)) => {
ty::Const::const_arg_from_anon_const( ty::Const::from_opt_const_arg_anon_const(
tcx, tcx,
ty::WithOptParam { ty::WithOptConstParam {
did: tcx.hir().local_def_id(ct.value.hir_id), did: tcx.hir().local_def_id(ct.value.hir_id),
param_did: Some(param.def_id), const_param_did: Some(param.def_id),
}, },
) )
.into() .into()

View file

@ -3560,11 +3560,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ast_c: &hir::AnonConst, ast_c: &hir::AnonConst,
param_def_id: DefId, param_def_id: DefId,
) -> &'tcx ty::Const<'tcx> { ) -> &'tcx ty::Const<'tcx> {
let const_def = ty::WithOptParam { let const_def = ty::WithOptConstParam {
did: self.tcx.hir().local_def_id(ast_c.hir_id), did: self.tcx.hir().local_def_id(ast_c.hir_id),
param_did: Some(param_def_id), const_param_did: Some(param_def_id),
}; };
let c = ty::Const::const_arg_from_anon_const(self.tcx, const_def); let c = ty::Const::from_opt_const_arg_anon_const(self.tcx, const_def);
self.register_wf_obligation( self.register_wf_obligation(
c.into(), c.into(),
self.tcx.hir().span(ast_c.hir_id), self.tcx.hir().span(ast_c.hir_id),

View file

@ -424,7 +424,7 @@ fn check_type_defn<'tcx, F>(
cause, cause,
fcx.param_env, fcx.param_env,
ty::PredicateKind::ConstEvaluatable( ty::PredicateKind::ConstEvaluatable(
ty::WithOptParam::dummy(discr_def_id.to_def_id()), ty::WithOptConstParam::dummy(discr_def_id.to_def_id()),
discr_substs, discr_substs,
) )
.to_predicate(fcx.tcx), .to_predicate(fcx.tcx),

View file

@ -22,7 +22,7 @@
- // + ty: &i32 - // + ty: &i32
- // + val: Value(Scalar(alloc0)) - // + val: Value(Scalar(alloc0))
+ // + ty: &[&i32; 1] + // + ty: &[&i32; 1]
+ // + val: Unevaluated(WithOptParam { did: DefId(0:6 ~ const_promotion_extern_static[317d]::BAR[0]), param_did: None }, [], Some(promoted[0])) + // + val: Unevaluated(WithOptConstParam { did: DefId(0:6 ~ const_promotion_extern_static[317d]::BAR[0]), const_param_did: None }, [], Some(promoted[0]))
// mir::Constant // mir::Constant
- // + span: $DIR/const-promotion-extern-static.rs:9:33: 9:34 - // + span: $DIR/const-promotion-extern-static.rs:9:33: 9:34
- // + literal: Const { ty: &i32, val: Value(Scalar(alloc0)) } - // + literal: Const { ty: &i32, val: Value(Scalar(alloc0)) }
@ -30,7 +30,7 @@
- _3 = [move _4]; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35 - _3 = [move _4]; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35
- _2 = &_3; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35 - _2 = &_3; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35
+ // + span: $DIR/const-promotion-extern-static.rs:9:31: 9:35 + // + span: $DIR/const-promotion-extern-static.rs:9:31: 9:35
+ // + literal: Const { ty: &[&i32; 1], val: Unevaluated(WithOptParam { did: DefId(0:6 ~ const_promotion_extern_static[317d]::BAR[0]), param_did: None }, [], Some(promoted[0])) } + // + literal: Const { ty: &[&i32; 1], val: Unevaluated(WithOptConstParam { did: DefId(0:6 ~ const_promotion_extern_static[317d]::BAR[0]), const_param_did: None }, [], Some(promoted[0])) }
+ _2 = &(*_6); // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35 + _2 = &(*_6); // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35
_1 = move _2 as &[&i32] (Pointer(Unsize)); // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35 _1 = move _2 as &[&i32] (Pointer(Unsize)); // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35
_0 = const core::slice::<impl [&i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1]; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:44 _0 = const core::slice::<impl [&i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1]; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:44

View file

@ -24,7 +24,7 @@
- // + ty: &i32 - // + ty: &i32
- // + val: Value(Scalar(alloc2)) - // + val: Value(Scalar(alloc2))
+ // + ty: &[&i32; 1] + // + ty: &[&i32; 1]
+ // + val: Unevaluated(WithOptParam { did: DefId(0:7 ~ const_promotion_extern_static[317d]::FOO[0]), param_did: None }, [], Some(promoted[0])) + // + val: Unevaluated(WithOptConstParam { did: DefId(0:7 ~ const_promotion_extern_static[317d]::FOO[0]), const_param_did: None }, [], Some(promoted[0]))
// mir::Constant // mir::Constant
- // + span: $DIR/const-promotion-extern-static.rs:13:42: 13:43 - // + span: $DIR/const-promotion-extern-static.rs:13:42: 13:43
- // + literal: Const { ty: &i32, val: Value(Scalar(alloc2)) } - // + literal: Const { ty: &i32, val: Value(Scalar(alloc2)) }
@ -32,7 +32,7 @@
- _3 = [move _4]; // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46 - _3 = [move _4]; // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46
- _2 = &_3; // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46 - _2 = &_3; // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46
+ // + span: $DIR/const-promotion-extern-static.rs:13:31: 13:46 + // + span: $DIR/const-promotion-extern-static.rs:13:31: 13:46
+ // + literal: Const { ty: &[&i32; 1], val: Unevaluated(WithOptParam { did: DefId(0:7 ~ const_promotion_extern_static[317d]::FOO[0]), param_did: None }, [], Some(promoted[0])) } + // + literal: Const { ty: &[&i32; 1], val: Unevaluated(WithOptConstParam { did: DefId(0:7 ~ const_promotion_extern_static[317d]::FOO[0]), const_param_did: None }, [], Some(promoted[0])) }
+ _2 = &(*_6); // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46 + _2 = &(*_6); // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46
_1 = move _2 as &[&i32] (Pointer(Unsize)); // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46 _1 = move _2 as &[&i32] (Pointer(Unsize)); // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46
_0 = const core::slice::<impl [&i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1]; // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:55 _0 = const core::slice::<impl [&i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1]; // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:55

View file

@ -28,10 +28,10 @@
_9 = const main::promoted[0]; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35 _9 = const main::promoted[0]; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
// ty::Const // ty::Const
// + ty: &[i32; 3] // + ty: &[i32; 3]
// + val: Unevaluated(WithOptParam { did: DefId(0:3 ~ bad_op_unsafe_oob_for_slices[317d]::main[0]), param_did: None }, [], Some(promoted[0])) // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ bad_op_unsafe_oob_for_slices[317d]::main[0]), const_param_did: None }, [], Some(promoted[0]))
// mir::Constant // mir::Constant
// + span: $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35 // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
// + literal: Const { ty: &[i32; 3], val: Unevaluated(WithOptParam { did: DefId(0:3 ~ bad_op_unsafe_oob_for_slices[317d]::main[0]), param_did: None }, [], Some(promoted[0])) } // + literal: Const { ty: &[i32; 3], val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ bad_op_unsafe_oob_for_slices[317d]::main[0]), const_param_did: None }, [], Some(promoted[0])) }
_3 = _9; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35 _3 = _9; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
_2 = &raw const (*_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35 _2 = &raw const (*_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
_1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35 _1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35

View file

@ -28,10 +28,10 @@
_9 = const main::promoted[0]; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35 _9 = const main::promoted[0]; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
// ty::Const // ty::Const
// + ty: &[i32; 3] // + ty: &[i32; 3]
// + val: Unevaluated(WithOptParam { did: DefId(0:3 ~ bad_op_unsafe_oob_for_slices[317d]::main[0]), param_did: None }, [], Some(promoted[0])) // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ bad_op_unsafe_oob_for_slices[317d]::main[0]), const_param_did: None }, [], Some(promoted[0]))
// mir::Constant // mir::Constant
// + span: $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35 // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
// + literal: Const { ty: &[i32; 3], val: Unevaluated(WithOptParam { did: DefId(0:3 ~ bad_op_unsafe_oob_for_slices[317d]::main[0]), param_did: None }, [], Some(promoted[0])) } // + literal: Const { ty: &[i32; 3], val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ bad_op_unsafe_oob_for_slices[317d]::main[0]), const_param_did: None }, [], Some(promoted[0])) }
_3 = _9; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35 _3 = _9; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
_2 = &raw const (*_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35 _2 = &raw const (*_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
_1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35 _1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35

View file

@ -19,10 +19,10 @@
_3 = const main::FOO; // scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:16 _3 = const main::FOO; // scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:16
// ty::Const // ty::Const
// + ty: &i32 // + ty: &i32
// + val: Unevaluated(WithOptParam { did: DefId(0:5 ~ const_prop_fails_gracefully[317d]::main[0]::FOO[0]), param_did: None }, [], None) // + val: Unevaluated(WithOptConstParam { did: DefId(0:5 ~ const_prop_fails_gracefully[317d]::main[0]::FOO[0]), const_param_did: None }, [], None)
// mir::Constant // mir::Constant
// + span: $DIR/const_prop_fails_gracefully.rs:7:13: 7:16 // + span: $DIR/const_prop_fails_gracefully.rs:7:13: 7:16
// + literal: Const { ty: &i32, val: Unevaluated(WithOptParam { did: DefId(0:5 ~ const_prop_fails_gracefully[317d]::main[0]::FOO[0]), param_did: None }, [], None) } // + literal: Const { ty: &i32, val: Unevaluated(WithOptConstParam { did: DefId(0:5 ~ const_prop_fails_gracefully[317d]::main[0]::FOO[0]), const_param_did: None }, [], None) }
_2 = &raw const (*_3); // scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:16 _2 = &raw const (*_3); // scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:16
_1 = move _2 as usize (Misc); // scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:39 _1 = move _2 as usize (Misc); // scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:39
StorageDead(_2); // scope 0 at $DIR/const_prop_fails_gracefully.rs:7:38: 7:39 StorageDead(_2); // scope 0 at $DIR/const_prop_fails_gracefully.rs:7:38: 7:39

View file

@ -12,11 +12,11 @@
+ _1 = const false; // scope 0 at $DIR/control-flow-simplification.rs:12:8: 12:21 + _1 = const false; // scope 0 at $DIR/control-flow-simplification.rs:12:8: 12:21
// ty::Const // ty::Const
// + ty: bool // + ty: bool
- // + val: Unevaluated(WithOptParam { did: DefId(0:4 ~ control_flow_simplification[317d]::NeedsDrop[0]::NEEDS[0]), param_did: None }, [bool], None) - // + val: Unevaluated(WithOptConstParam { did: DefId(0:4 ~ control_flow_simplification[317d]::NeedsDrop[0]::NEEDS[0]), const_param_did: None }, [bool], None)
+ // + val: Value(Scalar(0x00)) + // + val: Value(Scalar(0x00))
// mir::Constant // mir::Constant
// + span: $DIR/control-flow-simplification.rs:12:8: 12:21 // + span: $DIR/control-flow-simplification.rs:12:8: 12:21
- // + literal: Const { ty: bool, val: Unevaluated(WithOptParam { did: DefId(0:4 ~ control_flow_simplification[317d]::NeedsDrop[0]::NEEDS[0]), param_did: None }, [bool], None) } - // + literal: Const { ty: bool, val: Unevaluated(WithOptConstParam { did: DefId(0:4 ~ control_flow_simplification[317d]::NeedsDrop[0]::NEEDS[0]), const_param_did: None }, [bool], None) }
- switchInt(_1) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/control-flow-simplification.rs:12:5: 14:6 - switchInt(_1) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/control-flow-simplification.rs:12:5: 14:6
+ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
+ switchInt(const false) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/control-flow-simplification.rs:12:5: 14:6 + switchInt(const false) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/control-flow-simplification.rs:12:5: 14:6

View file

@ -14,10 +14,10 @@
_4 = const main::promoted[0]; // scope 0 at $DIR/ref_deref.rs:5:6: 5:10 _4 = const main::promoted[0]; // scope 0 at $DIR/ref_deref.rs:5:6: 5:10
// ty::Const // ty::Const
// + ty: &i32 // + ty: &i32
// + val: Unevaluated(WithOptParam { did: DefId(0:3 ~ ref_deref[317d]::main[0]), param_did: None }, [], Some(promoted[0])) // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ ref_deref[317d]::main[0]), const_param_did: None }, [], Some(promoted[0]))
// mir::Constant // mir::Constant
// + span: $DIR/ref_deref.rs:5:6: 5:10 // + span: $DIR/ref_deref.rs:5:6: 5:10
// + literal: Const { ty: &i32, val: Unevaluated(WithOptParam { did: DefId(0:3 ~ ref_deref[317d]::main[0]), param_did: None }, [], Some(promoted[0])) } // + literal: Const { ty: &i32, val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ ref_deref[317d]::main[0]), const_param_did: None }, [], Some(promoted[0])) }
_2 = _4; // scope 0 at $DIR/ref_deref.rs:5:6: 5:10 _2 = _4; // scope 0 at $DIR/ref_deref.rs:5:6: 5:10
- _1 = (*_2); // scope 0 at $DIR/ref_deref.rs:5:5: 5:10 - _1 = (*_2); // scope 0 at $DIR/ref_deref.rs:5:5: 5:10
+ _1 = const 4_i32; // scope 0 at $DIR/ref_deref.rs:5:5: 5:10 + _1 = const 4_i32; // scope 0 at $DIR/ref_deref.rs:5:5: 5:10

View file

@ -18,13 +18,13 @@
- // + ty: i32 - // + ty: i32
- // + val: Value(Scalar(0x00000004)) - // + val: Value(Scalar(0x00000004))
+ // + ty: &i32 + // + ty: &i32
+ // + val: Unevaluated(WithOptParam { did: DefId(0:3 ~ ref_deref[317d]::main[0]), param_did: None }, [], Some(promoted[0])) + // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ ref_deref[317d]::main[0]), const_param_did: None }, [], Some(promoted[0]))
// mir::Constant // mir::Constant
- // + span: $DIR/ref_deref.rs:5:8: 5:9 - // + span: $DIR/ref_deref.rs:5:8: 5:9
- // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } - // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) }
- _2 = &_3; // scope 0 at $DIR/ref_deref.rs:5:6: 5:10 - _2 = &_3; // scope 0 at $DIR/ref_deref.rs:5:6: 5:10
+ // + span: $DIR/ref_deref.rs:5:6: 5:10 + // + span: $DIR/ref_deref.rs:5:6: 5:10
+ // + literal: Const { ty: &i32, val: Unevaluated(WithOptParam { did: DefId(0:3 ~ ref_deref[317d]::main[0]), param_did: None }, [], Some(promoted[0])) } + // + literal: Const { ty: &i32, val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ ref_deref[317d]::main[0]), const_param_did: None }, [], Some(promoted[0])) }
+ _2 = &(*_4); // scope 0 at $DIR/ref_deref.rs:5:6: 5:10 + _2 = &(*_4); // scope 0 at $DIR/ref_deref.rs:5:6: 5:10
_1 = (*_2); // scope 0 at $DIR/ref_deref.rs:5:5: 5:10 _1 = (*_2); // scope 0 at $DIR/ref_deref.rs:5:5: 5:10
- StorageDead(_3); // scope 0 at $DIR/ref_deref.rs:5:10: 5:11 - StorageDead(_3); // scope 0 at $DIR/ref_deref.rs:5:10: 5:11

View file

@ -14,10 +14,10 @@
_4 = const main::promoted[0]; // scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 _4 = const main::promoted[0]; // scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17
// ty::Const // ty::Const
// + ty: &(i32, i32) // + ty: &(i32, i32)
// + val: Unevaluated(WithOptParam { did: DefId(0:3 ~ ref_deref_project[317d]::main[0]), param_did: None }, [], Some(promoted[0])) // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ ref_deref_project[317d]::main[0]), const_param_did: None }, [], Some(promoted[0]))
// mir::Constant // mir::Constant
// + span: $DIR/ref_deref_project.rs:5:6: 5:17 // + span: $DIR/ref_deref_project.rs:5:6: 5:17
// + literal: Const { ty: &(i32, i32), val: Unevaluated(WithOptParam { did: DefId(0:3 ~ ref_deref_project[317d]::main[0]), param_did: None }, [], Some(promoted[0])) } // + literal: Const { ty: &(i32, i32), val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ ref_deref_project[317d]::main[0]), const_param_did: None }, [], Some(promoted[0])) }
_2 = &((*_4).1: i32); // scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 _2 = &((*_4).1: i32); // scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17
_1 = (*_2); // scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17 _1 = (*_2); // scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17
StorageDead(_2); // scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18 StorageDead(_2); // scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18

View file

@ -18,7 +18,7 @@
- // + ty: i32 - // + ty: i32
- // + val: Value(Scalar(0x00000004)) - // + val: Value(Scalar(0x00000004))
+ // + ty: &(i32, i32) + // + ty: &(i32, i32)
+ // + val: Unevaluated(WithOptParam { did: DefId(0:3 ~ ref_deref_project[317d]::main[0]), param_did: None }, [], Some(promoted[0])) + // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ ref_deref_project[317d]::main[0]), const_param_did: None }, [], Some(promoted[0]))
// mir::Constant // mir::Constant
- // + span: $DIR/ref_deref_project.rs:5:9: 5:10 - // + span: $DIR/ref_deref_project.rs:5:9: 5:10
- // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } - // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) }
@ -30,7 +30,7 @@
- // + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) } - // + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) }
- _2 = &(_3.1: i32); // scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 - _2 = &(_3.1: i32); // scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17
+ // + span: $DIR/ref_deref_project.rs:5:6: 5:17 + // + span: $DIR/ref_deref_project.rs:5:6: 5:17
+ // + literal: Const { ty: &(i32, i32), val: Unevaluated(WithOptParam { did: DefId(0:3 ~ ref_deref_project[317d]::main[0]), param_did: None }, [], Some(promoted[0])) } + // + literal: Const { ty: &(i32, i32), val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ ref_deref_project[317d]::main[0]), const_param_did: None }, [], Some(promoted[0])) }
+ _2 = &((*_4).1: i32); // scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 + _2 = &((*_4).1: i32); // scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17
_1 = (*_2); // scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17 _1 = (*_2); // scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17
- StorageDead(_3); // scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18 - StorageDead(_3); // scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18

View file

@ -21,10 +21,10 @@
_9 = const main::promoted[0]; // scope 0 at $DIR/slice_len.rs:5:6: 5:19 _9 = const main::promoted[0]; // scope 0 at $DIR/slice_len.rs:5:6: 5:19
// ty::Const // ty::Const
// + ty: &[u32; 3] // + ty: &[u32; 3]
// + val: Unevaluated(WithOptParam { did: DefId(0:3 ~ slice_len[317d]::main[0]), param_did: None }, [], Some(promoted[0])) // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ slice_len[317d]::main[0]), const_param_did: None }, [], Some(promoted[0]))
// mir::Constant // mir::Constant
// + span: $DIR/slice_len.rs:5:6: 5:19 // + span: $DIR/slice_len.rs:5:6: 5:19
// + literal: Const { ty: &[u32; 3], val: Unevaluated(WithOptParam { did: DefId(0:3 ~ slice_len[317d]::main[0]), param_did: None }, [], Some(promoted[0])) } // + literal: Const { ty: &[u32; 3], val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ slice_len[317d]::main[0]), const_param_did: None }, [], Some(promoted[0])) }
_4 = _9; // scope 0 at $DIR/slice_len.rs:5:6: 5:19 _4 = _9; // scope 0 at $DIR/slice_len.rs:5:6: 5:19
_3 = _4; // scope 0 at $DIR/slice_len.rs:5:6: 5:19 _3 = _4; // scope 0 at $DIR/slice_len.rs:5:6: 5:19
_2 = move _3 as &[u32] (Pointer(Unsize)); // scope 0 at $DIR/slice_len.rs:5:6: 5:19 _2 = move _3 as &[u32] (Pointer(Unsize)); // scope 0 at $DIR/slice_len.rs:5:6: 5:19

View file

@ -21,10 +21,10 @@
_9 = const main::promoted[0]; // scope 0 at $DIR/slice_len.rs:5:6: 5:19 _9 = const main::promoted[0]; // scope 0 at $DIR/slice_len.rs:5:6: 5:19
// ty::Const // ty::Const
// + ty: &[u32; 3] // + ty: &[u32; 3]
// + val: Unevaluated(WithOptParam { did: DefId(0:3 ~ slice_len[317d]::main[0]), param_did: None }, [], Some(promoted[0])) // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ slice_len[317d]::main[0]), const_param_did: None }, [], Some(promoted[0]))
// mir::Constant // mir::Constant
// + span: $DIR/slice_len.rs:5:6: 5:19 // + span: $DIR/slice_len.rs:5:6: 5:19
// + literal: Const { ty: &[u32; 3], val: Unevaluated(WithOptParam { did: DefId(0:3 ~ slice_len[317d]::main[0]), param_did: None }, [], Some(promoted[0])) } // + literal: Const { ty: &[u32; 3], val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ slice_len[317d]::main[0]), const_param_did: None }, [], Some(promoted[0])) }
_4 = _9; // scope 0 at $DIR/slice_len.rs:5:6: 5:19 _4 = _9; // scope 0 at $DIR/slice_len.rs:5:6: 5:19
_3 = _4; // scope 0 at $DIR/slice_len.rs:5:6: 5:19 _3 = _4; // scope 0 at $DIR/slice_len.rs:5:6: 5:19
_2 = move _3 as &[u32] (Pointer(Unsize)); // scope 0 at $DIR/slice_len.rs:5:6: 5:19 _2 = move _3 as &[u32] (Pointer(Unsize)); // scope 0 at $DIR/slice_len.rs:5:6: 5:19

View file

@ -38,10 +38,10 @@ fn bar() -> bool {
_10 = const bar::promoted[1]; // scope 1 at $DIR/inline-retag.rs:12:7: 12:9 _10 = const bar::promoted[1]; // scope 1 at $DIR/inline-retag.rs:12:7: 12:9
// ty::Const // ty::Const
// + ty: &i32 // + ty: &i32
// + val: Unevaluated(WithOptParam { did: DefId(0:4 ~ inline_retag[317d]::bar[0]), param_did: None }, [], Some(promoted[1])) // + val: Unevaluated(WithOptConstParam { did: DefId(0:4 ~ inline_retag[317d]::bar[0]), const_param_did: None }, [], Some(promoted[1]))
// mir::Constant // mir::Constant
// + span: $DIR/inline-retag.rs:12:7: 12:9 // + span: $DIR/inline-retag.rs:12:7: 12:9
// + literal: Const { ty: &i32, val: Unevaluated(WithOptParam { did: DefId(0:4 ~ inline_retag[317d]::bar[0]), param_did: None }, [], Some(promoted[1])) } // + literal: Const { ty: &i32, val: Unevaluated(WithOptConstParam { did: DefId(0:4 ~ inline_retag[317d]::bar[0]), const_param_did: None }, [], Some(promoted[1])) }
Retag(_10); // scope 1 at $DIR/inline-retag.rs:12:7: 12:9 Retag(_10); // scope 1 at $DIR/inline-retag.rs:12:7: 12:9
_4 = &(*_10); // scope 1 at $DIR/inline-retag.rs:12:7: 12:9 _4 = &(*_10); // scope 1 at $DIR/inline-retag.rs:12:7: 12:9
Retag(_4); // scope 1 at $DIR/inline-retag.rs:12:7: 12:9 Retag(_4); // scope 1 at $DIR/inline-retag.rs:12:7: 12:9
@ -52,10 +52,10 @@ fn bar() -> bool {
_9 = const bar::promoted[0]; // scope 1 at $DIR/inline-retag.rs:12:11: 12:14 _9 = const bar::promoted[0]; // scope 1 at $DIR/inline-retag.rs:12:11: 12:14
// ty::Const // ty::Const
// + ty: &i32 // + ty: &i32
// + val: Unevaluated(WithOptParam { did: DefId(0:4 ~ inline_retag[317d]::bar[0]), param_did: None }, [], Some(promoted[0])) // + val: Unevaluated(WithOptConstParam { did: DefId(0:4 ~ inline_retag[317d]::bar[0]), const_param_did: None }, [], Some(promoted[0]))
// mir::Constant // mir::Constant
// + span: $DIR/inline-retag.rs:12:11: 12:14 // + span: $DIR/inline-retag.rs:12:11: 12:14
// + literal: Const { ty: &i32, val: Unevaluated(WithOptParam { did: DefId(0:4 ~ inline_retag[317d]::bar[0]), param_did: None }, [], Some(promoted[0])) } // + literal: Const { ty: &i32, val: Unevaluated(WithOptConstParam { did: DefId(0:4 ~ inline_retag[317d]::bar[0]), const_param_did: None }, [], Some(promoted[0])) }
Retag(_9); // scope 1 at $DIR/inline-retag.rs:12:11: 12:14 Retag(_9); // scope 1 at $DIR/inline-retag.rs:12:11: 12:14
_7 = &(*_9); // scope 1 at $DIR/inline-retag.rs:12:11: 12:14 _7 = &(*_9); // scope 1 at $DIR/inline-retag.rs:12:11: 12:14
Retag(_7); // scope 1 at $DIR/inline-retag.rs:12:11: 12:14 Retag(_7); // scope 1 at $DIR/inline-retag.rs:12:11: 12:14

View file

@ -96,10 +96,10 @@
(_5.1: &i32) = const main::promoted[1]; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL (_5.1: &i32) = const main::promoted[1]; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
// ty::Const // ty::Const
// + ty: &i32 // + ty: &i32
// + val: Unevaluated(WithOptParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), param_did: None }, [], Some(promoted[1])) // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[1]))
// mir::Constant // mir::Constant
// + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL
// + literal: Const { ty: &i32, val: Unevaluated(WithOptParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), param_did: None }, [], Some(promoted[1])) } // + literal: Const { ty: &i32, val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[1])) }
StorageDead(_6); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL StorageDead(_6); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
StorageLive(_7); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL StorageLive(_7); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
_7 = (_5.0: &i32); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _7 = (_5.0: &i32); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
@ -140,10 +140,10 @@
_15 = const main::promoted[0] as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _15 = const main::promoted[0] as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
// ty::Const // ty::Const
// + ty: &[&str; 3] // + ty: &[&str; 3]
// + val: Unevaluated(WithOptParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), param_did: None }, [], Some(promoted[0])) // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[0]))
// mir::Constant // mir::Constant
// + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL
// + literal: Const { ty: &[&str; 3], val: Unevaluated(WithOptParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), param_did: None }, [], Some(promoted[0])) } // + literal: Const { ty: &[&str; 3], val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[0])) }
StorageLive(_18); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL StorageLive(_18); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL
StorageLive(_19); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL StorageLive(_19); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL
StorageLive(_20); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL StorageLive(_20); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL

View file

@ -153,10 +153,10 @@
_51 = const main::promoted[1]; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _51 = const main::promoted[1]; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
// ty::Const // ty::Const
// + ty: &i32 // + ty: &i32
// + val: Unevaluated(WithOptParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), param_did: None }, [], Some(promoted[1])) // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[1]))
// mir::Constant // mir::Constant
// + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL
// + literal: Const { ty: &i32, val: Unevaluated(WithOptParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), param_did: None }, [], Some(promoted[1])) } // + literal: Const { ty: &i32, val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[1])) }
_11 = _51; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _11 = _51; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
(_9.0: &i32) = move _10; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL (_9.0: &i32) = move _10; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
(_9.1: &i32) = move _11; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL (_9.1: &i32) = move _11; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
@ -220,10 +220,10 @@
_50 = const main::promoted[0]; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _50 = const main::promoted[0]; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
// ty::Const // ty::Const
// + ty: &[&str; 3] // + ty: &[&str; 3]
// + val: Unevaluated(WithOptParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), param_did: None }, [], Some(promoted[0])) // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[0]))
// mir::Constant // mir::Constant
// + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL
// + literal: Const { ty: &[&str; 3], val: Unevaluated(WithOptParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), param_did: None }, [], Some(promoted[0])) } // + literal: Const { ty: &[&str; 3], val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[0])) }
_25 = _50; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _25 = _50; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
_24 = _25; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _24 = _25; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
_23 = move _24 as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _23 = move _24 as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL

View file

@ -96,10 +96,10 @@
(_5.1: &i32) = const main::promoted[1]; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL (_5.1: &i32) = const main::promoted[1]; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
// ty::Const // ty::Const
// + ty: &i32 // + ty: &i32
// + val: Unevaluated(WithOptParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), param_did: None }, [], Some(promoted[1])) // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[1]))
// mir::Constant // mir::Constant
// + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL
// + literal: Const { ty: &i32, val: Unevaluated(WithOptParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), param_did: None }, [], Some(promoted[1])) } // + literal: Const { ty: &i32, val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[1])) }
StorageDead(_6); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL StorageDead(_6); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
StorageLive(_7); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL StorageLive(_7); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
_7 = (_5.0: &i32); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _7 = (_5.0: &i32); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
@ -140,10 +140,10 @@
_15 = const main::promoted[0] as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _15 = const main::promoted[0] as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
// ty::Const // ty::Const
// + ty: &[&str; 3] // + ty: &[&str; 3]
// + val: Unevaluated(WithOptParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), param_did: None }, [], Some(promoted[0])) // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[0]))
// mir::Constant // mir::Constant
// + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL
// + literal: Const { ty: &[&str; 3], val: Unevaluated(WithOptParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), param_did: None }, [], Some(promoted[0])) } // + literal: Const { ty: &[&str; 3], val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[0])) }
StorageLive(_18); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL StorageLive(_18); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL
StorageLive(_19); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL StorageLive(_19); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL
StorageLive(_20); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL StorageLive(_20); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL

View file

@ -153,10 +153,10 @@
_51 = const main::promoted[1]; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _51 = const main::promoted[1]; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
// ty::Const // ty::Const
// + ty: &i32 // + ty: &i32
// + val: Unevaluated(WithOptParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), param_did: None }, [], Some(promoted[1])) // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[1]))
// mir::Constant // mir::Constant
// + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL
// + literal: Const { ty: &i32, val: Unevaluated(WithOptParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), param_did: None }, [], Some(promoted[1])) } // + literal: Const { ty: &i32, val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[1])) }
_11 = _51; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _11 = _51; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
(_9.0: &i32) = move _10; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL (_9.0: &i32) = move _10; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
(_9.1: &i32) = move _11; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL (_9.1: &i32) = move _11; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
@ -220,10 +220,10 @@
_50 = const main::promoted[0]; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _50 = const main::promoted[0]; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
// ty::Const // ty::Const
// + ty: &[&str; 3] // + ty: &[&str; 3]
// + val: Unevaluated(WithOptParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), param_did: None }, [], Some(promoted[0])) // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[0]))
// mir::Constant // mir::Constant
// + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL
// + literal: Const { ty: &[&str; 3], val: Unevaluated(WithOptParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), param_did: None }, [], Some(promoted[0])) } // + literal: Const { ty: &[&str; 3], val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main[0]), const_param_did: None }, [], Some(promoted[0])) }
_25 = _50; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _25 = _50; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
_24 = _25; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _24 = _25; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL
_23 = move _24 as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL _23 = move _24 as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL

View file

@ -76,10 +76,10 @@ fn full_tested_match() -> () {
_11 = const full_tested_match::promoted[0]; // scope 0 at $DIR/match_false_edges.rs:16:14: 16:15 _11 = const full_tested_match::promoted[0]; // scope 0 at $DIR/match_false_edges.rs:16:14: 16:15
// ty::Const // ty::Const
// + ty: &std::option::Option<i32> // + ty: &std::option::Option<i32>
// + val: Unevaluated(WithOptParam { did: DefId(0:5 ~ match_false_edges[317d]::full_tested_match[0]), param_did: None }, [], Some(promoted[0])) // + val: Unevaluated(WithOptConstParam { did: DefId(0:5 ~ match_false_edges[317d]::full_tested_match[0]), const_param_did: None }, [], Some(promoted[0]))
// mir::Constant // mir::Constant
// + span: $DIR/match_false_edges.rs:16:14: 16:15 // + span: $DIR/match_false_edges.rs:16:14: 16:15
// + literal: Const { ty: &std::option::Option<i32>, val: Unevaluated(WithOptParam { did: DefId(0:5 ~ match_false_edges[317d]::full_tested_match[0]), param_did: None }, [], Some(promoted[0])) } // + literal: Const { ty: &std::option::Option<i32>, val: Unevaluated(WithOptConstParam { did: DefId(0:5 ~ match_false_edges[317d]::full_tested_match[0]), const_param_did: None }, [], Some(promoted[0])) }
_6 = &(((*_11) as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:16:14: 16:15 _6 = &(((*_11) as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:16:14: 16:15
_4 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:15:19: 15:27 _4 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:15:19: 15:27
StorageLive(_7); // scope 0 at $DIR/match_false_edges.rs:16:20: 16:27 StorageLive(_7); // scope 0 at $DIR/match_false_edges.rs:16:20: 16:27

View file

@ -184,10 +184,10 @@ fn main() -> () {
_27 = const main::promoted[0]; // scope 7 at $DIR/retag.rs:47:21: 47:23 _27 = const main::promoted[0]; // scope 7 at $DIR/retag.rs:47:21: 47:23
// ty::Const // ty::Const
// + ty: &i32 // + ty: &i32
// + val: Unevaluated(WithOptParam { did: DefId(0:13 ~ retag[317d]::main[0]), param_did: None }, [], Some(promoted[0])) // + val: Unevaluated(WithOptConstParam { did: DefId(0:13 ~ retag[317d]::main[0]), const_param_did: None }, [], Some(promoted[0]))
// mir::Constant // mir::Constant
// + span: $DIR/retag.rs:47:21: 47:23 // + span: $DIR/retag.rs:47:21: 47:23
// + literal: Const { ty: &i32, val: Unevaluated(WithOptParam { did: DefId(0:13 ~ retag[317d]::main[0]), param_did: None }, [], Some(promoted[0])) } // + literal: Const { ty: &i32, val: Unevaluated(WithOptConstParam { did: DefId(0:13 ~ retag[317d]::main[0]), const_param_did: None }, [], Some(promoted[0])) }
Retag(_27); // scope 7 at $DIR/retag.rs:47:21: 47:23 Retag(_27); // scope 7 at $DIR/retag.rs:47:21: 47:23
_23 = &(*_27); // scope 7 at $DIR/retag.rs:47:21: 47:23 _23 = &(*_27); // scope 7 at $DIR/retag.rs:47:21: 47:23
Retag(_23); // scope 7 at $DIR/retag.rs:47:21: 47:23 Retag(_23); // scope 7 at $DIR/retag.rs:47:21: 47:23

View file

@ -332,7 +332,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
let result = self let result = self
.lcx .lcx
.tcx .tcx
.const_eval_resolve(self.param_env, ty::WithOptParam::dummy(def_id), substs, None, None) .const_eval_resolve(self.param_env, ty::WithOptConstParam::dummy(def_id), substs, None, None)
.ok() .ok()
.map(|val| rustc_middle::ty::Const::from_value(self.lcx.tcx, val, ty))?; .map(|val| rustc_middle::ty::Const::from_value(self.lcx.tcx, val, ty))?;
let result = miri_to_const(&result); let result = miri_to_const(&result);