Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a76a7e9

Browse files
committedMay 6, 2025
Fix tests
1 parent d91b9ec commit a76a7e9

19 files changed

+356
-92
lines changed
 

‎tests/crashes/133199.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎tests/crashes/136894.rs

Lines changed: 0 additions & 8 deletions
This file was deleted.

‎tests/crashes/137813.rs

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![feature(generic_arg_infer, associated_const_equality, generic_const_items)]
2+
#![expect(incomplete_features)]
3+
4+
// Regression test for #133066 where we would try to evaluate `<() as Foo>::ASSOC<_>` even
5+
// though it contained inference variables, which would cause ICEs.
6+
7+
trait Foo {
8+
const ASSOC<const N: u32>: u32;
9+
}
10+
11+
impl Foo for () {
12+
const ASSOC<const N: u32>: u32 = N;
13+
}
14+
15+
fn bar<const N: u32, T: Foo<ASSOC<N> = 10>>() {}
16+
17+
fn main() {
18+
bar::<_, ()>();
19+
//~^ ERROR: type mismatch resolving `<() as Foo>::ASSOC<_> == 10`
20+
21+
// FIXME(mgca):
22+
// FIXME(associated_const_equality):
23+
// This ought to start compiling once const items are aliases rather than bodies
24+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0271]: type mismatch resolving `<() as Foo>::ASSOC<_> == 10`
2+
--> $DIR/equality_bound_with_infer.rs:18:14
3+
|
4+
LL | bar::<_, ()>();
5+
| ^^ expected `10`, found `<() as Foo>::ASSOC::<_>`
6+
|
7+
= note: expected constant `10`
8+
found constant `<() as Foo>::ASSOC::<_>`
9+
note: required by a bound in `bar`
10+
--> $DIR/equality_bound_with_infer.rs:15:29
11+
|
12+
LL | fn bar<const N: u32, T: Foo<ASSOC<N> = 10>>() {}
13+
| ^^^^^^^^^^^^^ required by this bound in `bar`
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0271`.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// regression test for #137813 where we would assume all constants in the type system
2+
// cannot contain inference variables, even though associated const equality syntax
3+
// was still lowered without the feature gate enabled.
4+
5+
trait AssocConst {
6+
const A: u8;
7+
}
8+
9+
impl<T> AssocConst for (T,) {
10+
const A: u8 = 0;
11+
}
12+
13+
trait Trait {}
14+
15+
impl<U> Trait for () where (U,): AssocConst<A = { 0 }> {}
16+
//~^ ERROR associated const equality is incomplete
17+
//~| ERROR the type parameter `U` is not constrained by the impl trait
18+
19+
fn foo()
20+
where
21+
(): Trait,
22+
//~^ ERROR type mismatch resolving
23+
{
24+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
error[E0658]: associated const equality is incomplete
2+
--> $DIR/unconstrained_impl_param.rs:15:45
3+
|
4+
LL | impl<U> Trait for () where (U,): AssocConst<A = { 0 }> {}
5+
| ^^^^^^^^^
6+
|
7+
= note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information
8+
= help: add `#![feature(associated_const_equality)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
12+
--> $DIR/unconstrained_impl_param.rs:15:6
13+
|
14+
LL | impl<U> Trait for () where (U,): AssocConst<A = { 0 }> {}
15+
| ^ unconstrained type parameter
16+
17+
error[E0271]: type mismatch resolving `<(_,) as AssocConst>::A == 0`
18+
--> $DIR/unconstrained_impl_param.rs:21:5
19+
|
20+
LL | (): Trait,
21+
| ^^^^^^^^^ expected `0`, found `<(_,) as AssocConst>::A`
22+
|
23+
= note: expected constant `0`
24+
found constant `<(_,) as AssocConst>::A`
25+
note: required for `()` to implement `Trait`
26+
--> $DIR/unconstrained_impl_param.rs:15:9
27+
|
28+
LL | impl<U> Trait for () where (U,): AssocConst<A = { 0 }> {}
29+
| ^^^^^ ^^ --------- unsatisfied trait bound introduced here
30+
= help: see issue #48214
31+
help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
32+
|
33+
LL + #![feature(trivial_bounds)]
34+
|
35+
36+
error: aborting due to 3 previous errors
37+
38+
Some errors have detailed explanations: E0207, E0271, E0658.
39+
For more information about an error, try `rustc --explain E0207`.

