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.
5
5
6
6
use rustc_hir:: def_id:: { DefId , DefPathHash } ;
7
7
use rustc_session:: StableCrateId ;
@@ -75,12 +75,6 @@ declare_hooks! {
75
75
/// (Eligible functions might nevertheless be skipped for other reasons.)
76
76
hook is_eligible_for_coverage( key: LocalDefId ) -> bool ;
77
77
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
-
84
78
/// Imports all `SourceFile`s from the given crate into the current session.
85
79
/// This normally happens automatically when we decode a `Span` from
86
80
/// that crate's metadata - however, the incr comp cache needs
@@ -99,14 +93,11 @@ declare_hooks! {
99
93
/// Will fetch a DefId from a DefPathHash for a foreign crate.
100
94
hook def_path_hash_to_def_id_extern( hash: DefPathHash , stable_crate_id: StableCrateId ) -> DefId ;
101
95
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
-
108
96
/// Returns `true` if we should codegen an instance in the local crate, or returns `false` if we
109
97
/// 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.
110
101
hook should_codegen_locally( instance: crate :: ty:: Instance <' tcx>) -> bool ;
111
102
112
103
hook alloc_self_profile_query_strings( ) -> ( ) ;
0 commit comments