1- //! "Hooks" provide a way for `tcx` functionality to be provided by some downstream crate without
2- //! everything in rustc having to depend on that crate. This is somewhat similar to queries, but
3- //! queries come with a lot of machinery for caching and incremental compilation, whereas hooks are
4- //! just plain function pointers without any of the query magic.
1+ //! "Hooks" let you write `tcx` methods in downstream crates and call them in this crate, reducing
2+ //! the amount of code that needs to be in this crate (which is already very big). This is somewhat
3+ //! similar to queries, but queries come with a lot of machinery for caching and incremental
4+ //! compilation, whereas hooks are just plain function pointers without any of the query magic.
55
66use rustc_hir:: def_id:: { DefId , DefPathHash } ;
77use rustc_session:: StableCrateId ;
@@ -75,12 +75,6 @@ declare_hooks! {
7575 /// (Eligible functions might nevertheless be skipped for other reasons.)
7676 hook is_eligible_for_coverage( key: LocalDefId ) -> bool ;
7777
78- /// Create the MIR for a given `DefId` - this includes
79- /// unreachable code.
80- /// You do not want to call this yourself, instead use the cached version
81- /// via `mir_built`
82- hook build_mir( key: LocalDefId ) -> mir:: Body <' tcx>;
83-
8478 /// Imports all `SourceFile`s from the given crate into the current session.
8579 /// This normally happens automatically when we decode a `Span` from
8680 /// that crate's metadata - however, the incr comp cache needs
@@ -99,14 +93,11 @@ declare_hooks! {
9993 /// Will fetch a DefId from a DefPathHash for a foreign crate.
10094 hook def_path_hash_to_def_id_extern( hash: DefPathHash , stable_crate_id: StableCrateId ) -> DefId ;
10195
102- /// Create a THIR tree for debugging.
103- hook thir_tree( key: LocalDefId ) -> String ;
104-
105- /// Create a list-like THIR representation for debugging.
106- hook thir_flat( key: LocalDefId ) -> String ;
107-
10896 /// Returns `true` if we should codegen an instance in the local crate, or returns `false` if we
10997 /// can just link to the upstream crate and therefore don't need a mono item.
98+ ///
99+ /// Note: this hook isn't called within `rustc_middle` but #127779 suggests it's a hook instead
100+ /// of a normal function because external tools might want to override it.
110101 hook should_codegen_locally( instance: crate :: ty:: Instance <' tcx>) -> bool ;
111102
112103 hook alloc_self_profile_query_strings( ) -> ( ) ;
0 commit comments