Skip to content

Commit 1fd13fd

Browse files
committed
tests: add #![rustc_no_implicit_bounds]
After reviewing all tests with `?Sized` and discussing with lcnr, these tests seem like they could probably benefit from `#![rustc_no_implicit_bounds]`.
1 parent b930202 commit 1fd13fd

18 files changed

+109
-89
lines changed
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
//@ compile-flags: -Znext-solver=coherence
22

3+
#![feature(rustc_attrs)]
4+
#![rustc_no_implicit_bounds]
35
#![recursion_limit = "10"]
46

57
trait Trait {}
68

7-
struct W<T: ?Sized>(*const T);
9+
struct W<T>(*const T);
810
trait TwoW {}
9-
impl<T: ?Sized + TwoW> TwoW for W<W<T>> {}
11+
impl<T: TwoW> TwoW for W<W<T>> {}
1012

11-
impl<T: ?Sized + TwoW> Trait for W<T> {}
12-
impl<T: ?Sized + TwoW> Trait for T {}
13+
impl<T: TwoW> Trait for W<T> {}
14+
impl<T: TwoW> Trait for T {}
1315
//~^ ERROR conflicting implementations of trait `Trait` for type `W
1416

1517
fn main() {}

tests/ui/traits/next-solver/coherence/coherence-fulfill-overflow.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
error[E0119]: conflicting implementations of trait `Trait` for type `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>>>>>>>>>>>>>`
2-
--> $DIR/coherence-fulfill-overflow.rs:12:1
2+
--> $DIR/coherence-fulfill-overflow.rs:14:1
33
|
4-
LL | impl<T: ?Sized + TwoW> Trait for W<T> {}
5-
| ------------------------------------- first implementation here
6-
LL | impl<T: ?Sized + TwoW> Trait for T {}
7-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>>>>>>>>>>>>>`
4+
LL | impl<T: TwoW> Trait for W<T> {}
5+
| ---------------------------- first implementation here
6+
LL | impl<T: TwoW> Trait for T {}
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>>>>>>>>>>>>>`
88

99
error: aborting due to 1 previous error
1010

tests/ui/traits/next-solver/cycles/coinduction/incompleteness-unstable-result.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ revisions: with without
22
//@ compile-flags: -Znext-solver
33
#![feature(rustc_attrs)]
4+
#![rustc_no_implicit_bounds]
45

56
// This test is incredibly subtle. At its core the goal is to get a coinductive cycle,
67
// which, depending on its root goal, either holds or errors. We achieve this by getting
@@ -17,20 +18,20 @@
1718
// test for that.
1819

1920
#[rustc_coinductive]
20-
trait Trait<T: ?Sized, V: ?Sized, D: ?Sized> {}
21-
struct A<T: ?Sized>(*const T);
22-
struct B<T: ?Sized>(*const T);
21+
trait Trait<T, V, D> {}
22+
struct A<T>(*const T);
23+
struct B<T>(*const T);
2324

24-
trait IncompleteGuidance<T: ?Sized, V: ?Sized> {}
25-
impl<T: ?Sized, U: ?Sized + 'static> IncompleteGuidance<U, u8> for T {}
26-
impl<T: ?Sized, U: ?Sized + 'static> IncompleteGuidance<U, i8> for T {}
27-
impl<T: ?Sized, U: ?Sized + 'static> IncompleteGuidance<U, i16> for T {}
25+
trait IncompleteGuidance<T, V> {}
26+
impl<T, U: 'static> IncompleteGuidance<U, u8> for T {}
27+
impl<T, U: 'static> IncompleteGuidance<U, i8> for T {}
28+
impl<T, U: 'static> IncompleteGuidance<U, i16> for T {}
2829

