-
Notifications
You must be signed in to change notification settings - Fork 13.4k
use Vec for region constraints instead of BTreeMap #118824
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ use rustc_middle::ty::{ReBound, ReVar}; | |
use rustc_middle::ty::{Region, RegionVid}; | ||
use rustc_span::Span; | ||
|
||
use std::collections::BTreeMap; | ||
use std::ops::Range; | ||
use std::{cmp, fmt, mem}; | ||
|
||
|
@@ -90,7 +89,7 @@ pub type VarInfos = IndexVec<RegionVid, RegionVariableInfo>; | |
pub struct RegionConstraintData<'tcx> { | ||
/// Constraints of the form `A <= B`, where either `A` or `B` can | ||
/// be a region variable (or neither, as it happens). | ||
pub constraints: BTreeMap<Constraint<'tcx>, SubregionOrigin<'tcx>>, | ||
pub constraints: Vec<(Constraint<'tcx>, SubregionOrigin<'tcx>)>, | ||
|
||
/// Constraints of the form `R0 member of [R1, ..., Rn]`, meaning that | ||
/// `R0` must be equal to one of the regions `R1..Rn`. These occur | ||
|
@@ -273,7 +272,7 @@ pub(crate) enum UndoLog<'tcx> { | |
AddVar(RegionVid), | ||
|
||
/// We added the given `constraint`. | ||
AddConstraint(Constraint<'tcx>), | ||
AddConstraint(usize), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could be an IndexVec :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or simply remove the index from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is wrong. The index was actually needed in in leak_check code, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding a newtype index seems incompatible with sorting and deduplicating the IdexVec IMO. |
||
|
||
/// We added the given `verify`. | ||
AddVerify(usize), | ||
|
@@ -319,8 +318,9 @@ impl<'tcx> RegionConstraintStorage<'tcx> { | |
self.var_infos.pop().unwrap(); | ||
assert_eq!(self.var_infos.len(), vid.index()); | ||
} | ||
AddConstraint(ref constraint) => { | ||
self.data.constraints.remove(constraint); | ||
AddConstraint(index) => { | ||
self.data.constraints.pop().unwrap(); | ||
assert_eq!(self.data.constraints.len(), index); | ||
} | ||
AddVerify(index) => { | ||
self.data.verifys.pop(); | ||
|
@@ -443,14 +443,9 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> { | |
// cannot add constraints once regions are resolved | ||
debug!("RegionConstraintCollector: add_constraint({:?})", constraint); | ||
|
||
// never overwrite an existing (constraint, origin) - only insert one if it isn't | ||
// present in the map yet. This prevents origins from outside the snapshot being | ||
// replaced with "less informative" origins e.g., during calls to `can_eq` | ||
let undo_log = &mut self.undo_log; | ||
self.storage.data.constraints.entry(constraint).or_insert_with(|| { | ||
undo_log.push(AddConstraint(constraint)); | ||
origin | ||
}); | ||
let index = self.storage.data.constraints.len(); | ||
self.storage.data.constraints.push((constraint, origin)); | ||
self.undo_log.push(AddConstraint(index)); | ||
} | ||
|
||
fn add_verify(&mut self, verify: Verify<'tcx>) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,8 @@ error[E0308]: mismatched types | |
LL | assert_all::<_, &String>(id); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other | ||
| | ||
= note: expected reference `&String` | ||
found reference `&String` | ||
= note: expected trait `for<'a> <for<'a> fn(&'a String) -> &'a String {id} as FnMut<(&'a String,)>>` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did this change 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, it's the second commit. |
||
found trait `for<'a> <for<'a> fn(&'a String) -> &'a String {id} as FnMut<(&'a String,)>>` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.