Skip to content

Commit b178a28

Browse files
committed
tests: unconstrain params in non_lifetime_binders
It seems like generics from `non_lifetime_binders` don't have any default bounds like normal generics, so all of the `?Sized` relaxations need to be further relaxed with `PointeeSized` for this test to be the equivalent of before.
1 parent 2a40d32 commit b178a28

16 files changed

+68
-47
lines changed

tests/ui/traits/non_lifetime_binders/basic.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
//@ check-pass
22
// Basic test that show's we can successfully typeck a `for<T>` where clause.
33

4+
#![feature(sized_hierarchy)]
45
#![feature(non_lifetime_binders)]
56
//~^ WARN the feature `non_lifetime_binders` is incomplete
67

7-
trait Trait {}
8+
use std::marker::PointeeSized;
89

9-
impl<T: ?Sized> Trait for T {}
10+
trait Trait: PointeeSized {}
11+
12+
impl<T: PointeeSized> Trait for T {}
1013

1114
fn foo()
1215
where

tests/ui/traits/non_lifetime_binders/basic.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/basic.rs:4:12
2+
--> $DIR/basic.rs:5:12
33
|
44
LL | #![feature(non_lifetime_binders)]
55
| ^^^^^^^^^^^^^^^^^^^^

tests/ui/traits/non_lifetime_binders/diagnostic-hir-wf-check.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
// Make sure not to construct predicates with escaping bound vars in `diagnostic_hir_wf_check`.
22
// Regression test for <https://github.com/rust-lang/rust/issues/139330>.
33

4+
#![feature(sized_hierarchy)]
45
#![feature(non_lifetime_binders)]
56
//~^ WARN the feature `non_lifetime_binders` is incomplete
67

7-
trait A<T: ?Sized> {}
8-
impl<T: ?Sized> A<T> for () {}
8+
use std::marker::PointeeSized;
9+
10+
trait A<T: PointeeSized> {}
11+
impl<T: PointeeSized> A<T> for () {}
912

1013
trait B {}
1114
struct W<T: B>(T);

tests/ui/traits/non_lifetime_binders/diagnostic-hir-wf-check.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/diagnostic-hir-wf-check.rs:4:12
2+
--> $DIR/diagnostic-hir-wf-check.rs:5:12
33
|
44
LL | #![feature(non_lifetime_binders)]
55
| ^^^^^^^^^^^^^^^^^^^^
@@ -8,54 +8,54 @@ LL | #![feature(non_lifetime_binders)]
88
= note: `#[warn(incomplete_features)]` on by default
99

1010
error[E0277]: the trait bound `(): B` is not satisfied
11-
--> $DIR/diagnostic-hir-wf-check.rs:13:12
11+
--> $DIR/diagnostic-hir-wf-check.rs:16:12
1212
|
1313
LL | fn b() -> (W<()>, impl for<C> A<C>) { (W(()), ()) }
1414
| ^^^^^ the trait `B` is not implemented for `()`
1515
|
1616
help: this trait has no implementations, consider adding one
17-
--> $DIR/diagnostic-hir-wf-check.rs:10:1
17+
--> $DIR/diagnostic-hir-wf-check.rs:13:1
1818
|
1919
LL | trait B {}
2020
| ^^^^^^^
2121
note: required by a bound in `W`
22-
--> $DIR/diagnostic-hir-wf-check.rs:11:13
22+
--> $DIR/diagnostic-hir-wf-check.rs:14:13
2323
|
2424
LL | struct W<T: B>(T);
2525
| ^ required by this bound in `W`
2626

2727
error[E0277]: the trait bound `(): B` is not satisfied
28-
--> $DIR/diagnostic-hir-wf-check.rs:13:42
28+
--> $DIR/diagnostic-hir-wf-check.rs:16:42
2929
|
3030
LL | fn b() -> (W<()>, impl for<C> A<C>) { (W(()), ()) }
3131
| - ^^ the trait `B` is not implemented for `()`
3232
| |
3333
| required by a bound introduced by this call
3434
|
3535
help: this trait has no implementations, consider adding one
36-
--> $DIR/diagnostic-hir-wf-check.rs:10:1
36+
--> $DIR/diagnostic-hir-wf-check.rs:13:1
3737
|
3838
LL | trait B {}
3939
| ^^^^^^^
4040
note: required by a bound in `W`
41-
--> $DIR/diagnostic-hir-wf-check.rs:11:13
41+
--> $DIR/diagnostic-hir-wf-check.rs:14:13
4242
|
4343
LL | struct W<T: B>(T);
4444
| ^ required by this bound in `W`
4545

