Skip to content

Commit 3ba742c

Browse files
More tweaks to tests
1 parent 3a63f79 commit 3ba742c

File tree

2 files changed

+30
-27
lines changed

2 files changed

+30
-27
lines changed

tests/ui/associated-item/duplicate_bound.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![feature(associated_const_equality, return_type_notation)]
44
#![allow(dead_code, refining_impl_trait_internal, type_alias_bounds)]
55

6+
use std::any::TypeId;
67
use std::iter;
78
use std::mem::ManuallyDrop;
89

@@ -225,17 +226,19 @@ fn uncallable_rtn(_: impl Trait<foo(..): Trait<ASSOC = 3>, foo(..): Trait<ASSOC
225226
fn callable_rtn(_: impl Trait<foo(..): Send, foo(..): Send, foo(..): Eq>) {}
226227

227228
type Works = dyn Iterator<Item = i32, Item = i32>;
228-
// ^~ ERROR conflicting associated type bounds
229229

230230
trait Trait2 {
231231
const ASSOC: u32;
232232
}
233233

234234
type AlsoWorks = dyn Trait2<ASSOC = 3u32, ASSOC = 3u32>;
235-
// ^~ ERROR conflicting associated type bounds
236235

237236
fn main() {
238237
callable(iter::empty::<i32>());
239238
callable_const(());
240239
callable_rtn(());
240+
assert_eq!(
241+
TypeId::of::<dyn Iterator<Item = u32>>(),
242+
TypeId::of::<dyn Iterator<Item = u32, Item = u32>>()
243+
);
241244
}

tests/ui/associated-item/duplicate_bound_err.stderr

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0282]: type annotations needed
2-
--> $DIR/duplicate_err.rs:7:5
2+
--> $DIR/duplicate_bound_err.rs:7:5
33
|
44
LL | iter::empty()
55
| ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty`
@@ -10,7 +10,7 @@ LL | iter::empty::<T>()
1010
| +++++
1111

1212
error[E0282]: type annotations needed
13-
--> $DIR/duplicate_err.rs:11:5
13+
--> $DIR/duplicate_bound_err.rs:11:5
1414
|
1515
LL | iter::empty()
1616
| ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty`
@@ -21,7 +21,7 @@ LL | iter::empty::<T>()
2121
| +++++
2222

