Skip to content

Commit f5d85b4

Browse files
committed
bless tests
1 parent 4b5a424 commit f5d85b4

9 files changed

Lines changed: 81 additions & 13 deletions

tests/ui/const-generics/associated-const-bindings/dyn-compat-const-projection-behind-trait-alias-mentions-self.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ trait Trait {
1616
struct Hold<T: ?Sized>(T);
1717

1818
trait Bound = Trait<Y = { Hold::<Self> }>;
19+
//~^ ERROR the constant `Hold::<Self>` is not of type `i32`
1920

2021
fn main() {
2122
let _: dyn Bound; //~ ERROR associated constant binding in trait object type mentions `Self`
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1+
error: the constant `Hold::<Self>` is not of type `i32`
2+
--> $DIR/dyn-compat-const-projection-behind-trait-alias-mentions-self.rs:18:21
3+
|
4+
LL | trait Bound = Trait<Y = { Hold::<Self> }>;
5+
| ^^^^^^^^^^^^^^^^^^^^ expected `i32`, found struct constructor
6+
|
7+
note: required by a const generic parameter in `Bound`
8+
--> $DIR/dyn-compat-const-projection-behind-trait-alias-mentions-self.rs:18:21
9+
|
10+
LL | trait Bound = Trait<Y = { Hold::<Self> }>;
11+
| ^^^^^^^^^^^^^^^^^^^^ required by this const generic parameter in `Bound`
12+
113
error: associated constant binding in trait object type mentions `Self`
2-
--> $DIR/dyn-compat-const-projection-behind-trait-alias-mentions-self.rs:21:12
14+
--> $DIR/dyn-compat-const-projection-behind-trait-alias-mentions-self.rs:22:12
315
|
416
LL | trait Bound = Trait<Y = { Hold::<Self> }>;
517
| -------------------- this binding mentions `Self`
618
...
719
LL | let _: dyn Bound;
820
| ^^^^^^^^^ contains a mention of `Self`
921

10-
error: aborting due to 1 previous error
22+
error: aborting due to 2 previous errors
1123

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//! Check associated const binding with escaping bound vars doesn't cause ICE
2+
//! (#151642)
3+
//@ check-pass
4+
5+
#![feature(min_generic_const_args)]
6+
#![expect(incomplete_features)]
7+
8+
trait Trait2<'a> { #[type_const] const ASSOC: i32; }
9+
fn g(_: for<'a> fn(Box<dyn Trait2<'a, ASSOC = 10>>)) {}
10+
11+
fn main() {}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
//@ known-bug: unknown
2-
//@ check-pass
1+
//! Check that we correctly handle associated const bindings
2+
//! in `impl Trait` where the RHS is a const param (#151642).
33
44
#![feature(min_generic_const_args)]
55
#![expect(incomplete_features)]
66

77
trait Trait { #[type_const] const CT: bool; }
88

9-
// FIXME: this should yield a type mismatch (`bool` v `i32`)
109
fn f<const N: i32>(_: impl Trait<CT = { N }>) {}
11-
10+
//~^ ERROR the constant `N` is not of type `bool`
1211
fn main() {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: the constant `N` is not of type `bool`
2+
--> $DIR/wf-mismatch-1.rs:9:34
3+
|
4+
LL | fn f<const N: i32>(_: impl Trait<CT = { N }>) {}
5+
| ^^^^^^^^^^ expected `bool`, found `i32`
6+
|
7+
note: required by a const generic parameter in `f`
8+
--> $DIR/wf-mismatch-1.rs:9:34
9+
|
10+
LL | fn f<const N: i32>(_: impl Trait<CT = { N }>) {}
11+
| ^^^^^^^^^^ required by this const generic parameter in `f`
12+
13+
error: aborting due to 1 previous error
14+
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
//@ known-bug: unknown
2-
//@ check-pass
1+
//! Check that we correctly handle associated const bindings
2+
//! in `dyn Trait` where the RHS is a const param (#151642).
33
44
#![feature(min_generic_const_args)]
55
#![expect(incomplete_features)]
66

77
trait Trait { #[type_const] const CT: bool; }
88

99
fn f<const N: i32>() {
10-
let _: dyn Trait<CT = { N }>; // FIXME: this should yield a type mismatch (`bool` v `i32`)
10+
let _: dyn Trait<CT = { N }>;
11+
//~^ ERROR the constant `N` is not of type `bool`
1112
}
1213
fn main() {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: the constant `N` is not of type `bool`
2+
--> $DIR/wf-mismatch-2.rs:10:12
3+
|
4+
LL | let _: dyn Trait<CT = { N }>;
5+
| ^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `i32`
6+
7+
error: aborting due to 1 previous error
8+
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//@ known-bug: unknown
2-
//@ check-pass
1+
//! Check that we correctly handle associated const bindings
2+
//! where the RHS is a normalizable const projection (#151642).
33
44
#![feature(min_generic_const_args)]
55
#![expect(incomplete_features)]
@@ -9,7 +9,9 @@ trait Trait { #[type_const] const CT: bool; }
99
trait Bound { #[type_const] const N: u32; }
1010
impl Bound for () { #[type_const] const N: u32 = 0; }
1111

12-
fn f() { let _: dyn Trait<CT = { <() as Bound>::N }>; } // FIXME
13-
fn g(_: impl Trait<CT = { <() as Bound>::N }>) {} // FIXME
12+
fn f() { let _: dyn Trait<CT = { <() as Bound>::N }>; }
13+
//~^ ERROR the constant `0` is not of type `bool`
14+
fn g(_: impl Trait<CT = { <() as Bound>::N }>) {}
15+
//~^ ERROR the constant `0` is not of type `bool`
1416

1517
fn main() {}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error: the constant `0` is not of type `bool`
2+
--> $DIR/wf-mismatch-3.rs:14:20
3+
|
4+
LL | fn g(_: impl Trait<CT = { <() as Bound>::N }>) {}
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `u32`
6+
|
7+
note: required by a const generic parameter in `g`
8+
--> $DIR/wf-mismatch-3.rs:14:20
9+
|
10+
LL | fn g(_: impl Trait<CT = { <() as Bound>::N }>) {}
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this const generic parameter in `g`
12+
13+
error: the constant `0` is not of type `bool`
14+
--> $DIR/wf-mismatch-3.rs:12:17
15+
|
16+
LL | fn f() { let _: dyn Trait<CT = { <() as Bound>::N }>; }
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `u32`
18+
19+
error: aborting due to 2 previous errors
20+

0 commit comments

Comments
 (0)