4646
error[E0277]: the trait bound `(): B` is not satisfied
47-
--> $DIR/diagnostic-hir-wf-check.rs:13:40
47+
--> $DIR/diagnostic-hir-wf-check.rs:16:40
4848
|
4949
LL | fn b() -> (W<()>, impl for<C> A<C>) { (W(()), ()) }
5050
| ^^^^^ the trait `B` is not implemented for `()`
5151
|
5252
help: this trait has no implementations, consider adding one
53-
--> $DIR/diagnostic-hir-wf-check.rs:10:1
53+
--> $DIR/diagnostic-hir-wf-check.rs:13:1
5454
|
5555
LL | trait B {}
5656
| ^^^^^^^
5757
note: required by a bound in `W`
58-
--> $DIR/diagnostic-hir-wf-check.rs:11:13
58+
--> $DIR/diagnostic-hir-wf-check.rs:14:13
5959
|
6060
LL | struct W<T: B>(T);
6161
| ^ required by this bound in `W`

tests/ui/traits/non_lifetime_binders/on-rpit.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
//@ check-pass
22

3+
#![feature(sized_hierarchy)]
34
#![feature(non_lifetime_binders)]
45
//~^ WARN the feature `non_lifetime_binders` is incomplete
56

6-
trait Trait<T: ?Sized> {}
7+
use std::marker::PointeeSized;
78

8-
impl<T: ?Sized> Trait<T> for i32 {}
9+
trait Trait<T: PointeeSized> {}
10+
11+
impl<T: PointeeSized> Trait<T> for i32 {}
912

