Function item should not be used as const arg#157962
Conversation
…ef const after scheduling. That works only when a later phase emits a real diagnostics. For function item (associated fn), the lowering needs parent trait and self args.
|
HIR ty lowering was modified cc @fmease |
|
|
| Res::Def(DefKind::AssocFn, _) => { | ||
| let guar = | ||
| self.dcx().span_err(span, "function items cannot be used as const arguments"); | ||
| Const::new_error(tcx, guar) | ||
| } | ||
| // FIXME(const_generics): create real const to allow fn items as const paths | ||
| Res::Def(DefKind::Fn | DefKind::AssocFn, did) => { | ||
| Res::Def(DefKind::Fn, did) => { |
There was a problem hiding this comment.
Previous both free function and associated function, where lowering to zero_sized fn def which would later emit diagnostics, but to lower the assoc it required the parent trait. This now emits an error, instead of lowering.
This comment has been minimized.
This comment has been minimized.
|
This PR changes a file inside |
|
in theory it should be possible to properly lower the path in a way that doesnt ICE and use that for recovering. I would prefer to do that if possible since eventually we do actually want to support function item types in const generics can you try and figure out the right way to paths to lower associated functions? thx :3 |
|
@rustbot author |
closes: #138088
r? @BoxyUwU