Skip to content

Commit 2c5815b

Browse files
committed
make outlives constraints from pointer comparisons less boring
1 parent 10061b3 commit 2c5815b

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

Diff for: compiler/rustc_borrowck/src/type_check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2181,7 +2181,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
21812181
ty_left,
21822182
common_ty,
21832183
location.to_locations(),
2184-
ConstraintCategory::Boring,
2184+
ConstraintCategory::CallArgument(None),
21852185
)
21862186
.unwrap_or_else(|err| {
21872187
bug!("Could not equate type variable with {:?}: {:?}", ty_left, err)
@@ -2190,7 +2190,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
21902190
ty_right,
21912191
common_ty,
21922192
location.to_locations(),
2193-
ConstraintCategory::Boring,
2193+
ConstraintCategory::CallArgument(None),
21942194
) {
21952195
span_mirbug!(
21962196
self,

Diff for: tests/ui/nll/type-check-pointer-comparisons.stderr

+15-15
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@ LL | fn compare_const<'a, 'b>(x: *const &mut &'a i32, y: *const &mut &'b i32) {
66
| |
77
| lifetime `'a` defined here
88
LL | x == y;
9-
| ^ requires that `'b` must outlive `'a`
9+
| ^^^^^^ argument requires that `'a` must outlive `'b`
1010
|
11-
= help: consider adding the following bound: `'b: 'a`
11+
= help: consider adding the following bound: `'a: 'b`
1212
= note: requirement occurs because of a mutable reference to `&i32`
1313
= note: mutable references are invariant over their type parameter
1414
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
1515

1616
error: lifetime may not live long enough
17-
--> $DIR/type-check-pointer-comparisons.rs:4:10
17+
--> $DIR/type-check-pointer-comparisons.rs:4:5
1818
|
1919
LL | fn compare_const<'a, 'b>(x: *const &mut &'a i32, y: *const &mut &'b i32) {
2020
| -- -- lifetime `'b` defined here
2121
| |
2222
| lifetime `'a` defined here
2323
LL | x == y;
24-
| ^ requires that `'a` must outlive `'b`
24+
| ^^^^^^ argument requires that `'b` must outlive `'a`
2525
|
26-
= help: consider adding the following bound: `'a: 'b`
26+
= help: consider adding the following bound: `'b: 'a`
2727
= note: requirement occurs because of a mutable reference to `&i32`
2828
= note: mutable references are invariant over their type parameter
2929
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
@@ -38,24 +38,24 @@ LL | fn compare_mut<'a, 'b>(x: *mut &'a i32, y: *mut &'b i32) {
3838
| |
3939
| lifetime `'a` defined here
4040
LL | x == y;
41-
| ^ requires that `'b` must outlive `'a`
41+
| ^^^^^^ argument requires that `'a` must outlive `'b`
4242
|
43-
= help: consider adding the following bound: `'b: 'a`
43+
= help: consider adding the following bound: `'a: 'b`
4444
= note: requirement occurs because of a mutable pointer to `&i32`
4545
= note: mutable pointers are invariant over their type parameter
4646
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
4747

4848
error: lifetime may not live long enough
49-
--> $DIR/type-check-pointer-comparisons.rs:10:10
49+
--> $DIR/type-check-pointer-comparisons.rs:10:5
5050
|
5151
LL | fn compare_mut<'a, 'b>(x: *mut &'a i32, y: *mut &'b i32) {
5252
| -- -- lifetime `'b` defined here
5353
| |
5454
| lifetime `'a` defined here
5555
LL | x == y;
56-
| ^ requires that `'a` must outlive `'b`
56+
| ^^^^^^ argument requires that `'b` must outlive `'a`
5757
|
58-
= help: consider adding the following bound: `'a: 'b`
58+
= help: consider adding the following bound: `'b: 'a`
5959
= note: requirement occurs because of a mutable pointer to `&i32`
6060
= note: mutable pointers are invariant over their type parameter
6161
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
@@ -72,24 +72,24 @@ LL | fn compare_fn_ptr<'a, 'b, 'c>(f: fn(&'c mut &'a i32), g: fn(&'c mut &'b i32
7272
| |
7373
| lifetime `'a` defined here
7474
LL | f == g;
75-
| ^ requires that `'b` must outlive `'a`
75+
| ^^^^^^ argument requires that `'a` must outlive `'b`
7676
|
77-
= help: consider adding the following bound: `'b: 'a`
77+
= help: consider adding the following bound: `'a: 'b`
7878
= note: requirement occurs because of a mutable reference to `&i32`
7979
= note: mutable references are invariant over their type parameter
8080
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
8181

8282
error: lifetime may not live long enough
83-
--> $DIR/type-check-pointer-comparisons.rs:16:10
83+
--> $DIR/type-check-pointer-comparisons.rs:16:5
8484
|
8585
LL | fn compare_fn_ptr<'a, 'b, 'c>(f: fn(&'c mut &'a i32), g: fn(&'c mut &'b i32)) {
8686
| -- -- lifetime `'b` defined here
8787
| |
8888
| lifetime `'a` defined here
8989
LL | f == g;
90-
| ^ requires that `'a` must outlive `'b`
90+
| ^^^^^^ argument requires that `'b` must outlive `'a`
9191
|
92-
= help: consider adding the following bound: `'a: 'b`
92+
= help: consider adding the following bound: `'b: 'a`
9393
= note: requirement occurs because of a mutable reference to `&i32`
9494
= note: mutable references are invariant over their type parameter
9595
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance

0 commit comments

Comments
 (0)