1013
fn produce() -> impl for<T> Trait<T> {
1114
16

tests/ui/traits/non_lifetime_binders/on-rpit.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/on-rpit.rs:3:12
2+
--> $DIR/on-rpit.rs:4:12
33
|
44
LL | #![feature(non_lifetime_binders)]
55
| ^^^^^^^^^^^^^^^^^^^^

tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1+
#![feature(sized_hierarchy)]
12
#![feature(non_lifetime_binders)]
23
//~^ WARN the feature `non_lifetime_binders` is incomplete
34

5+
use std::marker::PointeeSized;
6+
47
trait Foo: for<T> Bar<T> {}
58

6-
trait Bar<T: ?Sized> {
9+
trait Bar<T: PointeeSized>: PointeeSized {
710
fn method(&self) {}
811
}
912

10-
fn needs_bar(x: &(impl Bar<i32> + ?Sized)) {
13+
fn needs_bar(x: &(impl Bar<i32> + PointeeSized)) {
1114
x.method();
1215
}
1316

1417
impl Foo for () {}
1518

16-
impl<T: ?Sized> Bar<T> for () {}
19+
impl<T: PointeeSized> Bar<T> for () {}
1720

1821
fn main() {
1922
let x: &dyn Foo = &();

tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.stderr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/supertrait-dyn-compatibility.rs:1:12
2+
--> $DIR/supertrait-dyn-compatibility.rs:2:12
33
|
44
LL | #![feature(non_lifetime_binders)]
55
| ^^^^^^^^^^^^^^^^^^^^
@@ -8,14 +8,14 @@ LL | #![feature(non_lifetime_binders)]
88
= note: `#[warn(incomplete_features)]` on by default
99

1010
error[E0038]: the trait `Foo` is not dyn compatible
11-
--> $DIR/supertrait-dyn-compatibility.rs:19:23
11+
--> $DIR/supertrait-dyn-compatibility.rs:22:23
1212
|
1313
LL | let x: &dyn Foo = &();
1414
| ^^^ `Foo` is not dyn compatible
1515
|
1616
note: for a trait to be dyn compatible it needs to allow building a vtable
1717
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
18-
--> $DIR/supertrait-dyn-compatibility.rs:4:12
18+
--> $DIR/supertrait-dyn-compatibility.rs:7:12
1919
|
2020
LL | trait Foo: for<T> Bar<T> {}
2121
| --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables
@@ -25,14 +25,14 @@ LL | trait Foo: for<T> Bar<T> {}
2525
= note: required for the cast from `&()` to `&dyn Foo`
2626

2727
error[E0038]: the trait `Foo` is not dyn compatible
28-
--> $DIR/supertrait-dyn-compatibility.rs:19:12
28+
--> $DIR/supertrait-dyn-compatibility.rs:22:12
2929
|
3030
LL | let x: &dyn Foo = &();
3131
| ^^^^^^^^ `Foo` is not dyn compatible
3232
|
3333
note: for a trait to be dyn compatible it needs to allow building a vtable
3434
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
35-
--> $DIR/supertrait-dyn-compatibility.rs:4:12
35+
--> $DIR/supertrait-dyn-compatibility.rs:7:12
3636
|
3737
LL | trait Foo: for<T> Bar<T> {}
3838
| --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables
@@ -41,14 +41,14 @@ LL | trait Foo: for<T> Bar<T> {}
4141
= help: only type `()` implements `Foo`; consider using it directly instead.
4242

4343
error[E0038]: the trait `Foo` is not dyn compatible
44-
--> $DIR/supertrait-dyn-compatibility.rs:22:5
44+
--> $DIR/supertrait-dyn-compatibility.rs:25:5
4545
|
4646
LL | needs_bar(x);
4747
| ^^^^^^^^^ `Foo` is not dyn compatible
4848
|
4949
note: for a trait to be dyn compatible it needs to allow building a vtable
5050
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
51-
--> $DIR/supertrait-dyn-compatibility.rs:4:12
51+
--> $DIR/supertrait-dyn-compatibility.rs:7:12
5252
|
5353
LL | trait Foo: for<T> Bar<T> {}
5454
| --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables

tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.current.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/unifying-placeholders-in-query-response-2.rs:6:12
2+
--> $DIR/unifying-placeholders-in-query-response-2.rs:7:12
33
|
44
LL | #![feature(non_lifetime_binders)]
55
| ^^^^^^^^^^^^^^^^^^^^

tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.next.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/unifying-placeholders-in-query-response-2.rs:6:12
2+
--> $DIR/unifying-placeholders-in-query-response-2.rs:7:12
33
|
44
LL | #![feature(non_lifetime_binders)]
55
| ^^^^^^^^^^^^^^^^^^^^

tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@
33
//@[next] compile-flags: -Znext-solver
44
//@ check-pass
55

6+
#![feature(sized_hierarchy)]
67
#![feature(non_lifetime_binders)]
78
//~^ WARN the feature `non_lifetime_binders` is incomplete
89

9-
trait Id {
10-
type Output: ?Sized;
10+
use std::marker::PointeeSized;
11+
12+
trait Id: PointeeSized {
13+
type Output: PointeeSized;
1114
}
1215

13-
impl<T: ?Sized> Id for T {
16+
impl<T: PointeeSized> Id for T {
1417
type Output = T;
1518
}
1619

17-
trait Everyone {}
18-
impl<T: ?Sized> Everyone for T {}
20+
trait Everyone: PointeeSized {}
21+
impl<T: PointeeSized> Everyone for T {}
1922

2023
fn hello() where for<T> <T as Id>::Output: Everyone {}
2124

tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.current.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/unifying-placeholders-in-query-response.rs:6:12
2+
--> $DIR/unifying-placeholders-in-query-response.rs:7:12
33
|
44
LL | #![feature(non_lifetime_binders)]
55
| ^^^^^^^^^^^^^^^^^^^^

tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.next.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/unifying-placeholders-in-query-response.rs:6:12
2+
--> $DIR/unifying-placeholders-in-query-response.rs:7:12
33
|
44
LL | #![feature(non_lifetime_binders)]
55
| ^^^^^^^^^^^^^^^^^^^^

tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
//@[next] compile-flags: -Znext-solver
44
//@ check-pass
55

6+
#![feature(sized_hierarchy)]
67
#![feature(non_lifetime_binders)]
78
//~^ WARN the feature `non_lifetime_binders` is incomplete
89

9-
pub trait Foo<T: ?Sized> {
10-
type Bar<K: ?Sized>: ?Sized;
10+
use std::marker::PointeeSized;
11+
12+
pub trait Foo<T: PointeeSized> {
13+
type Bar<K: PointeeSized>: PointeeSized;
1114
}
1215

1316
impl Foo<usize> for () {
14-
type Bar<K: ?Sized> = K;
17+
type Bar<K: PointeeSized> = K;
1518
}
1619

1720
pub fn f<T1, T2>(a: T1, b: T2)

tests/ui/traits/non_lifetime_binders/universe-error1.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
#![feature(sized_hierarchy)]
12
#![feature(non_lifetime_binders)]
23
//~^ WARN the feature `non_lifetime_binders` is incomplete
34

4-
trait Other<U: ?Sized> {}
5+
use std::marker::PointeeSized;
56

6-
impl<U: ?Sized> Other<U> for U {}
7+
trait Other<U: PointeeSized>: PointeeSized {}
8+
9+
impl<U: PointeeSized> Other<U> for U {}
710

811
#[rustfmt::skip]
9-
fn foo<U: ?Sized>()
12+
fn foo<U: PointeeSized>()
1013
where
1114
for<T> T: Other<U> {}
1215

tests/ui/traits/non_lifetime_binders/universe-error1.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/universe-error1.rs:1:12
2+
--> $DIR/universe-error1.rs:2:12
33
|
44
LL | #![feature(non_lifetime_binders)]
55
| ^^^^^^^^^^^^^^^^^^^^
@@ -8,15 +8,15 @@ LL | #![feature(non_lifetime_binders)]
88
= note: `#[warn(incomplete_features)]` on by default
99

1010
error[E0277]: the trait bound `T: Other<_>` is not satisfied
11-
--> $DIR/universe-error1.rs:14:11
11+
--> $DIR/universe-error1.rs:17:11
1212
|
1313
LL | foo::<_>();
1414
| ^ the trait `Other<_>` is not implemented for `T`
1515
|
1616
note: required by a bound in `foo`
17-
--> $DIR/universe-error1.rs:11:15
17+
--> $DIR/universe-error1.rs:14:15
1818
|
19-
LL | fn foo<U: ?Sized>()
19+
LL | fn foo<U: PointeeSized>()
2020
| --- required by a bound in this function
2121
LL | where
2222
LL | for<T> T: Other<U> {}

0 commit comments

Comments
 (0)