2323
error[E0282]: type annotations needed
24-
--> $DIR/duplicate_err.rs:15:5
24+
--> $DIR/duplicate_bound_err.rs:15:5
2525
|
2626
LL | iter::empty()
2727
| ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty`
@@ -32,55 +32,55 @@ LL | iter::empty::<T>()
3232
| +++++
3333

3434
error: unconstrained opaque type
35-
--> $DIR/duplicate_err.rs:19:51
35+
--> $DIR/duplicate_bound_err.rs:19:51
3636
|
3737
LL | type ETAI1<T: Iterator<Item: Copy, Item: Send>> = impl Copy;
3838
| ^^^^^^^^^
3939
|
4040
= note: `ETAI1` must be used in combination with a concrete type within the same crate
4141

4242
error: unconstrained opaque type
43-
--> $DIR/duplicate_err.rs:21:51
43+
--> $DIR/duplicate_bound_err.rs:21:51
4444
|
4545
LL | type ETAI2<T: Iterator<Item: Copy, Item: Copy>> = impl Copy;
4646
| ^^^^^^^^^
4747
|
4848
= note: `ETAI2` must be used in combination with a concrete type within the same crate
4949

5050
error: unconstrained opaque type
51-
--> $DIR/duplicate_err.rs:23:57
51+
--> $DIR/duplicate_bound_err.rs:23:57
5252
|
5353
LL | type ETAI3<T: Iterator<Item: 'static, Item: 'static>> = impl Copy;
5454
| ^^^^^^^^^
5555
|
5656
= note: `ETAI3` must be used in combination with a concrete type within the same crate
5757

5858
error: unconstrained opaque type
59-
--> $DIR/duplicate_err.rs:26:14
59+
--> $DIR/duplicate_bound_err.rs:26:14
6060
|
6161
LL | type ETAI4 = impl Iterator<Item: Copy, Item: Send>;
6262
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6363
|
6464
= note: `ETAI4` must be used in combination with a concrete type within the same crate
6565

6666
error: unconstrained opaque type
67-
--> $DIR/duplicate_err.rs:28:14
67+
--> $DIR/duplicate_bound_err.rs:28:14
6868
|
6969
LL | type ETAI5 = impl Iterator<Item: Copy, Item: Copy>;
7070
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7171
|
7272
= note: `ETAI5` must be used in combination with a concrete type within the same crate
7373

7474
error: unconstrained opaque type
75-
--> $DIR/duplicate_err.rs:30:14
75+
--> $DIR/duplicate_bound_err.rs:30:14
7676
|
7777
LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>;
7878
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7979
|
8080
= note: `ETAI6` must be used in combination with a concrete type within the same crate
8181

8282
error[E0277]: `*const ()` cannot be sent between threads safely
83-
--> $DIR/duplicate_err.rs:33:18
83+
--> $DIR/duplicate_bound_err.rs:33:18
8484
|
8585
LL | fn mismatch() -> impl Iterator<Item: Copy, Item: Send> {
8686
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely
@@ -90,15 +90,15 @@ LL | iter::empty::<*const ()>()
9090
= help: the trait `Send` is not implemented for `*const ()`
9191

9292
error[E0277]: the trait bound `String: Copy` is not satisfied
93-
--> $DIR/duplicate_err.rs:37:20
93+
--> $DIR/duplicate_bound_err.rs:37:20
9494
|
9595
LL | fn mismatch_2() -> impl Iterator<Item: Copy, Item: Send> {
9696
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
9797
LL | iter::empty::<String>()
9898
| ----------------------- return type was inferred to be `std::iter::Empty<String>` here
9999

100100
error: conflicting associated type bounds for `Item`
101-
--> $DIR/duplicate_err.rs:73:17
101+
--> $DIR/duplicate_bound_err.rs:73:17
102102
|
103103
LL | type MustFail = dyn Iterator<Item = i32, Item = u32>;
104104
| ^^^^^^^^^^^^^----------^^----------^
@@ -107,7 +107,7 @@ LL | type MustFail = dyn Iterator<Item = i32, Item = u32>;
107107
| `Item` is specified to be `i32` here
108108

109109
error: conflicting associated type bounds for `ASSOC`
110-
--> $DIR/duplicate_err.rs:80:18
110+
--> $DIR/duplicate_bound_err.rs:80:18
111111
|
112112
LL | type MustFail2 = dyn Trait2<ASSOC = 3u32, ASSOC = 4u32>;
113113
| ^^^^^^^^^^^------------^^------------^
@@ -116,35 +116,35 @@ LL | type MustFail2 = dyn Trait2<ASSOC = 3u32, ASSOC = 4u32>;
116116
| `ASSOC` is specified to be `3` here
117117

118118
error[E0271]: expected `Empty<u32>` to be an iterator that yields `i32`, but it yields `u32`
119-
--> $DIR/duplicate_err.rs:84:16
119+
--> $DIR/duplicate_bound_err.rs:84:16
120120
|
121121
LL | uncallable(iter::empty::<u32>());
122122
| ---------- ^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32`
123123
| |
124124
| required by a bound introduced by this call
125125
|
126126
note: required by a bound in `uncallable`
127-
--> $DIR/duplicate_err.rs:67:32
127+
--> $DIR/duplicate_bound_err.rs:67:32
128128
|
129129
LL | fn uncallable(_: impl Iterator<Item = i32, Item = u32>) {}
130130
| ^^^^^^^^^^ required by this bound in `uncallable`
131131