29-
trait ImplGuidance<T: ?Sized, V: ?Sized> {}
30-
impl<T: ?Sized> ImplGuidance<u32, u8> for T {}
31-
impl<T: ?Sized> ImplGuidance<i32, i8> for T {}
30+
trait ImplGuidance<T, V> {}
31+
impl<T> ImplGuidance<u32, u8> for T {}
32+
impl<T> ImplGuidance<i32, i8> for T {}
3233

33-
impl<T: ?Sized, U: ?Sized, V: ?Sized, D: ?Sized> Trait<U, V, D> for A<T>
34+
impl<T, U, V, D> Trait<U, V, D> for A<T>
3435
where
3536
T: IncompleteGuidance<U, V>,
3637
A<T>: Trait<U, D, V>,
@@ -39,17 +40,17 @@ where
3940
{
4041
}
4142

42-
trait ToU8<T: ?Sized> {}
43+
trait ToU8<T> {}
4344
impl ToU8<u8> for () {}
4445

45-
impl<T: ?Sized, U: ?Sized, V: ?Sized, D: ?Sized> Trait<U, V, D> for B<T>
46+
impl<T, U, V, D> Trait<U, V, D> for B<T>
4647
where
4748
T: ImplGuidance<U, V>,
4849
A<T>: Trait<U, V, D>,
4950
{
5051
}
5152

52-
fn impls_trait<T: ?Sized + Trait<U, V, D>, U: ?Sized, V: ?Sized, D: ?Sized>() {}
53+
fn impls_trait<T: Trait<U, V, D>, U, V, D>() {}
5354

5455
fn with_bound<X>()
5556
where

tests/ui/traits/next-solver/cycles/coinduction/incompleteness-unstable-result.with.stderr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
error[E0277]: the trait bound `A<X>: Trait<_, _, _>` is not satisfied
2-
--> $DIR/incompleteness-unstable-result.rs:65:19
2+
--> $DIR/incompleteness-unstable-result.rs:66:19
33
|
44
LL | impls_trait::<A<X>, _, _, _>();
55
| ^^^^ the trait `Trait<_, _, _>` is not implemented for `A<X>`
66
|
77
= help: the trait `Trait<U, V, D>` is implemented for `A<T>`
88
note: required for `A<X>` to implement `Trait<_, _, _>`
9-
--> $DIR/incompleteness-unstable-result.rs:33:50
9+
--> $DIR/incompleteness-unstable-result.rs:34:18
1010
|
11-
LL | impl<T: ?Sized, U: ?Sized, V: ?Sized, D: ?Sized> Trait<U, V, D> for A<T>
12-
| ^^^^^^^^^^^^^^ ^^^^
11+
LL | impl<T, U, V, D> Trait<U, V, D> for A<T>
12+
| ^^^^^^^^^^^^^^ ^^^^
1313
...
1414
LL | A<T>: Trait<U, D, V>,
1515
| -------------- unsatisfied trait bound introduced here
1616
= note: 8 redundant requirements hidden
1717
= note: required for `A<X>` to implement `Trait<_, _, _>`
1818
note: required by a bound in `impls_trait`
19-
--> $DIR/incompleteness-unstable-result.rs:52:28
19+
--> $DIR/incompleteness-unstable-result.rs:53:19
2020
|
21-
LL | fn impls_trait<T: ?Sized + Trait<U, V, D>, U: ?Sized, V: ?Sized, D: ?Sized>() {}
22-
| ^^^^^^^^^^^^^^ required by this bound in `impls_trait`
21+
LL | fn impls_trait<T: Trait<U, V, D>, U, V, D>() {}
22+
| ^^^^^^^^^^^^^^ required by this bound in `impls_trait`
2323

2424
error: aborting due to 1 previous error
2525

tests/ui/traits/next-solver/cycles/coinduction/incompleteness-unstable-result.without.stderr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
error[E0277]: the trait bound `A<X>: Trait<_, _, _>` is not satisfied
2-
--> $DIR/incompleteness-unstable-result.rs:65:19
2+
--> $DIR/incompleteness-unstable-result.rs:66:19
33
|
44
LL | impls_trait::<A<X>, _, _, _>();
55
| ^^^^ the trait `Trait<_, _, _>` is not implemented for `A<X>`
66
|
77
= help: the trait `Trait<U, V, D>` is implemented for `A<T>`
88
note: required for `A<X>` to implement `Trait<_, _, _>`
9-
--> $DIR/incompleteness-unstable-result.rs:33:50
9+
--> $DIR/incompleteness-unstable-result.rs:34:18
1010
|
11-
LL | impl<T: ?Sized, U: ?Sized, V: ?Sized, D: ?Sized> Trait<U, V, D> for A<T>
12-
| ^^^^^^^^^^^^^^ ^^^^
11+
LL | impl<T, U, V, D> Trait<U, V, D> for A<T>
12+
| ^^^^^^^^^^^^^^ ^^^^
1313
...
1414
LL | A<T>: Trait<U, D, V>,
1515
| -------------- unsatisfied trait bound introduced here
1616
= note: 8 redundant requirements hidden
1717
= note: required for `A<X>` to implement `Trait<_, _, _>`
1818
note: required by a bound in `impls_trait`
19-
--> $DIR/incompleteness-unstable-result.rs:52:28
19+
--> $DIR/incompleteness-unstable-result.rs:53:19
2020
|
21-
LL | fn impls_trait<T: ?Sized + Trait<U, V, D>, U: ?Sized, V: ?Sized, D: ?Sized>() {}
22-
| ^^^^^^^^^^^^^^ required by this bound in `impls_trait`
21+
LL | fn impls_trait<T: Trait<U, V, D>, U, V, D>() {}
22+
| ^^^^^^^^^^^^^^ required by this bound in `impls_trait`
2323

2424
error: aborting due to 1 previous error
2525

tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
//@ compile-flags: -Znext-solver
22
#![feature(rustc_attrs)]
3+
#![rustc_no_implicit_bounds]
34

45
// Check that we correctly rerun the trait solver for heads of cycles,
56
// even if they are not the root.
67

7-
struct A<T: ?Sized>(*const T);
8-
struct B<T: ?Sized>(*const T);
9-
struct C<T: ?Sized>(*const T);
8+
struct A<T>(*const T);
9+
struct B<T>(*const T);
10+
struct C<T>(*const T);
1011

1112
#[rustc_coinductive]
1213
trait Trait<'a, 'b> {}
1314
trait NotImplemented {}
1415

15-
impl<'a, 'b, T: ?Sized> Trait<'a, 'b> for A<T> where B<T>: Trait<'a, 'b> {}
16+
impl<'a, 'b, T> Trait<'a, 'b> for A<T> where B<T>: Trait<'a, 'b> {}
1617

1718
// With this the root of `B<T>` is `A<T>`, even if the other impl does
1819
// not have a cycle with `A<T>`. This candidate never applies because of
1920
// the `A<T>: NotImplemented` bound.
20-
impl<'a, 'b, T: ?Sized> Trait<'a, 'b> for B<T>
21+
impl<'a, 'b, T> Trait<'a, 'b> for B<T>
2122
where
2223
A<T>: Trait<'a, 'b>,
2324
A<T>: NotImplemented,
@@ -31,7 +32,7 @@ where
3132
// use the impl itself to prove that adds region constraints as we uniquified the
3233
// regions in the `A<T>: Trait<'a, 'b>` where-bound. As both the impl above
3334
// and the impl below now apply with some constraints, we failed with ambiguity.
34-
impl<'a, 'b, T: ?Sized> Trait<'a, 'b> for B<T>
35+
impl<'a, 'b, T> Trait<'a, 'b> for B<T>
3536
where
3637
A<T>: NotImplemented,
3738
{}
@@ -40,22 +41,22 @@ where
4041
//
4142
// Because of the coinductive cycle through `C<T>` it also requires
4243
// 'a to be 'static.
43-
impl<'a, T: ?Sized> Trait<'a, 'static> for B<T>
44+
impl<'a, T> Trait<'a, 'static> for B<T>
4445
where
4546
C<T>: Trait<'a, 'a>,
4647
{}
4748