‎tests/crashes/auxiliary/aux133199.rs renamed to ‎tests/ui/const-generics/generic_const_exprs/auxiliary/cross-crate-2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#![allow(incomplete_features)]
22
#![feature(generic_const_exprs)]
33

4-
pub struct FixedBitSet<const N: usize>;
4+
pub struct Foo<const N: usize>;
55

6-
impl<const N: usize> FixedBitSet<N>
6+
impl<const N: usize> Foo<N>
77
where
88
[u8; N.div_ceil(8)]: Sized,
99
{
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//@ check-pass
2+
//@ aux-build: cross-crate-2.rs
3+
4+
extern crate cross_crate_2;
5+
6+
use cross_crate_2::Foo;
7+
8+
fn main() {
9+
Foo::<7>::new();
10+
}

‎tests/ui/const-generics/generic_const_exprs/dependence_lint.full.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: generic parameters may not be used in const operations
2-
--> $DIR/dependence_lint.rs:14:32
2+
--> $DIR/dependence_lint.rs:15:32
33
|
44
LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce
55
| ^ cannot perform const operation using `T`
@@ -8,7 +8,7 @@ LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce
88
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
99

1010
error: generic parameters may not be used in const operations
11-
--> $DIR/dependence_lint.rs:21:37
11+
--> $DIR/dependence_lint.rs:22:37
1212
|
1313
LL | let _: [u8; if true { size_of::<T>() } else { 3 }]; // error on stable, error with gce
1414
| ^ cannot perform const operation using `T`
@@ -27,7 +27,7 @@ LL | [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_
2727
= note: `#[warn(const_evaluatable_unchecked)]` on by default
2828

2929
warning: cannot use constants which depend on generic parameters in types
30-
--> $DIR/dependence_lint.rs:17:9
30+
--> $DIR/dependence_lint.rs:18:9
3131
|
3232
LL | [0; if false { size_of::<T>() } else { 3 }]; // lint on stable, error with gce
3333
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

‎tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,27 @@ help: try adding a `where` bound
99
LL | fn foo<T>() where [(); size_of::<*mut T>()]: {
1010
| ++++++++++++++++++++++++++++++++
1111

12+
error: unconstrained generic constant
13+
--> $DIR/dependence_lint.rs:10:5
14+
|
15+
LL | [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_exprs`
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^
17+
|
18+
help: try adding a `where` bound
19+
|
20+
LL | fn foo<T>() where [(); size_of::<*mut T>()]: {
21+
| ++++++++++++++++++++++++++++++++
22+
1223
error: overly complex generic constant
13-
--> $DIR/dependence_lint.rs:17:9
24+
--> $DIR/dependence_lint.rs:18:9
1425
|
1526
LL | [0; if false { size_of::<T>() } else { 3 }]; // lint on stable, error with gce
1627
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ control flow is not supported in generic constants
1728
|
1829
= help: consider moving this anonymous constant into a `const` function
1930

2031
error: unconstrained generic constant
21-
--> $DIR/dependence_lint.rs:14:12
32+
--> $DIR/dependence_lint.rs:15:12
2233
|
2334
LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce
2435
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -29,12 +40,12 @@ LL | fn foo<T>() where [(); size_of::<*mut T>()]: {
2940
| ++++++++++++++++++++++++++++++++
3041

3142
error: overly complex generic constant
32-
--> $DIR/dependence_lint.rs:21:17
43+
--> $DIR/dependence_lint.rs:22:17
3344
|
3445
LL | let _: [u8; if true { size_of::<T>() } else { 3 }]; // error on stable, error with gce
3546
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ control flow is not supported in generic constants
3647
|
3748
= help: consider moving this anonymous constant into a `const` function
3849

39-
error: aborting due to 4 previous errors
50+
error: aborting due to 5 previous errors
4051

‎tests/ui/const-generics/generic_const_exprs/dependence_lint.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ use std::mem::size_of;
99
fn foo<T>() {
1010
[0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_exprs`
1111
//[gce]~^ ERROR unconstrained
12-
//[full]~^^ WARNING cannot use constants
12+
//[gce]~| ERROR unconstrained generic constant
13+
//[full]~^^^ WARNING cannot use constants
1314
//[full]~| WARNING this was previously accepted
1415
let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce
1516
//[full]~^ ERROR generic parameters may not be used

‎tests/ui/const-generics/generic_const_exprs/different-fn.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ error[E0308]: mismatched types
22
--> $DIR/different-fn.rs:10:5
33
|
44
LL | [0; size_of::<Foo<T>>()]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected `size_of::<T>()`, found `0`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected `size_of::<T>()`, found `size_of::<Foo<T>>()`
66
|
77
= note: expected constant `size_of::<T>()`
8-
found constant `0`
8+
found constant `size_of::<Foo<T>>()`
99

1010
error: unconstrained generic constant
1111
--> $DIR/different-fn.rs:10:9
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@ check-pass
2+
3+
// regression test for #136894.
4+
// I (BoxyUwU) don't know what the underlying cause was here
5+
6+
#![feature(generic_const_exprs)]
7+
#![crate_type = "lib"]
8+
#![allow(incomplete_features, dead_code)]
9+
10+
struct X<T>([(); f::<T>()])
11+
where
12+
[(); f::<T>()]:;
13+
14+
const fn f<T>() -> usize {
15+
panic!()
16+
}

‎tests/ui/const-generics/issues/issue-71202.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ impl<T: Copy> DataHolder<T> {
2525
}
2626

2727
<IsCopy<T>>::VALUE
28-
} as usize] = []; //~ ERROR unconstrained generic constant
28+
} as usize] = [];
29+
//~^ ERROR unconstrained generic constant
30+
//~^^ ERROR mismatched types
2931
}
3032

3133
fn main() {}

‎tests/ui/const-generics/issues/issue-71202.stderr

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,49 @@ LL + <IsCopy<T>>::VALUE
5959
LL ~ } as usize]: = [];
6060
|
6161

62-
error: aborting due to 2 previous errors
62+
error[E0308]: mismatched types
63+
--> $DIR/issue-71202.rs:28:19
64+
|
65+
LL | } as usize] = [];
66+
| ^^ expected `1 - {
67+
trait NotCopy {
68+
const VALUE: bool = false;
69+
}
70+
71+
impl<__Type: ?Sized> NotCopy for __Type {}
72+
73+
struct IsCopy<__Type: ?Sized>(PhantomData<__Type>);
74+
75+
impl<__Type> IsCopy<__Type>
76+
where
77+
__Type: Sized + Copy,
78+
{
79+
const VALUE: bool = true;
80+
}
81+
82+
<IsCopy<T>>::VALUE
83+
} as usize`, found `0`
84+
|
85+
= note: expected constant `1 - {
86+
trait NotCopy {
87+
const VALUE: bool = false;
88+
}
89+
90+
impl<__Type: ?Sized> NotCopy for __Type {}
91+
92+
struct IsCopy<__Type: ?Sized>(PhantomData<__Type>);
93+
94+
impl<__Type> IsCopy<__Type>
95+
where
96+
__Type: Sized + Copy,
97+
{
98+
const VALUE: bool = true;
99+
}
100+
101+
<IsCopy<T>>::VALUE
102+
} as usize`
103+
found constant `0`
104+
105+
error: aborting due to 3 previous errors
63106

107+
For more information about this error, try `rustc --explain E0308`.

‎tests/ui/const-generics/issues/issue-83765.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33

44
trait TensorDimension {
55
const DIM: usize;
6-
//~^ ERROR cycle detected when resolving instance
7-
//~| ERROR cycle detected when resolving instance
8-
// FIXME Given the current state of the compiler its expected that we cycle here,
9-
// but the cycle is still wrong.
106
const ISSCALAR: bool = Self::DIM == 0;
117
fn is_scalar(&self) -> bool {
128
Self::ISSCALAR
@@ -49,19 +45,25 @@ impl<'a, T: Broadcastable, const DIM: usize> TensorDimension for LazyUpdim<'a, T
4945

5046
impl<'a, T: Broadcastable, const DIM: usize> TensorSize for LazyUpdim<'a, T, { T::DIM }, DIM> {
5147
fn size(&self) -> [usize; DIM] {
48+
//~^ ERROR: method not compatible with trait
5249
self.size
5350
}
5451
}
5552

5653
impl<'a, T: Broadcastable, const DIM: usize> Broadcastable for LazyUpdim<'a, T, { T::DIM }, DIM> {
5754
type Element = T::Element;
5855
fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> {
56+
//~^ ERROR: method not compatible with trait
5957
assert!(DIM >= T::DIM);
6058
if !self.inbounds(index) {
59+
//~^ ERROR: unconstrained generic constant
60+
//~| ERROR: mismatched types
6161
return None;
6262
}
6363
let size = self.size();
64+
//~^ ERROR: unconstrained generic constant
6465
let newindex: [usize; T::DIM] = Default::default();
66+
//~^ ERROR: the trait bound
6567
self.reference.bget(newindex)
6668
}
6769
}
@@ -82,6 +84,8 @@ impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> TensorSi
8284
fn size(&self) -> [usize; DIM] {
8385
//~^ ERROR: method not compatible with trait
8486
self.reference.size()
87+
//~^ ERROR: unconstrained generic constant
88+
//~| ERROR: mismatched types
8589
}
8690
}
8791

@@ -92,6 +96,8 @@ impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> Broadcas
9296
fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> {
9397
//~^ ERROR: method not compatible with trait
9498
self.reference.bget(index).map(&self.closure)
99+
//~^ ERROR: unconstrained generic constant
100+
//~| ERROR: mismatched types
95101
}
96102
}
97103

@@ -100,12 +106,14 @@ impl<T> TensorDimension for Vec<T> {
100106
}
101107
impl<T> TensorSize for Vec<T> {
102108
fn size(&self) -> [usize; 1] {
109+
//~^ ERROR: method not compatible with trait
103110
[self.len()]
104111
}
105112
}
106113
impl<T: Clone> Broadcastable for Vec<T> {
107114
type Element = T;
108115
fn bget(&self, index: [usize; 1]) -> Option<T> {
116+
//~^ ERROR: method not compatible with trait
109117
self.get(index[0]).cloned()
110118
}
111119
}
Lines changed: 137 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,23 @@
1-
error[E0391]: cycle detected when resolving instance `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>::DIM`
2-
--> $DIR/issue-83765.rs:5:5
3-
|
4-
LL | const DIM: usize;
5-
| ^^^^^^^^^^^^^^^^
6-
|
7-
note: ...which requires computing candidate for `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>`...
8-
--> $DIR/issue-83765.rs:4:1
9-
|
10-
LL | trait TensorDimension {
11-
| ^^^^^^^^^^^^^^^^^^^^^
12-
= note: ...which again requires resolving instance `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>::DIM`, completing the cycle
13-
note: cycle used when checking assoc item `<impl at $DIR/issue-83765.rs:50:1: 50:94>::size` is compatible with trait definition
14-
--> $DIR/issue-83765.rs:51:5
1+
error[E0308]: method not compatible with trait
2+
--> $DIR/issue-83765.rs:47:5
153
|
164
LL | fn size(&self) -> [usize; DIM] {
17-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18-
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
19-
20-
error[E0391]: cycle detected when resolving instance `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>::DIM`
21-
--> $DIR/issue-83765.rs:5:5
22-
|
23-
LL | const DIM: usize;
24-
| ^^^^^^^^^^^^^^^^
25-
|
26-
note: ...which requires computing candidate for `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>`...
27-
--> $DIR/issue-83765.rs:4:1
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM`
286
|
29-
LL | trait TensorDimension {
30-
| ^^^^^^^^^^^^^^^^^^^^^
31-
= note: ...which again requires resolving instance `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>::DIM`, completing the cycle
32-
note: cycle used when checking assoc item `<impl at $DIR/issue-83765.rs:56:1: 56:97>::bget` is compatible with trait definition
33-
--> $DIR/issue-83765.rs:58:5
7+
= note: expected constant `Self::DIM`
8+
found constant `DIM`
9+
10+
error[E0308]: method not compatible with trait
11+
--> $DIR/issue-83765.rs:55:5
3412
|
3513
LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> {
36-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
37-
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM`
15+
|
16+
= note: expected constant `Self::DIM`
17+
found constant `DIM`
3818

3919
error[E0308]: method not compatible with trait
40-
--> $DIR/issue-83765.rs:82:5
20+
--> $DIR/issue-83765.rs:84:5
4121
|
4222
LL | fn size(&self) -> [usize; DIM] {
4323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM`
@@ -46,15 +26,135 @@ LL | fn size(&self) -> [usize; DIM] {
4626
found constant `DIM`
4727

4828
error[E0308]: method not compatible with trait
49-
--> $DIR/issue-83765.rs:92:5
29+
--> $DIR/issue-83765.rs:96:5
5030
|
5131
LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> {
5232
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM`
5333
|
5434
= note: expected constant `Self::DIM`
5535
found constant `DIM`
5636

57-
error: aborting due to 4 previous errors
37+
error[E0308]: method not compatible with trait
38+
--> $DIR/issue-83765.rs:108:5
39+
|
40+
LL | fn size(&self) -> [usize; 1] {
41+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `1`
42+
|
43+
= note: expected constant `Self::DIM`
44+
found constant `1`
45+
46+
error[E0308]: method not compatible with trait
47+
--> $DIR/issue-83765.rs:115:5
48+
|
49+
LL | fn bget(&self, index: [usize; 1]) -> Option<T> {
50+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `1`
51+
|
52+
= note: expected constant `Self::DIM`
53+
found constant `1`
54+
55+
error: unconstrained generic constant
56+
--> $DIR/issue-83765.rs:58:13
57+
|
58+
LL | if !self.inbounds(index) {
59+
| ^^^^
60+
|
61+
note: required by a bound in `TensorSize::inbounds`
62+
--> $DIR/issue-83765.rs:14:39
63+
|
64+
LL | fn inbounds(&self, index: [usize; Self::DIM]) -> bool {
65+
| ^^^^^^^^^ required by this bound in `TensorSize::inbounds`
66+
help: try adding a `where` bound
67+
|
68+
LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> where [(); Self::DIM]: {
69+
| ++++++++++++++++++++++
70+
71+
error[E0308]: mismatched types
72+
--> $DIR/issue-83765.rs:58:27
73+
|
74+
LL | if !self.inbounds(index) {
75+
| ^^^^^ expected `Self::DIM`, found `DIM`
76+
|
77+
= note: expected constant `Self::DIM`
78+
found constant `DIM`
79+
80+
error: unconstrained generic constant
81+
--> $DIR/issue-83765.rs:63:25
82+
|
83+
LL | let size = self.size();
84+
| ^^^^
85+
|
86+
note: required by a bound in `TensorSize::size`
87+
--> $DIR/issue-83765.rs:13:31
88+
|
89+
LL | fn size(&self) -> [usize; Self::DIM];
90+
| ^^^^^^^^^ required by this bound in `TensorSize::size`
91+
help: try adding a `where` bound
92+
|
93+
LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> where [(); Self::DIM]: {
94+
| ++++++++++++++++++++++
95+
96+
error[E0277]: the trait bound `[usize; T::DIM]: Default` is not satisfied
97+
--> $DIR/issue-83765.rs:65:41
98+
|
99+
LL | let newindex: [usize; T::DIM] = Default::default();
100+
| ^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `[usize; T::DIM]`
101+
|
102+
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
103+
|
104+
LL | impl<'a, T: Broadcastable, const DIM: usize> Broadcastable for LazyUpdim<'a, T, { T::DIM }, DIM> where [usize; T::DIM]: Default {
105+
| ++++++++++++++++++++++++++++++
106+
107+
error: unconstrained generic constant
108+
--> $DIR/issue-83765.rs:86:24
109+
|
110+
LL | self.reference.size()
111+
| ^^^^
112+
|
113+
note: required by a bound in `TensorSize::size`
114+
--> $DIR/issue-83765.rs:13:31
115+
|
116+
LL | fn size(&self) -> [usize; Self::DIM];
117+
| ^^^^^^^^^ required by this bound in `TensorSize::size`
118+
help: try adding a `where` bound
119+
|
120+
LL | fn size(&self) -> [usize; DIM] where [(); Self::DIM]: {
121+
| ++++++++++++++++++++++
122+
123+
error[E0308]: mismatched types
124+
--> $DIR/issue-83765.rs:86:9
125+
|
126+
LL | self.reference.size()
127+
| ^^^^^^^^^^^^^^^^^^^^^ expected `DIM`, found `Self::DIM`
128+
|
129+
= note: expected constant `DIM`
130+
found constant `Self::DIM`
131+
132+
error: unconstrained generic constant
133+
--> $DIR/issue-83765.rs:98:9
134+
|
135+
LL | self.reference.bget(index).map(&self.closure)
136+
| ^^^^^^^^^^^^^^
137+
|
138+
note: required by a bound in `Broadcastable::bget`
139+
--> $DIR/issue-83765.rs:21:35
140+
|
141+
LL | fn bget(&self, index: [usize; Self::DIM]) -> Option<Self::Element>;
142+
| ^^^^^^^^^ required by this bound in `Broadcastable::bget`
143+
help: try adding a `where` bound
144+
|
145+
LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> where [(); Self::DIM]: {
146+
| ++++++++++++++++++++++
147+
148+
error[E0308]: mismatched types
149+
--> $DIR/issue-83765.rs:98:29
150+
|
151+
LL | self.reference.bget(index).map(&self.closure)
152+
| ^^^^^ expected `Self::DIM`, found `DIM`
153+
|
154+
= note: expected constant `Self::DIM`
155+
found constant `DIM`
156+
157+
error: aborting due to 14 previous errors
58158

59-
Some errors have detailed explanations: E0308, E0391.
60-
For more information about an error, try `rustc --explain E0308`.
159+
Some errors have detailed explanations: E0277, E0308.
160+
For more information about an error, try `rustc --explain E0277`.

‎tests/ui/type-alias-impl-trait/in-where-clause.stderr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ LL | / fn foo() -> Bar
6262
LL | | where
6363
LL | | Bar: Send,
6464
| |______________^
65+
note: ...which requires computing revealed normalized predicates of `foo::{constant#0}`...
66+
--> $DIR/in-where-clause.rs:13:9
67+
|
68+
LL | [0; 1 + 2]
69+
| ^^^^^
6570
= note: ...which requires revealing opaque types in `[Binder { value: TraitPredicate(<Bar as core::marker::Send>, polarity:Positive), bound_vars: [] }]`...
6671
note: ...which requires computing type of `Bar::{opaque#0}`...
6772
--> $DIR/in-where-clause.rs:5:12

0 commit comments

Comments
 (0)
Please sign in to comment.