Skip to content

Commit 483b137

Browse files
committed
Fix new associated_const_equality test
1 parent 86f9105 commit 483b137

File tree

3 files changed

+47
-34
lines changed

3 files changed

+47
-34
lines changed

tests/ui/associated-type-bounds/duplicate-bound-err.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
//@ edition: 2024
22

3-
#![feature(associated_const_equality, type_alias_impl_trait, return_type_notation)]
3+
#![feature(
4+
associated_const_equality,
5+
min_generic_const_args,
6+
type_alias_impl_trait,
7+
return_type_notation
8+
)]
9+
#![expect(incomplete_features)]
410
#![allow(refining_impl_trait_internal)]
511

612
use std::iter;
@@ -45,6 +51,7 @@ fn mismatch_2() -> impl Iterator<Item: Copy, Item: Send> {
4551
trait Trait {
4652
type Gat<T>;
4753

54+
#[type_const]
4855
const ASSOC: i32;
4956

5057
fn foo() -> impl Sized;
@@ -53,6 +60,7 @@ trait Trait {
5360
impl Trait for () {
5461
type Gat<T> = ();
5562

63+
#[type_const]
5664
const ASSOC: i32 = 3;
5765

5866
fn foo() {}
@@ -61,6 +69,7 @@ impl Trait for () {
6169
impl Trait for u32 {
6270
type Gat<T> = ();
6371

72+
#[type_const]
6473
const ASSOC: i32 = 4;
6574

6675
fn foo() -> u32 {
@@ -79,6 +88,7 @@ type MustFail = dyn Iterator<Item = i32, Item = u32>;
7988
//~| ERROR conflicting associated type bounds
8089

8190
trait Trait2 {
91+
#[type_const]
8292
const ASSOC: u32;
8393
}
8494

tests/ui/associated-type-bounds/duplicate-bound-err.stderr

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0282]: type annotations needed
2-
--> $DIR/duplicate-bound-err.rs:9:5
2+
--> $DIR/duplicate-bound-err.rs:15: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-bound-err.rs:13:5
13+
--> $DIR/duplicate-bound-err.rs:19: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-bound-err.rs:17:5
24+
--> $DIR/duplicate-bound-err.rs:23: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-bound-err.rs:21:51
35+
--> $DIR/duplicate-bound-err.rs:27:51
3636
|
3737
LL | type Tait1<T: Iterator<Item: Copy, Item: Send>> = impl Copy;
3838
| ^^^^^^^^^
3939
|
4040
= note: `Tait1` must be used in combination with a concrete type within the same crate
4141

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

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

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

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

7474
error: unconstrained opaque type
75-
--> $DIR/duplicate-bound-err.rs:32:14
75+
--> $DIR/duplicate-bound-err.rs:38:14
7676
|
7777
LL | type Tait6 = impl Iterator<Item: 'static, Item: 'static>;
7878
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7979
|
8080
= note: `Tait6` 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-bound-err.rs:35:18
83+
--> $DIR/duplicate-bound-err.rs:41:18
8484
|
8585
LL | fn mismatch() -> impl Iterator<Item: Copy, Item: Send> {
8686
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely
@@ -91,7 +91,7 @@ LL | iter::empty::<*const ()>()
9191
= help: the trait `Send` is not implemented for `*const ()`
9292

9393
error[E0277]: the trait bound `String: Copy` is not satisfied
94-
--> $DIR/duplicate-bound-err.rs:40:20
94+
--> $DIR/duplicate-bound-err.rs:46:20
9595
|
9696
LL | fn mismatch_2() -> impl Iterator<Item: Copy, Item: Send> {
9797
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
@@ -100,7 +100,7 @@ LL | iter::empty::<String>()
100100
| ----------------------- return type was inferred to be `std::iter::Empty<String>` here
101101

102102
error[E0271]: expected `IntoIter<u32, 1>` to be an iterator that yields `i32`, but it yields `u32`
103-
--> $DIR/duplicate-bound-err.rs:100:17
103+
--> $DIR/duplicate-bound-err.rs:110:17
104104
|
105105
LL | fn foo() -> impl Iterator<Item = i32, Item = u32> {
106106
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32`
@@ -109,15 +109,15 @@ LL | [2u32].into_iter()
109109
| ------------------ return type was inferred to be `std::array::IntoIter<u32, 1>` here
110110

111111
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
112-
--> $DIR/duplicate-bound-err.rs:77:42
112+
--> $DIR/duplicate-bound-err.rs:86:42
113113
|
114114
LL | type MustFail = dyn Iterator<Item = i32, Item = u32>;
115115
| ---------- ^^^^^^^^^^ re-bound here
116116
| |
117117
| `Item` bound here first
118118

119119
error: conflicting associated type bounds for `Item`
120-
--> $DIR/duplicate-bound-err.rs:77:17
120+
--> $DIR/duplicate-bound-err.rs:86:17
121121
|
122122
LL | type MustFail = dyn Iterator<Item = i32, Item = u32>;
123123
| ^^^^^^^^^^^^^----------^^----------^
@@ -126,15 +126,15 @@ LL | type MustFail = dyn Iterator<Item = i32, Item = u32>;
126126
| `Item` is specified to be `i32` here
127127

128128
error[E0719]: the value of the associated type `ASSOC` in trait `Trait2` is already specified
129-
--> $DIR/duplicate-bound-err.rs:85:43
129+
--> $DIR/duplicate-bound-err.rs:95:43
130130
|
131131
LL | type MustFail2 = dyn Trait2<ASSOC = 3u32, ASSOC = 4u32>;
132132
| ------------ ^^^^^^^^^^^^ re-bound here
133133
| |
134134
| `ASSOC` bound here first
135135

136136
error: conflicting associated type bounds for `ASSOC`
137-
--> $DIR/duplicate-bound-err.rs:85:18
137+
--> $DIR/duplicate-bound-err.rs:95:18
138138
|
139139
LL | type MustFail2 = dyn Trait2<ASSOC = 3u32, ASSOC = 4u32>;
140140
| ^^^^^^^^^^^------------^^------------^
@@ -143,63 +143,63 @@ LL | type MustFail2 = dyn Trait2<ASSOC = 3u32, ASSOC = 4u32>;
143143
| `ASSOC` is specified to be `3` here
144144

145145
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
146-
--> $DIR/duplicate-bound-err.rs:89:43
146+
--> $DIR/duplicate-bound-err.rs:99:43
147147
|
148148
LL | type MustFail3 = dyn Iterator<Item = i32, Item = i32>;
149149
| ---------- ^^^^^^^^^^ re-bound here
150150
| |
151151
| `Item` bound here first
152152

153153
error[E0719]: the value of the associated type `ASSOC` in trait `Trait2` is already specified
154-
--> $DIR/duplicate-bound-err.rs:92:43
154+
--> $DIR/duplicate-bound-err.rs:102:43
155155
|
156156
LL | type MustFail4 = dyn Trait2<ASSOC = 3u32, ASSOC = 3u32>;
157157
| ------------ ^^^^^^^^^^^^ re-bound here
158158
| |
159159
| `ASSOC` bound here first
160160

161161
error[E0271]: expected `impl Iterator<Item = u32>` to be an iterator that yields `i32`, but it yields `u32`
162-
--> $DIR/duplicate-bound-err.rs:100:17
162+
--> $DIR/duplicate-bound-err.rs:110:17
163163
|
164164
LL | fn foo() -> impl Iterator<Item = i32, Item = u32> {
165165
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32`
166166
|
167167
note: required by a bound in `Trait3::foo::{anon_assoc#0}`
168-
--> $DIR/duplicate-bound-err.rs:96:31
168+
--> $DIR/duplicate-bound-err.rs:106:31
169169
|
170170
LL | fn foo() -> impl Iterator<Item = i32, Item = u32>;
171171
| ^^^^^^^^^^ required by this bound in `Trait3::foo::{anon_assoc#0}`
172172

173173
error[E0271]: expected `Empty<u32>` to be an iterator that yields `i32`, but it yields `u32`
174-
--> $DIR/duplicate-bound-err.rs:108:16
174+
--> $DIR/duplicate-bound-err.rs:118:16
175175
|
176176
LL | uncallable(iter::empty::<u32>());
177177
| ---------- ^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32`
178178
| |
179179
| required by a bound introduced by this call
180180
|
181181
note: required by a bound in `uncallable`
182-
--> $DIR/duplicate-bound-err.rs:71:32
182+
--> $DIR/duplicate-bound-err.rs:80:32
183183
|
184184
LL | fn uncallable(_: impl Iterator<Item = i32, Item = u32>) {}
185185
| ^^^^^^^^^^ required by this bound in `uncallable`
186186

187187
error[E0271]: expected `Empty<i32>` to be an iterator that yields `u32`, but it yields `i32`
188-
--> $DIR/duplicate-bound-err.rs:109:16
188+
--> $DIR/duplicate-bound-err.rs:119:16
189189
|
190190
LL | uncallable(iter::empty::<i32>());
191191
| ---------- ^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `i32`
192192
| |
193193
| required by a bound introduced by this call
194194
|
195195
note: required by a bound in `uncallable`
196-
--> $DIR/duplicate-bound-err.rs:71:44
196+
--> $DIR/duplicate-bound-err.rs:80:44
197197
|
198198
LL | fn uncallable(_: impl Iterator<Item = i32, Item = u32>) {}
199199
| ^^^^^^^^^^ required by this bound in `uncallable`
200200

201201
error[E0271]: type mismatch resolving `<() as Trait>::ASSOC == 4`
202-
--> $DIR/duplicate-bound-err.rs:110:22
202+
--> $DIR/duplicate-bound-err.rs:120:22
203203
|
204204
LL | uncallable_const(());
205205
| ---------------- ^^ expected `4`, found `3`
@@ -209,13 +209,13 @@ LL | uncallable_const(());
209209
= note: expected constant `4`
210210
found constant `3`
211211
note: required by a bound in `uncallable_const`
212-
--> $DIR/duplicate-bound-err.rs:73:46
212+
--> $DIR/duplicate-bound-err.rs:82:46
213213
|
214214
LL | fn uncallable_const(_: impl Trait<ASSOC = 3, ASSOC = 4>) {}
215215
| ^^^^^^^^^ required by this bound in `uncallable_const`
216216

217217
error[E0271]: type mismatch resolving `<u32 as Trait>::ASSOC == 3`
218-
--> $DIR/duplicate-bound-err.rs:111:22
218+
--> $DIR/duplicate-bound-err.rs:121:22
219219
|
220220
LL | uncallable_const(4u32);
221221
| ---------------- ^^^^ expected `3`, found `4`
@@ -225,13 +225,13 @@ LL | uncallable_const(4u32);
225225
= note: expected constant `3`
226226
found constant `4`
227227
note: required by a bound in `uncallable_const`
228-
--> $DIR/duplicate-bound-err.rs:73:35
228+
--> $DIR/duplicate-bound-err.rs:82:35
229229
|
230230
LL | fn uncallable_const(_: impl Trait<ASSOC = 3, ASSOC = 4>) {}
231231
| ^^^^^^^^^ required by this bound in `uncallable_const`
232232

233233
error[E0271]: type mismatch resolving `<() as Trait>::ASSOC == 4`
234-
--> $DIR/duplicate-bound-err.rs:112:20
234+
--> $DIR/duplicate-bound-err.rs:122:20
235235
|
236236
LL | uncallable_rtn(());
237237
| -------------- ^^ expected `4`, found `3`
@@ -241,13 +241,13 @@ LL | uncallable_rtn(());
241241
= note: expected constant `4`
242242
found constant `3`
243243
note: required by a bound in `uncallable_rtn`
244-
--> $DIR/duplicate-bound-err.rs:75:75
244+
--> $DIR/duplicate-bound-err.rs:84:75
245245
|
246246
LL | fn uncallable_rtn(_: impl Trait<foo(..): Trait<ASSOC = 3>, foo(..): Trait<ASSOC = 4>>) {}
247247
| ^^^^^^^^^ required by this bound in `uncallable_rtn`
248248

249249
error[E0271]: type mismatch resolving `<u32 as Trait>::ASSOC == 3`
250-
--> $DIR/duplicate-bound-err.rs:113:20
250+
--> $DIR/duplicate-bound-err.rs:123:20
251251
|
252252
LL | uncallable_rtn(17u32);
253253
| -------------- ^^^^^ expected `3`, found `4`
@@ -257,7 +257,7 @@ LL | uncallable_rtn(17u32);
257257
= note: expected constant `3`
258258
found constant `4`
259259
note: required by a bound in `uncallable_rtn`
260-
--> $DIR/duplicate-bound-err.rs:75:48
260+
--> $DIR/duplicate-bound-err.rs:84:48
261261
|
262262
LL | fn uncallable_rtn(_: impl Trait<foo(..): Trait<ASSOC = 3>, foo(..): Trait<ASSOC = 4>>) {}
263263
| ^^^^^^^^^ required by this bound in `uncallable_rtn`

tests/ui/associated-type-bounds/duplicate-bound.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//@ edition: 2024
22
//@ run-pass
33

4-
#![feature(associated_const_equality, return_type_notation)]
4+
#![feature(associated_const_equality, min_generic_const_args, return_type_notation)]
5+
#![expect(incomplete_features)]
56
#![allow(dead_code, refining_impl_trait_internal, type_alias_bounds)]
67

78
use std::iter;
@@ -188,6 +189,7 @@ trait Tra3 {
188189
trait Trait {
189190
type Gat<T>;
190191

192+
#[type_const]
191193
const ASSOC: i32;
192194

193195
fn foo() -> impl Sized;
@@ -196,6 +198,7 @@ trait Trait {
196198
impl Trait for () {
197199
type Gat<T> = ();
198200

201+
#[type_const]
199202
const ASSOC: i32 = 3;
200203

201204
fn foo() {}

0 commit comments

Comments
 (0)