pub fn non_const<O: NonConstOp>(ccx: &ConstCx<'_, '_>, op: O, span: Span) {
    debug!("illegal_op: op={:?}", op);

    let gate = match op.status_in_item(ccx) {
        Status::Allowed => return,

        Status::Unstable(gate) if ccx.tcx.features().enabled(gate) => {
            let unstable_in_stable = ccx.const_kind() == hir::ConstContext::ConstFn
                && ccx.tcx.features().enabled(sym::staged_api)
                && !ccx.tcx.has_attr(ccx.def_id.to_def_id(), sym::rustc_const_unstable)
                && !super::allow_internal_unstable(ccx.tcx, ccx.def_id.to_def_id(), gate);

            if unstable_in_stable {
                ccx.tcx.sess
                    .struct_span_err(span, &format!("`#[feature({})]` cannot be depended on in a const-stable function", gate.as_str()))
                    .span_suggestion(
                        ccx.body.span,
                        "if it is not part of the public API, make this function unstably const",
                        concat!(r#"#[rustc_const_unstable(feature = "...", issue = "...")]"#, '\n').to_owned(),
                        Applicability::HasPlaceholders,
                    )
                    .help("otherwise `#[allow_internal_unstable]` can be used to bypass stability checks")
                    .emit();
            }

            return;
        }

        Status::Unstable(gate) => Some(gate),
        Status::Forbidden => None,
    };

    if ccx.tcx.sess.opts.debugging_opts.unleash_the_miri_inside_of_you {
        ccx.tcx.sess.miri_unleashed_feature(span, gate);
        return;
    }

    op.emit_error(ccx, span);
}
/// Emits an error if `op` is not allowed in the given const context.
Emits an error if `op` is not allowed in the given const context.
Emits an error if ` op ` is not allowed in the given const context .
pub fn non_const<O: NonConstOp>(ccx: &ConstCx<'_, '_>, op: O, span: Span) {
    debug!("illegal_op: op={:?}", op);
    let gate = match op.status_in_item(ccx) {
        Status::Allowed => return,
        Status::Unstable(gate) if ccx.tcx.features().enabled(gate) => {
            let unstable_in_stable = ccx.const_kind() == hir::ConstContext::ConstFn
                && ccx.tcx.features().enabled(sym::staged_api)
                && !ccx.tcx.has_attr(ccx.def_id.to_def_id(), sym::rustc_const_unstable)
                && !super::allow_internal_unstable(ccx.tcx, ccx.def_id.to_def_id(), gate);
            if unstable_in_stable {
                ccx.tcx.sess
                    .struct_span_err(span, &format!("`#[feature({})]` cannot be depended on in a const-stable function", gate.as_str()))
                    .span_suggestion(
                        ccx.body.span,
                        "if it is not part of the public API, make this function unstably const",
                        concat!(r#"#[rustc_const_unstable(feature = "...", issue = "...")]"#, '\n').to_owned(),
                        Applicability::HasPlaceholders,
                    )
                    .help("otherwise `#[allow_internal_unstable]` can be used to bypass stability checks")
                    .emit();
            }
            return;
        }
        Status::Unstable(gate) => Some(gate),
        Status::Forbidden => None,
    };
    if ccx.tcx.sess.opts.debugging_opts.unleash_the_miri_inside_of_you {
        ccx.tcx.sess.miri_unleashed_feature(span, gate);
        return;
    }
    op.emit_error(ccx, span);
}
pub fn non_const < O : NonConstOp > ( ccx : & ConstCx < ' _ , ' _ > , op : O , span : Span ) { debug ! ( " " op ) ; let gate = match op . status_in_item ( ccx ) { Status :: Allowed => return , Status :: Unstable ( gate ) if ccx . tcx . features ( ) . enabled ( gate ) => { let unstable_in_stable = ccx . const_kind ( ) == hir :: ConstContext :: ConstFn && ccx . tcx . features ( ) . enabled ( sym :: staged_api ) && ! ccx . tcx . has_attr ( ccx . def_id . to_def_id ( ) , sym :: rustc_const_unstable ) && ! super :: allow_internal_unstable ( ccx . tcx , ccx . def_id . to_def_id ( ) , gate ) ; if unstable_in_stable { ccx . tcx . sess . struct_span_err ( span , & format ! ( " " gate as_str ( ) ) ) . span_suggestion ( ccx . body . span , " " , concat ! ( r#"#[rustc_const_unstable(feature = "...", issue = "...")]"# '\n' ) . to_owned ( ) , Applicability :: HasPlaceholders , ) . help ( " " ) . emit ( ) ; } return ; } Status :: Unstable ( gate ) => Some ( gate ) , Status :: Forbidden => None , } ; if ccx . tcx . sess . opts . debugging_opts . unleash_the_miri_inside_of_you { ccx . tcx . sess . miri_unleashed_feature ( span , gate ) ; return ; } op . emit_error ( ccx , span ) ; }
Emits an error if `op` is not allowed in the given const context.
Emits an error if ` op ` is not allowed in the given const context .
ccx
&ConstCx<'_, '_>
op
O
span
Span