fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
    assert_eq!(cnum, LOCAL_CRATE);

    rustc_passes::hir_id_validator::check_crate(tcx);

    let sess = tcx.sess;
    let mut entry_point = None;

    sess.time("misc_checking_1", || {
        parallel!(
            {
                entry_point = sess
                    .time("looking_for_entry_point", || rustc_passes::entry::find_entry_point(tcx));

                sess.time("looking_for_plugin_registrar", || {
                    plugin::build::find_plugin_registrar(tcx)
                });

                sess.time("looking_for_derive_registrar", || proc_macro_decls::find(tcx));
            },
            {
                par_iter(&tcx.hir().krate().modules).for_each(|(&module, _)| {
                    let local_def_id = tcx.hir().local_def_id(module);
                    tcx.ensure().check_mod_loops(local_def_id);
                    tcx.ensure().check_mod_attrs(local_def_id);
                    tcx.ensure().check_mod_unstable_api_usage(local_def_id);
                    tcx.ensure().check_mod_const_bodies(local_def_id);
                });
            }
        );
    });

    // passes are timed inside typeck
    typeck::check_crate(tcx)?;

    sess.time("misc_checking_2", || {
        parallel!(
            {
                sess.time("match_checking", || {
                    tcx.par_body_owners(|def_id| {
                        tcx.ensure().check_match(def_id.to_def_id());
                    });
                });
            },
            {
                sess.time("liveness_and_intrinsic_checking", || {
                    par_iter(&tcx.hir().krate().modules).for_each(|(&module, _)| {
                        // this must run before MIR dump, because
                        // "not all control paths return a value" is reported here.
                        //
                        // maybe move the check to a MIR pass?
                        let local_def_id = tcx.hir().local_def_id(module);

                        tcx.ensure().check_mod_liveness(local_def_id);
                        tcx.ensure().check_mod_intrinsics(local_def_id);
                    });
                });
            }
        );
    });

    sess.time("MIR_borrow_checking", || {
        tcx.par_body_owners(|def_id| tcx.ensure().mir_borrowck(def_id));
    });

    sess.time("MIR_effect_checking", || {
        for def_id in tcx.body_owners() {
            mir::transform::check_unsafety::check_unsafety(tcx, def_id);

            if tcx.hir().body_const_context(def_id).is_some() {
                tcx.ensure().mir_drops_elaborated_and_const_checked(def_id);
            }
        }
    });

    sess.time("layout_testing", || layout_test::test_layout(tcx));

    // Avoid overwhelming user with errors if borrow checking failed.
    // I'm not sure how helpful this is, to be honest, but it avoids a
    // lot of annoying errors in the compile-fail tests (basically,
    // lint warnings and so on -- kindck used to do this abort, but
    // kindck is gone now). -nmatsakis
    if sess.has_errors() {
        return Err(ErrorReported);
    }

    sess.time("misc_checking_3", || {
        parallel!(
            {
                tcx.ensure().privacy_access_levels(LOCAL_CRATE);

                parallel!(
                    {
                        tcx.ensure().check_private_in_public(LOCAL_CRATE);
                    },
                    {
                        sess.time("death_checking", || rustc_passes::dead::check_crate(tcx));
                    },
                    {
                        sess.time("unused_lib_feature_checking", || {
                            rustc_passes::stability::check_unused_or_stable_features(tcx)
                        });
                    },
                    {
                        sess.time("lint_checking", || {
                            rustc_lint::check_crate(tcx, || {
                                rustc_lint::BuiltinCombinedLateLintPass::new()
                            });
                        });
                    }
                );
            },
            {
                sess.time("privacy_checking_modules", || {
                    par_iter(&tcx.hir().krate().modules).for_each(|(&module, _)| {
                        tcx.ensure().check_mod_privacy(tcx.hir().local_def_id(module));
                    });
                });
            }
        );
    });

    Ok(())
}
/// Runs the resolution, type-checking, region checking and other
/// miscellaneous analysis passes on the crate.
Runs the resolution, type-checking, region checking and other
miscellaneous analysis passes on the crate.
Runs the resolution type - checking region checking and other miscellaneous analysis passes on the crate .
fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
    assert_eq!(cnum, LOCAL_CRATE);
    rustc_passes::hir_id_validator::check_crate(tcx);
    let sess = tcx.sess;
    let mut entry_point = None;
    sess.time("misc_checking_1", || {
        parallel!(
            {
                entry_point = sess
                    .time("looking_for_entry_point", || rustc_passes::entry::find_entry_point(tcx));
                sess.time("looking_for_plugin_registrar", || {
                    plugin::build::find_plugin_registrar(tcx)
                });
                sess.time("looking_for_derive_registrar", || proc_macro_decls::find(tcx));
            },
            {
                par_iter(&tcx.hir().krate().modules).for_each(|(&module, _)| {
                    let local_def_id = tcx.hir().local_def_id(module);
                    tcx.ensure().check_mod_loops(local_def_id);
                    tcx.ensure().check_mod_attrs(local_def_id);
                    tcx.ensure().check_mod_unstable_api_usage(local_def_id);
                    tcx.ensure().check_mod_const_bodies(local_def_id);
                });
            }
        );
    });
    // passes are timed inside typeck
    typeck::check_crate(tcx)?;
    sess.time("misc_checking_2", || {
        parallel!(
            {
                sess.time("match_checking", || {
                    tcx.par_body_owners(|def_id| {
                        tcx.ensure().check_match(def_id.to_def_id());
                    });
                });
            },
            {
                sess.time("liveness_and_intrinsic_checking", || {
                    par_iter(&tcx.hir().krate().modules).for_each(|(&module, _)| {
                        // this must run before MIR dump, because
                        // "not all control paths return a value" is reported here.
                        //
                        // maybe move the check to a MIR pass?
                        let local_def_id = tcx.hir().local_def_id(module);
                        tcx.ensure().check_mod_liveness(local_def_id);
                        tcx.ensure().check_mod_intrinsics(local_def_id);
                    });
                });
            }
        );
    });
    sess.time("MIR_borrow_checking", || {
        tcx.par_body_owners(|def_id| tcx.ensure().mir_borrowck(def_id));
    });
    sess.time("MIR_effect_checking", || {
        for def_id in tcx.body_owners() {
            mir::transform::check_unsafety::check_unsafety(tcx, def_id);
            if tcx.hir().body_const_context(def_id).is_some() {
                tcx.ensure().mir_drops_elaborated_and_const_checked(def_id);
            }
        }
    });
    sess.time("layout_testing", || layout_test::test_layout(tcx));
    // Avoid overwhelming user with errors if borrow checking failed.
    // I'm not sure how helpful this is, to be honest, but it avoids a
    // lot of annoying errors in the compile-fail tests (basically,
    // lint warnings and so on -- kindck used to do this abort, but
    // kindck is gone now). -nmatsakis
    if sess.has_errors() {
        return Err(ErrorReported);
    }
    sess.time("misc_checking_3", || {
        parallel!(
            {
                tcx.ensure().privacy_access_levels(LOCAL_CRATE);
                parallel!(
                    {
                        tcx.ensure().check_private_in_public(LOCAL_CRATE);
                    },
                    {
                        sess.time("death_checking", || rustc_passes::dead::check_crate(tcx));
                    },
                    {
                        sess.time("unused_lib_feature_checking", || {
                            rustc_passes::stability::check_unused_or_stable_features(tcx)
                        });
                    },
                    {
                        sess.time("lint_checking", || {
                            rustc_lint::check_crate(tcx, || {
                                rustc_lint::BuiltinCombinedLateLintPass::new()
                            });
                        });
                    }
                );
            },
            {
                sess.time("privacy_checking_modules", || {
                    par_iter(&tcx.hir().krate().modules).for_each(|(&module, _)| {
                        tcx.ensure().check_mod_privacy(tcx.hir().local_def_id(module));
                    });
                });
            }
        );
    });
    Ok(())
}
fn analysis ( tcx : TyCtxt < ' _ > , cnum : CrateNum ) -> Result < ( ) > { assert_eq ! ( cnum LOCAL_CRATE ) ; rustc_passes :: hir_id_validator :: check_crate ( tcx ) ; let sess = tcx . sess ; let mut entry_point = None ; sess . time ( " " , | | { parallel ! ( { entry_point sess time ( " " rustc_passes entry find_entry_point ( tcx ) ) sess time ( " " { plugin build find_plugin_registrar ( tcx ) } ) sess time ( " " proc_macro_decls find ( tcx ) ) } { par_iter ( tcx hir ( ) krate ( ) modules ) for_each ( ( module ) { let local_def_id tcx hir ( ) local_def_id ( module ) tcx ensure ( ) check_mod_loops ( local_def_id ) tcx ensure ( ) check_mod_attrs ( local_def_id ) tcx ensure ( ) check_mod_unstable_api_usage ( local_def_id ) tcx ensure ( ) check_mod_const_bodies ( local_def_id ) } ) } ) ; } ) ; // passes are timed inside typeck typeck :: check_crate ( tcx ) ? ; sess . time ( " " , | | { parallel ! ( { sess time ( " " { tcx par_body_owners ( def_id { tcx ensure ( ) check_match ( def_id to_def_id ( ) ) } ) } ) } { sess time ( " " { par_iter ( tcx hir ( ) krate ( ) modules ) for_each ( ( module ) { // this must run before MIR dump, because // "not all control paths return a value" is reported here. // maybe move the check to a MIR pass? let local_def_id tcx hir ( ) local_def_id ( module ) tcx ensure ( ) check_mod_liveness ( local_def_id ) tcx ensure ( ) check_mod_intrinsics ( local_def_id ) } ) } ) } ) ; } ) ; sess . time ( " " , | | { tcx . par_body_owners ( | def_id | tcx . ensure ( ) . mir_borrowck ( def_id ) ) ; } ) ; sess . time ( " " , | | { for def_id in tcx . body_owners ( ) { mir :: transform :: check_unsafety :: check_unsafety ( tcx , def_id ) ; if tcx . hir ( ) . body_const_context ( def_id ) . is_some ( ) { tcx . ensure ( ) . mir_drops_elaborated_and_const_checked ( def_id ) ; } } } ) ; sess . time ( " " , | | layout_test :: test_layout ( tcx ) ) ; // Avoid overwhelming user with errors if borrow checking failed. // I'm not sure how helpful this is, to be honest, but it avoids a // lot of annoying errors in the compile-fail tests (basically, // lint warnings and so on -- kindck used to do this abort, but // kindck is gone now). -nmatsakis if sess . has_errors ( ) { return Err ( ErrorReported ) ; } sess . time ( " " , | | { parallel ! ( { tcx ensure ( ) privacy_access_levels ( LOCAL_CRATE ) parallel ( { tcx ensure ( ) check_private_in_public ( LOCAL_CRATE ) } { sess time ( " " rustc_passes dead check_crate ( tcx ) ) } { sess time ( " " { rustc_passes stability check_unused_or_stable_features ( tcx ) } ) } { sess time ( " " { rustc_lint check_crate ( tcx { rustc_lint BuiltinCombinedLateLintPass new ( ) } ) } ) } ) } { sess time ( " " { par_iter ( tcx hir ( ) krate ( ) modules ) for_each ( ( module ) { tcx ensure ( ) check_mod_privacy ( tcx hir ( ) local_def_id ( module ) ) } ) } ) } ) ; } ) ; Ok ( ( ) ) }
Runs the resolution, type-checking, region checking and other
miscellaneous analysis passes on the crate.
Runs the resolution type - checking region checking and other miscellaneous analysis passes on the crate .
tcx
TyCtxt<'_>
cnum
CrateNum
tcx
TyCtxt<'_>
cnum
CrateNum