New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create const block DefIds in typeck instead of ast lowering #124650
base: master
Are you sure you want to change the base?
Conversation
The guarded call will ICE on its own. While this improved diagnostics in the presence of bugs somewhat, it is also a blocker to query feeding of constants. If this case is hit again, we should instead improve diagnostics of the root ICE
…am_attrs` This can cause query cycles in const eval, when const eval checks the ABI of functions, as mir_keys can depend on `typeck` to find all newly generated items (like const blocks)
Some changes occurred in match checking cc @Nadrieril Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Changes to the size of AST and/or HIR nodes. cc @nnethercote |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
Create const block DefIds in typeck instead of ast lowering r? `@ghost` this is a prerequisite for cleaning up pattern types and the range pattern HIR nodes in general. Right now they contain expressions, but they are supposed to only contain constants. In order to generate the anonymous constants lazily during typeck, we need to support generating new items with bodies during typeck in general. Transforming const blocks was the simplest change I could find to allow us to do that (everything else is much more invasive if we haven't already done it for const blocks).
ty::InstanceDef::Item(def) => { | ||
if ecx.tcx.is_ctfe_mir_available(def) { | ||
Ok(ecx.tcx.mir_for_ctfe(def)) | ||
} else if ecx.tcx.def_kind(def) == DefKind::AssocConst { | ||
ecx.tcx.dcx().bug("This is likely a const item that is missing from its impl"); | ||
} else { | ||
// `find_mir_or_eval_fn` checks that this is a const fn before even calling us, | ||
// so this should be unreachable. | ||
let path = ecx.tcx.def_path_str(def); | ||
bug!("trying to call extern function `{path}` at compile-time"); | ||
} | ||
} | ||
ty::InstanceDef::Item(def) => Ok(ecx.tcx.mir_for_ctfe(def)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_ctfe_mir_available invokes mir_keys
, which now invokes typeck, so we'd get cycles
The job Click to see the possible cause of the failure (guessed by this bot)
|
The job Click to see the possible cause of the failure (guessed by this bot)
|
💔 Test failed - checks-actions |
☔ The latest upstream changes (presumably #124401) made this pull request unmergeable. Please resolve the merge conflicts. |
r? @ghost
this is a prerequisite for cleaning up pattern types and the range pattern HIR nodes in general. Right now they contain expressions, but they are supposed to only contain constants. In order to generate the anonymous constants lazily during typeck, we need to support generating new items with bodies during typeck in general. Transforming const blocks was the simplest change I could find to allow us to do that (everything else is much more invasive if we haven't already done it for const blocks).