remove cfgs

This commit is contained in:
b-naber 2022-12-09 18:26:20 +01:00 committed by b-naber
parent 2d2bccf751
commit aefc5ec110
7 changed files with 77 additions and 208 deletions

View File

@ -2003,9 +2003,15 @@ dependencies = [
[[package]]
name = "http-auth"
<<<<<<< HEAD
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5430cacd7a1f9a02fbeb350dfc81a0e5ed42d81f3398cb0ba184017f85bdcfbc"
=======
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0b40b39d66c28829a0cf4d09f7e139ff8201f7500a5083732848ed3b4b4d850"
>>>>>>> 570ad623189 (remove cfgs)
dependencies = [
"memchr",
]
@ -6271,6 +6277,7 @@ checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608"
[[package]]
name = "windows_aarch64_msvc"
<<<<<<< HEAD
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7"
@ -6292,6 +6299,29 @@ name = "windows_x86_64_gnu"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45"
=======
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4"
[[package]]
name = "windows_i686_gnu"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7"
[[package]]
name = "windows_i686_msvc"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed"
>>>>>>> 570ad623189 (remove cfgs)
[[package]]
name = "windows_x86_64_gnullvm"
@ -6301,9 +6331,15 @@ checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463"
[[package]]
name = "windows_x86_64_msvc"
<<<<<<< HEAD
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"
=======
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5"
>>>>>>> 570ad623189 (remove cfgs)
[[package]]
name = "writeable"

View File

@ -97,7 +97,6 @@ use nll::{PoloniusOutput, ToRegionVid};
use place_ext::PlaceExt;
use places_conflict::{places_conflict, PlaceConflictBias};
use region_infer::RegionInferenceContext;
#[cfg(debug_assertions)]
use renumber::RegionCtxt;
// FIXME(eddyb) perhaps move this somewhere more centrally.
@ -488,28 +487,14 @@ pub struct BodyWithBorrowckFacts<'tcx> {
pub struct BorrowckInferCtxt<'cx, 'tcx> {
pub(crate) infcx: &'cx InferCtxt<'tcx>,
#[cfg(debug_assertions)]
pub(crate) reg_var_to_origin: RefCell<FxHashMap<ty::RegionVid, RegionCtxt>>,
}
impl<'cx, 'tcx> BorrowckInferCtxt<'cx, 'tcx> {
#[cfg(not(debug_assertions))]
pub(crate) fn new(infcx: &'cx InferCtxt<'tcx>) -> Self {
BorrowckInferCtxt { infcx }
}
#[cfg(debug_assertions)]
pub(crate) fn new(infcx: &'cx InferCtxt<'tcx>) -> Self {
BorrowckInferCtxt { infcx, reg_var_to_origin: RefCell::new(Default::default()) }
}
#[cfg(not(debug_assertions))]
pub(crate) fn next_region_var(&self, origin: RegionVariableOrigin) -> ty::Region<'tcx> {
self.infcx.next_region_var(origin)
}
#[cfg(debug_assertions)]
pub(crate) fn next_region_var(
&self,
origin: RegionVariableOrigin,
@ -533,12 +518,6 @@ impl<'cx, 'tcx> BorrowckInferCtxt<'cx, 'tcx> {
next_region
}
#[cfg(not(debug_assertions))]
pub(crate) fn next_nll_region_var(&self, origin: NllRegionVariableOrigin) -> ty::Region<'tcx> {
self.infcx.next_nll_region_var(origin)
}
#[cfg(debug_assertions)]
#[instrument(skip(self), level = "debug")]
pub(crate) fn next_nll_region_var(
&self,

View File

@ -244,7 +244,6 @@ pub enum ExtraConstraintInfo {
PlaceholderFromPredicate(Span),
}
#[cfg(debug_assertions)]
#[instrument(skip(infcx, sccs), level = "debug")]
fn sccs_info<'cx, 'tcx>(
infcx: &'cx BorrowckInferCtxt<'cx, 'tcx>,
@ -278,7 +277,7 @@ fn sccs_info<'cx, 'tcx>(
.map(|(scc_idx, region_ctxts)| {
let repr = region_ctxts
.into_iter()
.max_by(|x, y| x._preference_value().cmp(&y._preference_value()))
.max_by(|x, y| x.preference_value().cmp(&y.preference_value()))
.unwrap();
(ConstraintSccIndex::from_usize(scc_idx), repr)
@ -334,10 +333,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
let fr_static = universal_regions.fr_static;
let constraint_sccs = Rc::new(constraints.compute_sccs(&constraint_graph, fr_static));
#[cfg(debug_assertions)]
{
sccs_info(_infcx, constraint_sccs.clone());
}
sccs_info(_infcx, constraint_sccs.clone());
let mut scc_values =
RegionValues::new(elements, universal_regions.len(), &placeholder_indices);

View File

@ -8,7 +8,6 @@ use rustc_middle::mir::Constant;
use rustc_middle::mir::{Body, Location, Promoted};
use rustc_middle::ty::subst::SubstsRef;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable};
#[cfg(debug_assertions)]
use rustc_span::{Span, Symbol};
/// Replaces all free regions appearing in the MIR with fresh
@ -32,21 +31,6 @@ pub fn renumber_mir<'tcx>(
/// Replaces all regions appearing in `value` with fresh inference
/// variables.
#[cfg(not(debug_assertions))]
#[instrument(skip(infcx), level = "debug")]
pub(crate) fn renumber_regions<'tcx, T>(infcx: &BorrowckInferCtxt<'_, 'tcx>, value: T) -> T
where
T: TypeFoldable<'tcx>,
{
infcx.tcx.fold_regions(value, |_region, _depth| {
let origin = NllRegionVariableOrigin::Existential { from_forall: false };
infcx.next_nll_region_var(origin)
})
}
/// Replaces all regions appearing in `value` with fresh inference
/// variables.
#[cfg(debug_assertions)]
#[instrument(skip(infcx), level = "debug")]
pub(crate) fn renumber_regions<'tcx, T>(
infcx: &BorrowckInferCtxt<'_, 'tcx>,
@ -62,14 +46,12 @@ where
})
}
#[cfg(debug_assertions)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
pub(crate) enum BoundRegionInfo {
Name(Symbol),
Span(Span),
}
#[cfg(debug_assertions)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
pub(crate) enum RegionCtxt {
Location(Location),
@ -82,12 +64,11 @@ pub(crate) enum RegionCtxt {
Unknown,
}
#[cfg(debug_assertions)]
impl RegionCtxt {
/// Used to determine the representative of a component in the strongly connected
/// constraint graph
/// FIXME: don't use underscore here. Got a 'not used' error for some reason
pub(crate) fn _preference_value(self) -> usize {
pub(crate) fn preference_value(self) -> usize {
let _anon = Symbol::intern("anon");
match self {
@ -106,21 +87,12 @@ struct NllVisitor<'a, 'tcx> {
}
impl<'a, 'tcx> NllVisitor<'a, 'tcx> {
#[cfg(debug_assertions)]
fn renumber_regions<T>(&mut self, value: T, ctxt: RegionCtxt) -> T
where
T: TypeFoldable<'tcx>,
{
renumber_regions(self.infcx, value, ctxt)
}
#[cfg(not(debug_assertions))]
fn renumber_regions<T>(&mut self, value: T) -> T
where
T: TypeFoldable<'tcx>,
{
renumber_regions(self.infcx, value)
}
}
impl<'a, 'tcx> MutVisitor<'tcx> for NllVisitor<'a, 'tcx> {
@ -128,15 +100,6 @@ impl<'a, 'tcx> MutVisitor<'tcx> for NllVisitor<'a, 'tcx> {
self.infcx.tcx
}
#[cfg(not(debug_assertions))]
#[instrument(skip(self), level = "debug")]
fn visit_ty(&mut self, ty: &mut Ty<'tcx>, _ty_context: TyContext) {
*ty = self.renumber_regions(*ty);
debug!(?ty);
}
#[cfg(debug_assertions)]
#[instrument(skip(self), level = "debug")]
fn visit_ty(&mut self, ty: &mut Ty<'tcx>, _ty_context: TyContext) {
*ty = self.renumber_regions(*ty, RegionCtxt::TyContext(_ty_context));
@ -144,15 +107,6 @@ impl<'a, 'tcx> MutVisitor<'tcx> for NllVisitor<'a, 'tcx> {
debug!(?ty);
}
#[cfg(not(debug_assertions))]
#[instrument(skip(self), level = "debug")]
fn visit_substs(&mut self, substs: &mut SubstsRef<'tcx>, location: Location) {
*substs = self.renumber_regions(*substs);
debug!(?substs);
}
#[cfg(debug_assertions)]
#[instrument(skip(self), level = "debug")]
fn visit_substs(&mut self, substs: &mut SubstsRef<'tcx>, location: Location) {
*substs = self.renumber_regions(*substs, RegionCtxt::Location(location));
@ -160,16 +114,6 @@ impl<'a, 'tcx> MutVisitor<'tcx> for NllVisitor<'a, 'tcx> {
debug!(?substs);
}
#[cfg(not(debug_assertions))]
#[instrument(skip(self), level = "debug")]
fn visit_region(&mut self, region: &mut ty::Region<'tcx>, location: Location) {
let old_region = *region;
*region = self.renumber_regions(old_region);
debug!(?region);
}
#[cfg(debug_assertions)]
#[instrument(skip(self), level = "debug")]
fn visit_region(&mut self, region: &mut ty::Region<'tcx>, location: Location) {
let old_region = *region;
@ -178,15 +122,6 @@ impl<'a, 'tcx> MutVisitor<'tcx> for NllVisitor<'a, 'tcx> {
debug!(?region);
}
#[cfg(not(debug_assertions))]
#[instrument(skip(self), level = "debug")]
fn visit_constant(&mut self, constant: &mut Constant<'tcx>, _location: Location) {
let literal = constant.literal;
constant.literal = self.renumber_regions(literal);
debug!("constant: {:#?}", constant);
}
#[cfg(debug_assertions)]
#[instrument(skip(self), level = "debug")]
fn visit_constant(&mut self, constant: &mut Constant<'tcx>, _location: Location) {
let literal = constant.literal;

View File

@ -1335,43 +1335,27 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
}
};
let (sig, map) = tcx.replace_late_bound_regions(sig, |br| {
#[cfg(not(debug_assertions))]
{
self.infcx.next_region_var(LateBoundRegion(
use crate::renumber::{BoundRegionInfo, RegionCtxt};
use rustc_span::Symbol;
let reg_info = match br.kind {
// FIXME Probably better to use the `Span` here
ty::BoundRegionKind::BrAnon(_, Some(span)) => BoundRegionInfo::Span(span),
ty::BoundRegionKind::BrAnon(..) => {
BoundRegionInfo::Name(Symbol::intern("anon"))
}
ty::BoundRegionKind::BrNamed(_, name) => BoundRegionInfo::Name(name),
ty::BoundRegionKind::BrEnv => BoundRegionInfo::Name(Symbol::intern("env")),
};
self.infcx.next_region_var(
LateBoundRegion(
term.source_info.span,
br.kind,
LateBoundRegionConversionTime::FnCall,
))
}
#[cfg(debug_assertions)]
{
use crate::renumber::{BoundRegionInfo, RegionCtxt};
use rustc_span::Symbol;
let reg_info = match br.kind {
// FIXME Probably better to use the `Span` here
ty::BoundRegionKind::BrAnon(_, Some(span)) => {
BoundRegionInfo::Span(span)
}
ty::BoundRegionKind::BrAnon(..) => {
BoundRegionInfo::Name(Symbol::intern("anon"))
}
ty::BoundRegionKind::BrNamed(_, name) => BoundRegionInfo::Name(name),
ty::BoundRegionKind::BrEnv => {
BoundRegionInfo::Name(Symbol::intern("env"))
}
};
self.infcx.next_region_var(
LateBoundRegion(
term.source_info.span,
br.kind,
LateBoundRegionConversionTime::FnCall,
),
RegionCtxt::LateBound(reg_info),
)
}
),
RegionCtxt::LateBound(reg_info),
)
});
debug!(?sig);
// IMPORTANT: We have to prove well formed for the function signature before

View File

@ -9,7 +9,6 @@ use rustc_trait_selection::traits::query::Fallible;
use crate::constraints::OutlivesConstraint;
use crate::diagnostics::UniverseInfo;
#[cfg(debug_assertions)]
use crate::renumber::{BoundRegionInfo, RegionCtxt};
use crate::type_check::{InstantiateOpaqueType, Locations, TypeChecker};
@ -110,10 +109,6 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
) -> ty::Region<'tcx> {
let origin = NllRegionVariableOrigin::Existential { from_forall };
#[cfg(not(debug_assertions))]
let reg_var = self.type_checker.infcx.next_nll_region_var(origin);
#[cfg(debug_assertions)]
let reg_var =
self.type_checker.infcx.next_nll_region_var(origin, RegionCtxt::Existential(_name));
@ -128,23 +123,19 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
.constraints
.placeholder_region(self.type_checker.infcx, placeholder);
#[cfg(debug_assertions)]
{
let reg_info = match placeholder.name {
// FIXME Probably better to use the `Span` here
ty::BoundRegionKind::BrAnon(_, Some(span)) => BoundRegionInfo::Span(span),
ty::BoundRegionKind::BrAnon(..) => BoundRegionInfo::Name(Symbol::intern("anon")),
ty::BoundRegionKind::BrNamed(_, name) => BoundRegionInfo::Name(name),
ty::BoundRegionKind::BrEnv => BoundRegionInfo::Name(Symbol::intern("env")),
};
let reg_info = match placeholder.name {
ty::BoundRegionKind::BrAnon(_, Some(span)) => BoundRegionInfo::Span(span),
ty::BoundRegionKind::BrAnon(..) => BoundRegionInfo::Name(Symbol::intern("anon")),
ty::BoundRegionKind::BrNamed(_, name) => BoundRegionInfo::Name(name),
ty::BoundRegionKind::BrEnv => BoundRegionInfo::Name(Symbol::intern("env")),
};
let reg_var = reg
.try_get_var()
.unwrap_or_else(|| bug!("expected region {:?} to be of kind ReVar", reg));
let mut var_to_origin = self.type_checker.infcx.reg_var_to_origin.borrow_mut();
let prev = var_to_origin.insert(reg_var, RegionCtxt::Placeholder(reg_info));
assert!(matches!(prev, None));
}
let reg_var = reg
.try_get_var()
.unwrap_or_else(|| bug!("expected region {:?} to be of kind ReVar", reg));
let mut var_to_origin = self.type_checker.infcx.reg_var_to_origin.borrow_mut();
let prev = var_to_origin.insert(reg_var, RegionCtxt::Placeholder(reg_info));
assert!(matches!(prev, None));
reg
}
@ -156,15 +147,12 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
universe,
);
#[cfg(debug_assertions)]
{
let reg_var = reg
.try_get_var()
.unwrap_or_else(|| bug!("expected region {:?} to be of kind ReVar", reg));
let mut var_to_origin = self.type_checker.infcx.reg_var_to_origin.borrow_mut();
let prev = var_to_origin.insert(reg_var, RegionCtxt::Existential(None));
assert!(matches!(prev, None));
}
let reg_var = reg
.try_get_var()
.unwrap_or_else(|| bug!("expected region {:?} to be of kind ReVar", reg));
let mut var_to_origin = self.type_checker.infcx.reg_var_to_origin.borrow_mut();
let prev = var_to_origin.insert(reg_var, RegionCtxt::Existential(None));
assert!(matches!(prev, None));
reg
}

View File

@ -26,12 +26,10 @@ use rustc_middle::ty::{
self, DefIdTree, InlineConstSubsts, InlineConstSubstsParts, RegionVid, Ty, TyCtxt,
};
use rustc_middle::ty::{InternalSubsts, SubstsRef};
#[cfg(debug_assertions)]
use rustc_span::Symbol;
use std::iter;
use crate::nll::ToRegionVid;
#[cfg(debug_assertions)]
use crate::renumber::{BoundRegionInfo, RegionCtxt};
use crate::BorrowckInferCtxt;
@ -408,9 +406,6 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
assert_eq!(FIRST_GLOBAL_INDEX, self.infcx.num_region_vars());
// Create the "global" region that is always free in all contexts: 'static.
#[cfg(not(debug_assertions))]
let fr_static = self.infcx.next_nll_region_var(FR).to_region_vid();
#[cfg(debug_assertions)]
let fr_static = self
.infcx
.next_nll_region_var(FR, RegionCtxt::Free(Symbol::intern("static")))
@ -446,10 +441,6 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
|r| {
debug!(?r);
if !indices.indices.contains_key(&r) {
#[cfg(not(debug_assertions))]
let region_vid = self.infcx.next_nll_region_var(FR);
#[cfg(debug_assertions)]
let region_vid = {
let name = match r.get_name() {
Some(name) => name,
@ -489,10 +480,6 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
for_each_late_bound_region_in_item(self.infcx.tcx, self.mir_def.did, |r| {
debug!(?r);
if !indices.indices.contains_key(&r) {
#[cfg(not(debug_assertions))]
let region_vid = self.infcx.next_nll_region_var(FR);
#[cfg(debug_assertions)]
let region_vid = {
let name = match r.get_name() {
Some(name) => name,
@ -521,7 +508,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
);
let reg_vid = self.infcx.next_nll_region_var(FR, RegionCtxt::Free(Symbol::intern("c-variadic")).to_region_vid();
let region =
self.infcx.tcx.mk_re_var(self.infcx.next_nll_region_var(FR).to_region_vid());
self.infcx.tcx.mk_re_var(reg_vid);
let va_list_ty =
self.infcx.tcx.type_of(va_list_did).subst(self.infcx.tcx, &[region.into()]);
@ -531,9 +518,6 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
}
}
#[cfg(not(debug_assertions))]
let fr_fn_body = self.infcx.next_nll_region_var(FR).to_region_vid();
#[cfg(debug_assertions)]
let fr_fn_body = self
.infcx
.next_nll_region_var(FR, RegionCtxt::Free(Symbol::intern("fn_body")))
@ -766,19 +750,6 @@ trait InferCtxtExt<'tcx> {
}
impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
#[cfg(not(debug_assertions))]
fn replace_free_regions_with_nll_infer_vars<T>(
&self,
origin: NllRegionVariableOrigin,
value: T,
) -> T
where
T: TypeFoldable<'tcx>,
{
self.tcx.fold_regions(value, |_region, _depth| self.infcx.next_nll_region_var(origin))
}
#[cfg(debug_assertions)]
#[instrument(skip(self), level = "debug")]
fn replace_free_regions_with_nll_infer_vars<T>(
&self,
@ -815,19 +786,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
let (value, _map) = self.tcx.replace_late_bound_regions(value, |br| {
debug!(?br);
let liberated_region = self.tcx.mk_re_free(all_outlive_scope.to_def_id(), br.kind);
#[cfg(not(debug_assertions))]
let region_vid = self.next_nll_region_var(origin);
#[cfg(debug_assertions)]
let region_vid = {
let name = match br.kind.get_name() {
Some(name) => name,
_ => Symbol::intern("anon"),
};
self.next_nll_region_var(origin, RegionCtxt::Bound(BoundRegionInfo::Name(name)))
};
let region_vid = self.next_nll_region_var(origin, RegionCtxt::Bound(BoundRegionInfo::Name(name)));
indices.insert_late_bound_region(liberated_region, region_vid.to_region_vid());
debug!(?liberated_region, ?region_vid);
region_vid
@ -853,10 +812,6 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
for_each_late_bound_region_in_recursive_scope(self.tcx, mir_def_id, |r| {
debug!(?r);
if !indices.indices.contains_key(&r) {
#[cfg(not(debug_assertions))]
let region_vid = self.next_nll_region_var(FR);
#[cfg(debug_assertions)]
let region_vid = {
let name = match r.get_name() {
Some(name) => name,
@ -881,10 +836,6 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
for_each_late_bound_region_in_item(self.tcx, mir_def_id, |r| {
debug!(?r);
if !indices.indices.contains_key(&r) {
#[cfg(not(debug_assertions))]
let region_vid = self.next_nll_region_var(FR);
#[cfg(debug_assertions)]
let region_vid = {
let name = match r.get_name() {
Some(name) => name,