Skip to content

Rollup of 7 pull requests #108325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c13d5f1
Make sure test_type_match doesn't ICE with late-bound types
compiler-errors Feb 18, 2023
cb35a7b
add BorrowckInferCtxt
b-naber Nov 7, 2022
2f79f73
collect region contexts during mir renumbering
b-naber Nov 8, 2022
960ebaf
collect existentials and placeholders
b-naber Nov 9, 2022
e2bf960
sccs info
b-naber Nov 9, 2022
46bd77a
some conditional imports
b-naber Nov 9, 2022
2d2bccf
rebase
b-naber Nov 10, 2022
aefc5ec
remove cfgs
b-naber Dec 9, 2022
0725d0c
add some cfgs back
b-naber Feb 19, 2023
4a75995
Move state fixup into a different method.
cjgillot Feb 8, 2023
d0934f1
Merge if-let and match.
cjgillot Feb 8, 2023
f02d6c4
Remove use_ecx.
cjgillot Feb 10, 2023
c9843d6
remove cfg attributes
b-naber Feb 20, 2023
a58682d
Specify what 'this' actually is
compiler-errors Feb 21, 2023
1397a5e
compiletest: bump miow crate
klensy Feb 21, 2023
6e34e65
Fix compiletest crash when test file path does not exist
chenyukang Feb 21, 2023
58e7470
replace lazy_static with once_cell
klensy Feb 21, 2023
b483816
hir-analysis: make one diagnostic translatable
tshepang Feb 21, 2023
8252a6e
address review
b-naber Feb 21, 2023
314fe4d
Rollup merge of #104239 - b-naber:sccs-info, r=jackh726
matthiaskrgr Feb 21, 2023
8a5843f
Rollup merge of #108202 - compiler-errors:non_lifetime_binders-type-m…
matthiaskrgr Feb 21, 2023
ae01430
Rollup merge of #108295 - compiler-errors:wtf-is-this, r=cjgillot
matthiaskrgr Feb 21, 2023
c292def
Rollup merge of #108306 - klensy:compiletest-up, r=wesleywiser
matthiaskrgr Feb 21, 2023
c21b7f6
Rollup merge of #108313 - chenyukang:yukang/fix-only-modified, r=oli-obk
matthiaskrgr Feb 21, 2023
82dc2eb
Rollup merge of #108322 - cjgillot:clean-const-prop, r=oli-obk
matthiaskrgr Feb 21, 2023
d39fc21
Rollup merge of #108323 - tshepang:translatable-hir-analysis, r=compi…
matthiaskrgr Feb 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove cfgs
  • Loading branch information
b-naber committed Feb 19, 2023
commit aefc5ec11065728c99dd9636b736733e2c6544f0
36 changes: 36 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down
21 changes: 0 additions & 21 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
67 changes: 1 addition & 66 deletions compiler/rustc_borrowck/src/renumber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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>,
Expand All @@ -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),
Expand All @@ -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 {
Expand All @@ -106,70 +87,33 @@ 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> {
fn tcx(&self) -> TyCtxt<'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));

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));

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;
Expand All @@ -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;
Expand Down
52 changes: 18 additions & 34 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading