Skip to content

Commit 5be51f2

Browse files
authored
Rollup merge of rust-lang#88182 - spastorino:use-trait-in-tait-tests, r=oli-obk
We meant to use a trait instead of lifetime here r? `@oli-obk` Related to rust-lang#86727
2 parents 1a48b56 + 49a31a2 commit 5be51f2

4 files changed

+12
-33
lines changed

src/test/ui/type-alias-impl-trait/generic_underconstrained.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
fn main() {}
44

55
trait Trait {}
6-
type Underconstrained<T: Trait> = impl 'static;
7-
//~^ ERROR: at least one trait must be specified
6+
type Underconstrained<T: Trait> = impl Send;
87

98
// no `Trait` bound
109
fn underconstrain<T>(_: T) -> Underconstrained<T> {
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
1-
error: at least one trait must be specified
2-
--> $DIR/generic_underconstrained.rs:6:35
3-
|
4-
LL | type Underconstrained<T: Trait> = impl 'static;
5-
| ^^^^^^^^^^^^
6-
71
error[E0277]: the trait bound `T: Trait` is not satisfied
8-
--> $DIR/generic_underconstrained.rs:10:31
2+
--> $DIR/generic_underconstrained.rs:9:31
93
|
104
LL | fn underconstrain<T>(_: T) -> Underconstrained<T> {
115
| ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T`
126
|
137
note: required by a bound in `Underconstrained`
148
--> $DIR/generic_underconstrained.rs:6:26
159
|
16-
LL | type Underconstrained<T: Trait> = impl 'static;
10+
LL | type Underconstrained<T: Trait> = impl Send;
1711
| ^^^^^ required by this bound in `Underconstrained`
1812
help: consider restricting type parameter `T`
1913
|
2014
LL | fn underconstrain<T: Trait>(_: T) -> Underconstrained<T> {
2115
| +++++++
2216

23-
error: aborting due to 2 previous errors
17+
error: aborting due to previous error
2418

2519
For more information about this error, try `rustc --explain E0277`.

src/test/ui/type-alias-impl-trait/generic_underconstrained2.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22

33
fn main() {}
44

5-
type Underconstrained<T: std::fmt::Debug> = impl 'static;
6-
//~^ ERROR: at least one trait must be specified
5+
type Underconstrained<T: std::fmt::Debug> = impl Send;
76

87
// not a defining use, because it doesn't define *all* possible generics
98
fn underconstrained<U>(_: U) -> Underconstrained<U> {
109
//~^ ERROR `U` doesn't implement `Debug`
1110
5u32
1211
}
1312

14-
type Underconstrained2<T: std::fmt::Debug> = impl 'static;
15-
//~^ ERROR: at least one trait must be specified
13+
type Underconstrained2<T: std::fmt::Debug> = impl Send;
1614

1715
// not a defining use, because it doesn't define *all* possible generics
1816
fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> {
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,35 @@
1-
error: at least one trait must be specified
2-
--> $DIR/generic_underconstrained2.rs:5:45
3-
|
4-
LL | type Underconstrained<T: std::fmt::Debug> = impl 'static;
5-
| ^^^^^^^^^^^^
6-
7-
error: at least one trait must be specified
8-
--> $DIR/generic_underconstrained2.rs:14:46
9-
|
10-
LL | type Underconstrained2<T: std::fmt::Debug> = impl 'static;
11-
| ^^^^^^^^^^^^
12-
131
error[E0277]: `U` doesn't implement `Debug`
14-
--> $DIR/generic_underconstrained2.rs:9:33
2+
--> $DIR/generic_underconstrained2.rs:8:33
153
|
164
LL | fn underconstrained<U>(_: U) -> Underconstrained<U> {
175
| ^^^^^^^^^^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug`
186
|
197
note: required by a bound in `Underconstrained`
208
--> $DIR/generic_underconstrained2.rs:5:26
219
|
22-
LL | type Underconstrained<T: std::fmt::Debug> = impl 'static;
10+
LL | type Underconstrained<T: std::fmt::Debug> = impl Send;
2311
| ^^^^^^^^^^^^^^^ required by this bound in `Underconstrained`
2412
help: consider restricting type parameter `U`
2513
|
2614
LL | fn underconstrained<U: std::fmt::Debug>(_: U) -> Underconstrained<U> {
2715
| +++++++++++++++++
2816

2917
error[E0277]: `V` doesn't implement `Debug`
30-
--> $DIR/generic_underconstrained2.rs:18:43
18+
--> $DIR/generic_underconstrained2.rs:16:43
3119
|
3220
LL | fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> {
3321
| ^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `Debug`
3422
|
3523
note: required by a bound in `Underconstrained2`
36-
--> $DIR/generic_underconstrained2.rs:14:27
24+
--> $DIR/generic_underconstrained2.rs:13:27
3725
|
38-
LL | type Underconstrained2<T: std::fmt::Debug> = impl 'static;
26+
LL | type Underconstrained2<T: std::fmt::Debug> = impl Send;
3927
| ^^^^^^^^^^^^^^^ required by this bound in `Underconstrained2`
4028
help: consider restricting type parameter `V`
4129
|
4230
LL | fn underconstrained2<U, V: std::fmt::Debug>(_: U, _: V) -> Underconstrained2<V> {
4331
| +++++++++++++++++
4432

45-
error: aborting due to 4 previous errors
33+
error: aborting due to 2 previous errors
4634

4735
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)