Open
Description
It seems like the suggestion uses span_to_snippet since using macros gives weird results. The errors themselves are due to #120905. Playground:
#![feature(associated_const_equality)]
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
macro_rules! p {
($x:ident) => {
<Self::Params as Parameters>::$x
}
}
trait Container {
type Params: Parameters;
fn get(&self) -> Box<dyn Element<Params = Self::Params>>;
}
trait Element {
type Params: Parameters;
fn stuff(&self) -> [f32; p!(N)];
}
trait Parameters {
const N: usize;
fn info(&self) -> [i32; Self::N];
}
fn process<C, P, const N: usize>(c: C, p: P)
where
C: Container<Params = P>,
P: Parameters<N = { N }>,
{
analyze(c.get().stuff(), p.info());
}
fn analyze<const N: usize>(_stuff: [f32; N], _info: [i32; N]) {
todo!()
}
Error:
error: unconstrained generic constant
--> src/lib.rs:34:21
|
34 | analyze(c.get().stuff(), p.info());
| ^^^^^
|
note: required by a bound in `Element::stuff`
--> src/lib.rs:7:9
|
7 | <Self::Params as Parameters>::$x
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Element::stuff`
...
20 | fn stuff(&self) -> [f32; p!(N)];
| ----- ----- in this macro invocation
| |
| required by a bound in this associated function
= note: this error originates in the macro `p` (in Nightly builds, run with -Z macro-backtrace for more info)
help: try adding a `where` bound
|
32 | P: Parameters<N = { N }>, [(); <Self::Params as Parameters>::$x]:
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: unconstrained generic constant
--> src/lib.rs:34:32
|
34 | analyze(c.get().stuff(), p.info());
| ^^^^
|
note: required by a bound in `Parameters::info`
--> src/lib.rs:26:29
|
26 | fn info(&self) -> [i32; Self::N];
| ^^^^^^^ required by this bound in `Parameters::info`
help: try adding a `where` bound
|
32 | P: Parameters<N = { N }>, [(); Self::N]:
| ~~~~~~~~~~~~~~~~
error: unconstrained generic constant
--> src/lib.rs:34:5
|
34 | analyze(c.get().stuff(), p.info());
| ^^^^^^^
|
note: required by a bound in `Element::stuff`
--> src/lib.rs:7:9
|
7 | <Self::Params as Parameters>::$x
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Element::stuff`
...
20 | fn stuff(&self) -> [f32; p!(N)];
| ----- ----- in this macro invocation
| |
| required by a bound in this associated function
= note: this error originates in the macro `p` (in Nightly builds, run with -Z macro-backtrace for more info)
help: try adding a `where` bound
|
32 | P: Parameters<N = { N }>, [(); <Self::Params as Parameters>::$x]:
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error[E0308]: mismatched types
--> src/lib.rs:34:30
|
34 | analyze(c.get().stuff(), p.info());
| ^^^^^^^^ expected `<Self::Params as Parameters>::$x`, found `Self::N`
|
= note: expected constant `<Self::Params as Parameters>::$x`
found constant `Self::N`