Instead of using a visitor in typeck, we just check, whenever lowering a use of a param, whether the parent item is an MCG anon const during hir ty lowering (and instantiate_value_path). If so, we report an error since MCG anon consts should never be able to use generics. All other kinds of anon consts are at least syntactically allowed to use generic params. We use a `TypeFolder` to accomplish this; this way, we look at the fully explicit semantic representation of the type/const/whatever and don't miss subtle cases like `Self` type aliases.
14 lines
432 B
Text
14 lines
432 B
Text
error: generic `Self` types are currently not permitted in anonymous constants
|
|
--> $DIR/selftyalias-containing-param.rs:7:37
|
|
|
|
|
LL | fn foo() -> [(); const { let _: Self = loop {}; 1 }] {
|
|
| ^^^^
|
|
|
|
|
note: not a concrete type
|
|
--> $DIR/selftyalias-containing-param.rs:6:22
|
|
|
|
|
LL | impl<const N: usize> S<N> {
|
|
| ^^^^
|
|
|
|
error: aborting due to 1 previous error
|
|
|