Closed
Description
#![feature(adt_const_params)]
#![feature(const_type_name)]
#![allow(incomplete_features)]
pub trait True {}
pub struct Equal<const A: &'static str, const B: &'static str>;
impl<const A: &'static str> True for Equal<{A}, {A}> {}
pub fn assert<T: True>(_: T) {}
fn main() {
assert(Equal::<{std::any::type_name::<[u32; 0]>()}, "[u32; 0]">);
}
$ rustc t.rs
$ rustc t.rs -Zverbose
error[E0277]: the trait bound `Equal<Const(Value(Slice { data: Allocation { bytes: [91, 117, 51, 50, 59, 32, 67, 111, 110, 115, 116, 32, 123, 32, 116, 121, 58, 32, 117, 115, 105, 122, 101, 44, 32, 118, 97, 108, 58, 32, 86, 97, 108, 117, 101, 40, 83, 99, 97, 108, 97, 114, 40, 48, 120, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 41, 41, 32, 125, 93], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [18446744073709551615, 3], len: Size { raw: 66 } }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 66 }): &ReStatic str), Const(Value(Slice { data: Allocation { bytes: [91, 117, 51, 50, 59, 32, 48, 93], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [255], len: Size { raw: 8 } }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 8 }): &ReStatic str)>: True` is not satisfied
--> t.rs:14:12
|
14 | assert(Equal::<{std::any::type_name::<[u32; 0]>()}, "[u32; 0]">);
| ------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `True` is not implemented for `Equal<Const(Value(Slice { data: Allocation { bytes: [91, 117, 51, 50, 59, 32, 67, 111, 110, 115, 116, 32, 123, 32, 116, 121, 58, 32, 117, 115, 105, 122, 101, 44, 32, 118, 97, 108, 58, 32, 86, 97, 108, 117, 101, 40, 83, 99, 97, 108, 97, 114, 40, 48, 120, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 41, 41, 32, 125, 93], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [18446744073709551615, 3], len: Size { raw: 66 } }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 66 }): &ReStatic str), Const(Value(Slice { data: Allocation { bytes: [91, 117, 51, 50, 59, 32, 48, 93], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [255], len: Size { raw: 8 } }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 8 }): &ReStatic str)>`
| |
| required by a bound introduced by this call
|
= help: the following implementations were found:
<Equal<Const(Param(A/#0): &ReStatic str), Const(Param(A/#0): &ReStatic str)> as True>
note: required by a bound in `assert`
--> t.rs:11:18
|
11 | pub fn assert<T: True>(_: T) {}
| ^^^^ required by this bound in `assert`
error: aborting due to previous error
cc #63084
Metadata
Metadata
Assignees
Labels
Area: Constant evaluation, covers all const contexts (static, const fn, ...)Area: const generics (parameters and arguments)Category: This is a bug.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.