-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Remove implicit total orderings #107982
Remove implicit total orderings #107982
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 |
---|---|---|
|
@@ -403,19 +403,22 @@ fn try_extract_error_from_region_constraints<'tcx>( | |
mut region_var_origin: impl FnMut(RegionVid) -> RegionVariableOrigin, | ||
mut universe_of_region: impl FnMut(RegionVid) -> UniverseIndex, | ||
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> { | ||
let (sub_region, cause) = | ||
region_constraints.constraints.iter().find_map(|(constraint, cause)| { | ||
let (_, _, sub_region, cause) = region_constraints | ||
.constraints | ||
.iter() | ||
.filter_map(|(constraint, cause)| { | ||
match *constraint { | ||
Constraint::RegSubReg(sub, sup) if sup == placeholder_region && sup != sub => { | ||
Some((sub, cause.clone())) | ||
Some((1u8, None, sub, cause.clone())) | ||
} | ||
// FIXME: Should this check the universe of the var? | ||
Constraint::VarSubReg(vid, sup) if sup == placeholder_region => { | ||
Some((infcx.tcx.mk_region(ty::ReVar(vid)), cause.clone())) | ||
Some((0u8, Some(vid), infcx.tcx.mk_region(ty::ReVar(vid)), cause.clone())) | ||
} | ||
_ => None, | ||
} | ||
})?; | ||
}) | ||
.min_by_key(|(discr, vid, ..)| (*discr, *vid))?; | ||
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 doesn't |
||
|
||
debug!(?sub_region, "cause = {:#?}", cause); | ||
let error = match (error_region, *sub_region) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -238,8 +238,14 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> { | |
// later use this to expand across vids. | ||
let mut constraints = IndexVec::from_elem_n(Vec::new(), var_values.values.len()); | ||
// Tracks the changed region vids. | ||
let mut changes = Vec::new(); | ||
for constraint in self.data.constraints.keys() { | ||
let mut changes = vec![]; | ||
let mut input_constraints: Vec<_> = self.data.constraints.keys().collect(); | ||
input_constraints.sort_by_key(|c| match c { | ||
Constraint::VarSubVar(..) => 0u8, | ||
Constraint::RegSubVar(..) => 1, | ||
Constraint::VarSubReg(..) | Constraint::RegSubReg(..) => 2, | ||
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 definitely needs a comment. |
||
}); | ||
for constraint in input_constraints { | ||
match *constraint { | ||
Constraint::RegSubVar(a_region, b_vid) => { | ||
let b_data = var_values.value_mut(b_vid); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use super::ConstraintCategory; | ||
|
||
impl<'tcx> ConstraintCategory<'tcx> { | ||
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 does not need to be in a separate file. |
||
pub fn cmp_discr(&self) -> u8 { | ||
use ConstraintCategory::*; | ||
match self { | ||
Return(_) => 0, | ||
Yield => 1, | ||
UseAsConst => 2, | ||
UseAsStatic => 3, | ||
TypeAnnotation => 4, | ||
Cast => 5, | ||
ClosureBounds => 6, | ||
CallArgument(_) => 7, | ||
CopyBound => 8, | ||
SizedBound => 9, | ||
Assignment => 10, | ||
Usage => 11, | ||
OpaqueType => 12, | ||
ClosureUpvar(_) => 13, | ||
Predicate(_) => 14, | ||
Boring => 15, | ||
BoringNoLocation => 16, | ||
Internal => 17, | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mutability
is perhaps the one case where keeping the order is useful and sensible.