4849
// In the first iteration of `B<T>: Trait<'a, 'b>` we don't add any
4950
// constraints here, only after setting the provisional result to require
5051
// `'b == 'static` do we also add that constraint for `'a`.
51-
impl<'a, 'b, T: ?Sized> Trait<'a, 'b> for C<T>
52+
impl<'a, 'b, T> Trait<'a, 'b> for C<T>
5253
where
5354
B<T>: Trait<'a, 'b>,
5455
{}
5556

56-
fn impls_trait<'a, 'b, T: Trait<'a, 'b> + ?Sized>() {}
57+
fn impls_trait<'a, 'b, T: Trait<'a, 'b>>() {}
5758

58-
fn check<'a, T: ?Sized>() {
59+
fn check<'a, T>() {
5960
impls_trait::<'a, 'static, A<T>>();
6061
//~^ ERROR lifetime may not live long enough
6162
}

tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error: lifetime may not live long enough
2-
--> $DIR/fixpoint-rerun-all-cycle-heads.rs:59:5
2+
--> $DIR/fixpoint-rerun-all-cycle-heads.rs:60:5
33
|
4-
LL | fn check<'a, T: ?Sized>() {
4+
LL | fn check<'a, T>() {
55
| -- lifetime `'a` defined here
66
LL | impls_trait::<'a, 'static, A<T>>();
77
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`

tests/ui/traits/next-solver/cycles/inductive-fixpoint-hang.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
//@ compile-flags: -Znext-solver
2+
#![feature(rustc_attrs)]
3+
#![rustc_no_implicit_bounds]
24

35
// This currently hangs if we do not erase constraints from
46
// overflow.
@@ -17,9 +19,9 @@
1719
// the solver to hang without hitting the recursion limit.
1820
trait Trait {}
1921

20-
struct W<T: ?Sized>(*const T);
22+
struct W<T>(*const T);
2123

22-
impl<T: ?Sized> Trait for W<W<T>>
24+
impl<T> Trait for W<W<T>>
2325
where
2426
W<T>: Trait,
2527
W<T>: Trait,

tests/ui/traits/next-solver/cycles/inductive-fixpoint-hang.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0275]: overflow evaluating the requirement `W<_>: Trait`
2-
--> $DIR/inductive-fixpoint-hang.rs:31:19
2+
--> $DIR/inductive-fixpoint-hang.rs:33:19
33
|
44
LL | impls_trait::<W<_>>();
55
| ^^^^
66
|
77
note: required by a bound in `impls_trait`
8-
--> $DIR/inductive-fixpoint-hang.rs:28:19
8+
--> $DIR/inductive-fixpoint-hang.rs:30:19
99
|
1010
LL | fn impls_trait<T: Trait>() {}
1111
| ^^^^^ required by this bound in `impls_trait`

tests/ui/traits/next-solver/cycles/provisional-cache-impacts-behavior.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ compile-flags: -Znext-solver
22
//@ check-pass
33
#![feature(rustc_attrs)]
4+
#![rustc_no_implicit_bounds]
45

56
// A test showcasing that using a provisional cache can differ
67
// from only tracking stack entries.
@@ -59,9 +60,9 @@ trait B {}
5960
#[rustc_coinductive]
6061
trait C {}
6162

62-
impl<T: ?Sized + B + C> A for T {}
63-
impl<T: ?Sized + A + C> B for T {}
64-
impl<T: ?Sized + B> C for T {}
63+
impl<T: B + C> A for T {}
64+
impl<T: A + C> B for T {}
65+
impl<T: B> C for T {}
6566

6667
fn impls_a<T: A>() {}
6768

tests/ui/traits/next-solver/dont-canonicalize-re-error.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
//@ compile-flags: -Znext-solver
2+
#![feature(rustc_attrs)]
3+
#![rustc_no_implicit_bounds]
24

35
trait Tr<'a> {}
46

@@ -16,9 +18,9 @@ trait Tr<'a> {}
1618
// Then, when we recompute the goal `W<?0>: Constrain<'error>`, when
1719
// collecting ambiguities and overflows, we end up assembling a default
1820
// error candidate w/o ambiguity, which causes the goal to pass, and ICE.
19-
impl<'a, A: ?Sized> Tr<'a> for W<A> {}
20-
struct W<A: ?Sized>(A);
21-
impl<'a, A: ?Sized> Tr<'a> for A where A: Constrain<'a> {}
21+
impl<'a, A> Tr<'a> for W<A> {}
22+
struct W<A>(A);
23+
impl<'a, A> Tr<'a> for A where A: Constrain<'a> {}
2224
//~^ ERROR conflicting implementations of trait `Tr<'_>` for type `W<_>`
2325

