Auto merge of #77557 - Dylan-DPC:rollup-aib9ptp, r=Dylan-DPC
Rollup of 11 pull requests Successful merges: - #75853 (Use more intra-doc-links in `core::fmt`) - #75928 (Remove trait_selection error message in specific case) - #76329 (Add check for doc alias attribute at crate level) - #77219 (core::global_allocator docs link to std::alloc::GlobalAlloc) - #77395 (BTreeMap: admit the existence of leaf edges in comments) - #77407 (Improve build-manifest to work with the improved promote-release) - #77426 (Include scope id in SocketAddrV6::Display) - #77439 (Fix missing diagnostic span for `impl Trait` with const generics, and add various tests for `min_const_generics` and `const_generics`) - #77471 (BTreeMap: refactoring around edges, missed spots) - #77512 (Allow `Abort` terminators in all const-contexts) - #77514 (Replace some once(x).chain(once(y)) with [x, y] IntoIter) Failed merges: r? `@ghost`
This commit is contained in:
commit
efbaa41306
116 changed files with 1643 additions and 659 deletions
|
@ -41,18 +41,6 @@ pub trait NonConstOp: std::fmt::Debug {
|
|||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx>;
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Abort;
|
||||
impl NonConstOp for Abort {
|
||||
fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
|
||||
mcf_status_in_item(ccx)
|
||||
}
|
||||
|
||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||
mcf_build_error(ccx, span, "abort is not stable in const fn")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct FloatingPointOp;
|
||||
impl NonConstOp for FloatingPointOp {
|
||||
|
|
|
@ -434,11 +434,13 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
|
|||
fn visit_basic_block_data(&mut self, bb: BasicBlock, block: &BasicBlockData<'tcx>) {
|
||||
trace!("visit_basic_block_data: bb={:?} is_cleanup={:?}", bb, block.is_cleanup);
|
||||
|
||||
// Just as the old checker did, we skip const-checking basic blocks on the unwind path.
|
||||
// These blocks often drop locals that would otherwise be returned from the function.
|
||||
// We don't const-check basic blocks on the cleanup path since we never unwind during
|
||||
// const-eval: a panic causes an immediate compile error. In other words, cleanup blocks
|
||||
// are unreachable during const-eval.
|
||||
//
|
||||
// FIXME: This shouldn't be unsound since a panic at compile time will cause a compiler
|
||||
// error anyway, but maybe we should do more here?
|
||||
// We can't be more conservative (e.g., by const-checking cleanup blocks anyways) because
|
||||
// locals that would never be dropped during normal execution are sometimes dropped during
|
||||
// unwinding, which means backwards-incompatible live-drop errors.
|
||||
if block.is_cleanup {
|
||||
return;
|
||||
}
|
||||
|
@ -874,12 +876,16 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
|
|||
}
|
||||
|
||||
TerminatorKind::InlineAsm { .. } => self.check_op(ops::InlineAsm),
|
||||
TerminatorKind::Abort => self.check_op(ops::Abort),
|
||||
|
||||
TerminatorKind::GeneratorDrop | TerminatorKind::Yield { .. } => {
|
||||
self.check_op(ops::Generator(hir::GeneratorKind::Gen))
|
||||
}
|
||||
|
||||
TerminatorKind::Abort => {
|
||||
// Cleanup blocks are skipped for const checking (see `visit_basic_block_data`).
|
||||
span_bug!(self.span, "`Abort` terminator outside of cleanup block")
|
||||
}
|
||||
|
||||
TerminatorKind::Assert { .. }
|
||||
| TerminatorKind::FalseEdge { .. }
|
||||
| TerminatorKind::FalseUnwind { .. }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue