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
address review
  • Loading branch information
b-naber committed Feb 21, 2023
commit 8252a6eddfc59328fe6ac36ef09feb2844f28fa2
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ impl<'cx, 'tcx> BorrowckInferCtxt<'cx, 'tcx> {
{
let next_region = self.infcx.next_region_var(origin);
let vid = next_region
.try_get_var()
.as_var()
.unwrap_or_else(|| bug!("expected RegionKind::RegionVar on {:?}", next_region));

if cfg!(debug_assertions) {
Expand Down Expand Up @@ -534,7 +534,7 @@ impl<'cx, 'tcx> BorrowckInferCtxt<'cx, 'tcx> {
{
let next_region = self.infcx.next_nll_region_var(origin.clone());
let vid = next_region
.try_get_var()
.as_var()
.unwrap_or_else(|| bug!("expected RegionKind::RegionVar on {:?}", next_region));

if cfg!(debug_assertions) {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ fn sccs_info<'cx, 'tcx>(
}
debug!(debug_str);

let num_components = sccs.scc_data.ranges.len();
let num_components = sccs.scc_data().ranges().len();
let mut components = vec![FxHashSet::default(); num_components];

for (reg_var_idx, scc_idx) in sccs.scc_indices.iter().enumerate() {
for (reg_var_idx, scc_idx) in sccs.scc_indices().iter().enumerate() {
let reg_var = ty::RegionVid::from_usize(reg_var_idx);
let origin = var_to_origin.get(&reg_var).unwrap_or_else(|| &RegionCtxt::Unknown);
components[scc_idx.as_usize()].insert((reg_var, *origin));
Expand Down Expand Up @@ -298,8 +298,8 @@ fn sccs_info<'cx, 'tcx>(

let mut scc_node_to_edges = FxHashMap::default();
for (scc_idx, repr) in components_representatives.iter() {
let edges_range = sccs.scc_data.ranges[*scc_idx].clone();
let edges = &sccs.scc_data.all_successors[edges_range];
let edges_range = sccs.scc_data().ranges()[*scc_idx].clone();
let edges = &sccs.scc_data().all_successors()[edges_range];
let edge_representatives =
edges.iter().map(|scc_idx| components_representatives[scc_idx]).collect::<Vec<_>>();
scc_node_to_edges.insert((scc_idx, repr), edge_representatives);
Expand Down
10 changes: 4 additions & 6 deletions compiler/rustc_borrowck/src/type_check/relate_tys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,8 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
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 reg_var =
reg.as_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));
Expand All @@ -147,9 +146,8 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
universe,
);

let reg_var = reg
.try_get_var()
.unwrap_or_else(|| bug!("expected region {:?} to be of kind ReVar", reg));
let reg_var =
reg.as_var().unwrap_or_else(|| bug!("expected region {:?} to be of kind ReVar", reg));

if cfg!(debug_assertions) {
let mut var_to_origin = self.type_checker.infcx.reg_var_to_origin.borrow_mut();
Expand Down
24 changes: 20 additions & 4 deletions compiler/rustc_data_structures/src/graph/scc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,36 @@ mod tests;
pub struct Sccs<N: Idx, S: Idx> {
/// For each node, what is the SCC index of the SCC to which it
/// belongs.
pub scc_indices: IndexVec<N, S>,
scc_indices: IndexVec<N, S>,

/// Data about each SCC.
pub scc_data: SccData<S>,
scc_data: SccData<S>,
}

pub struct SccData<S: Idx> {
/// For each SCC, the range of `all_successors` where its
/// successors can be found.
pub ranges: IndexVec<S, Range<usize>>,
ranges: IndexVec<S, Range<usize>>,

/// Contains the successors for all the Sccs, concatenated. The
/// range of indices corresponding to a given SCC is found in its
/// SccData.
pub all_successors: Vec<S>,
all_successors: Vec<S>,
}

impl<N: Idx, S: Idx + Ord> Sccs<N, S> {
pub fn new(graph: &(impl DirectedGraph<Node = N> + WithNumNodes + WithSuccessors)) -> Self {
SccsConstruction::construct(graph)
}

pub fn scc_indices(&self) -> &IndexVec<N, S> {
&self.scc_indices
}

pub fn scc_data(&self) -> &SccData<S> {
&self.scc_data
}

/// Returns the number of SCCs in the graph.
pub fn num_sccs(&self) -> usize {
self.scc_data.len()
Expand Down Expand Up @@ -115,6 +123,14 @@ impl<S: Idx> SccData<S> {
self.ranges.len()
}

pub fn ranges(&self) -> &IndexVec<S, Range<usize>> {
&self.ranges
}

pub fn all_successors(&self) -> &Vec<S> {
&self.all_successors
}

/// Returns the successors of the given SCC.
fn successors(&self, scc: S) -> &[S] {
// Annoyingly, `range` does not implement `Copy`, so we have
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1752,7 +1752,7 @@ impl<'tcx> Region<'tcx> {
matches!(self.kind(), ty::ReVar(_))
}

pub fn try_get_var(self) -> Option<RegionVid> {
pub fn as_var(self) -> Option<RegionVid> {
match self.kind() {
ty::ReVar(vid) => Some(vid),
_ => None,
Expand Down