2426
trait Constrain<'a> {}

tests/ui/traits/next-solver/dont-canonicalize-re-error.stderr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
error[E0261]: use of undeclared lifetime name `'missing`
2-
--> $DIR/dont-canonicalize-re-error.rs:25:26
2+
--> $DIR/dont-canonicalize-re-error.rs:27:26
33
|
44
LL | impl<A: Sized> Constrain<'missing> for W<A> {}
55
| - ^^^^^^^^ undeclared lifetime
66
| |
77
| help: consider introducing lifetime `'missing` here: `'missing,`
88

99
error[E0119]: conflicting implementations of trait `Tr<'_>` for type `W<_>`
10-
--> $DIR/dont-canonicalize-re-error.rs:21:1
10+
--> $DIR/dont-canonicalize-re-error.rs:23:1
1111
|
12-
LL | impl<'a, A: ?Sized> Tr<'a> for W<A> {}
13-
| ----------------------------------- first implementation here
14-
LL | struct W<A: ?Sized>(A);
15-
LL | impl<'a, A: ?Sized> Tr<'a> for A where A: Constrain<'a> {}
16-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `W<_>`
12+
LL | impl<'a, A> Tr<'a> for W<A> {}
13+
| --------------------------- first implementation here
14+
LL | struct W<A>(A);
15+
LL | impl<'a, A> Tr<'a> for A where A: Constrain<'a> {}
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `W<_>`
1717

1818
error: aborting due to 2 previous errors
1919

tests/ui/traits/next-solver/normalize/normalize-region-obligations.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//@ revisions: normalize_param_env normalize_obligation hrtb
22
//@ check-pass
33
//@ compile-flags: -Znext-solver
4+
#![feature(rustc_attrs)]
5+
#![rustc_no_implicit_bounds]
46

57
trait Foo {
68
#[cfg(normalize_param_env)]
@@ -11,11 +13,11 @@ trait Foo {
1113
type Gat<'b> where for<'a> <Self as MirrorRegion<'a>>::Assoc: 'b;
1214
}
1315

14-
trait Mirror { type Assoc: ?Sized; }
15-
impl<T: ?Sized> Mirror for T { type Assoc = T; }
16+
trait Mirror { type Assoc; }
17+
impl<T> Mirror for T { type Assoc = T; }
1618

17-
trait MirrorRegion<'a> { type Assoc: ?Sized; }
18-
impl<'a, T: ?Sized> MirrorRegion<'a> for T { type Assoc = T; }
19+
trait MirrorRegion<'a> { type Assoc; }
20+
impl<'a, T> MirrorRegion<'a> for T { type Assoc = T; }
1921

2022
impl<T> Foo for T {
2123
#[cfg(normalize_param_env)]

0 commit comments

Comments
 (0)