Stop ConstraintCategory Ord impl from relying on Ty's Ord impl.

This commit is contained in:
Oli Scherer 2024-03-21 10:11:44 +00:00
parent 1cf345e10a
commit cda209bf43
5 changed files with 32 additions and 22 deletions

View File

@ -4236,6 +4236,7 @@ name = "rustc_middle"
version = "0.0.0"
dependencies = [
"bitflags 2.4.2",
"derivative",
"either",
"field-offset",
"gsgdt",

View File

@ -6,6 +6,7 @@ edition = "2021"
[dependencies]
# tidy-alphabetical-start
bitflags = "2.4.1"
derivative = "2.2.0"
either = "1.5.0"
field-offset = "0.3.5"
gsgdt = "0.1.2"

View File

@ -284,8 +284,15 @@ pub struct ClosureOutlivesRequirement<'tcx> {
/// order of the category, thereby influencing diagnostic output.
///
/// See also `rustc_const_eval::borrow_check::constraints`.
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
#[derive(TyEncodable, TyDecodable, HashStable, TypeVisitable, TypeFoldable)]
#[derive(derivative::Derivative)]
#[derivative(
PartialOrd,
Ord,
PartialOrd = "feature_allow_slow_enum",
Ord = "feature_allow_slow_enum"
)]
pub enum ConstraintCategory<'tcx> {
Return(ReturnConstraint),
Yield,
@ -295,6 +302,7 @@ pub enum ConstraintCategory<'tcx> {
Cast {
/// Whether this is an unsizing cast and if yes, this contains the target type.
/// Region variables are erased to ReErased.
#[derivative(PartialOrd = "ignore", Ord = "ignore")]
unsize_to: Option<Ty<'tcx>>,
},
@ -304,7 +312,7 @@ pub enum ConstraintCategory<'tcx> {
ClosureBounds,
/// Contains the function type if available.
CallArgument(Option<Ty<'tcx>>),
CallArgument(#[derivative(PartialOrd = "ignore", Ord = "ignore")] Option<Ty<'tcx>>),
CopyBound,
SizedBound,
Assignment,

View File

@ -53,17 +53,16 @@ LL | fn case2() {
error[E0597]: `a` does not live long enough
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:30:26
|
LL | let a = 0;
| - binding `a` declared here
LL | let cell = Cell::new(&a);
| ^^ borrowed value does not live long enough
LL | let a = 0;
| - binding `a` declared here
LL | let cell = Cell::new(&a);
| ----------^^-
| | |
| | borrowed value does not live long enough
| argument requires that `a` is borrowed for `'static`
...
LL | / foo(cell, |cell_a, cell_x| {
LL | | cell_x.set(cell_a.get()); // forces 'a: 'x, implies 'a = 'static -> borrow error
LL | | })
| |______- argument requires that `a` is borrowed for `'static`
LL | }
| - `a` dropped here while still borrowed
LL | }
| - `a` dropped here while still borrowed
error: aborting due to 2 previous errors

View File

@ -1,16 +1,17 @@
error[E0597]: `c` does not live long enough
--> $DIR/adt-nullary-enums.rs:33:41
|
LL | let c = 66;
| - binding `c` declared here
LL | / combine(
LL | | SomeEnum::SomeVariant(Cell::new(&c)),
| | ^^ borrowed value does not live long enough
LL | | SomeEnum::SomeOtherVariant::<Cell<&'static u32>>,
LL | | );
| |_____- argument requires that `c` is borrowed for `'static`
LL | }
| - `c` dropped here while still borrowed
LL | let c = 66;
| - binding `c` declared here
LL | combine(
LL | SomeEnum::SomeVariant(Cell::new(&c)),
| ----------^^-
| | |
| | borrowed value does not live long enough
| argument requires that `c` is borrowed for `'static`
...
LL | }
| - `c` dropped here while still borrowed
error[E0597]: `c` does not live long enough
--> $DIR/adt-nullary-enums.rs:41:41