Allow refrence cycles in constants

Constants cannot be dropped or modified and therefore allowing refrence cycles should be fine, but code like this fails to compile with the error "cycle used when processing main::CONST". If there is a problem with this proposal I think the error message and error index should be clarified to explain it better.

struct Struct(&'static Self);
const CONST: Struct = Struct(&CONST);
1 Like

Think of const values more like a kind of macro that gets inlined wherever the name is mentioned -- then it makes more sense that a cycle like this is not permitted. A static will work for this case.

6 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.