132132
error[E0271]: expected `Empty<i32>` to be an iterator that yields `u32`, but it yields `i32`
133-
--> $DIR/duplicate_err.rs:85:16
133+
--> $DIR/duplicate_bound_err.rs:85:16
134134
|
135135
LL | uncallable(iter::empty::<i32>());
136136
| ---------- ^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `i32`
137137
| |
138138
| required by a bound introduced by this call
139139
|
140140
note: required by a bound in `uncallable`
141-
--> $DIR/duplicate_err.rs:67:44
141+
--> $DIR/duplicate_bound_err.rs:67:44
142142
|
143143
LL | fn uncallable(_: impl Iterator<Item = i32, Item = u32>) {}
144144
| ^^^^^^^^^^ required by this bound in `uncallable`
145145

146146
error[E0271]: type mismatch resolving `<() as Trait>::ASSOC == 4`
147-
--> $DIR/duplicate_err.rs:86:22
147+
--> $DIR/duplicate_bound_err.rs:86:22
148148
|
149149
LL | uncallable_const(());
150150
| ---------------- ^^ expected `4`, found `3`
@@ -154,13 +154,13 @@ LL | uncallable_const(());
154154
= note: expected constant `4`
155155
found constant `3`
156156
note: required by a bound in `uncallable_const`
157-
--> $DIR/duplicate_err.rs:69:46
157+
--> $DIR/duplicate_bound_err.rs:69:46
158158
|
159159
LL | fn uncallable_const(_: impl Trait<ASSOC = 3, ASSOC = 4>) {}
160160
| ^^^^^^^^^ required by this bound in `uncallable_const`
161161

162162
error[E0271]: type mismatch resolving `<u32 as Trait>::ASSOC == 3`
163-
--> $DIR/duplicate_err.rs:87:22
163+
--> $DIR/duplicate_bound_err.rs:87:22
164164
|
165165
LL | uncallable_const(4u32);
166166
| ---------------- ^^^^ expected `3`, found `4`
@@ -170,13 +170,13 @@ LL | uncallable_const(4u32);
170170
= note: expected constant `3`
171171
found constant `4`
172172
note: required by a bound in `uncallable_const`
173-
--> $DIR/duplicate_err.rs:69:35
173+
--> $DIR/duplicate_bound_err.rs:69:35
174174
|
175175
LL | fn uncallable_const(_: impl Trait<ASSOC = 3, ASSOC = 4>) {}
176176
| ^^^^^^^^^ required by this bound in `uncallable_const`
177177

178178
error[E0271]: type mismatch resolving `<() as Trait>::ASSOC == 4`
179-
--> $DIR/duplicate_err.rs:88:20
179+
--> $DIR/duplicate_bound_err.rs:88:20
180180
|
181181
LL | uncallable_rtn(());
182182
| -------------- ^^ expected `4`, found `3`
@@ -186,13 +186,13 @@ LL | uncallable_rtn(());
186186
= note: expected constant `4`
187187
found constant `3`
188188
note: required by a bound in `uncallable_rtn`
189-
--> $DIR/duplicate_err.rs:71:75
189+
--> $DIR/duplicate_bound_err.rs:71:75
190190
|
191191
LL | fn uncallable_rtn(_: impl Trait<foo(..): Trait<ASSOC = 3>, foo(..): Trait<ASSOC = 4>>) {}
192192
| ^^^^^^^^^ required by this bound in `uncallable_rtn`
193193

194194
error[E0271]: type mismatch resolving `<u32 as Trait>::ASSOC == 3`
195-
--> $DIR/duplicate_err.rs:89:20
195+
--> $DIR/duplicate_bound_err.rs:89:20
196196
|
197197
LL | uncallable_rtn(17u32);
198198
| -------------- ^^^^^ expected `3`, found `4`
@@ -202,7 +202,7 @@ LL | uncallable_rtn(17u32);
202202
= note: expected constant `3`
203203
found constant `4`
204204
note: required by a bound in `uncallable_rtn`
205-
--> $DIR/duplicate_err.rs:71:48
205+
--> $DIR/duplicate_bound_err.rs:71:48
206206
|
207207
LL | fn uncallable_rtn(_: impl Trait<foo(..): Trait<ASSOC = 3>, foo(..): Trait<ASSOC = 4>>) {}
208208
| ^^^^^^^^^ required by this bound in `uncallable_rtn`

0 commit comments

Comments
 (0)