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.
8 lines
239 B
Text
8 lines
239 B
Text
error: generic parameters may not be used in const operations
|
|
--> $DIR/selftyparam.rs:5:37
|
|
|
|
|
LL | fn foo() -> [(); const { let _: Self; 1 }];
|
|
| ^^^^
|
|
|
|
error: aborting due to 1 previous error
|
|
|