@@ -133,21 +133,26 @@ const QUERY_CACHE_FILENAME: &str = "query-cache.bin";
133
133
// case-sensitive (as opposed to base64, for example).
134
134
const INT_ENCODE_BASE : usize = base_n:: CASE_INSENSITIVE ;
135
135
136
+ /// Returns the path to a session's dependency graph.
136
137
pub fn dep_graph_path ( sess : & Session ) -> PathBuf {
137
138
in_incr_comp_dir_sess ( sess, DEP_GRAPH_FILENAME )
138
139
}
140
+ /// Returns the path to a session's staging dependency graph.
141
+ ///
142
+ /// On the difference between dep-graph and staging dep-graph,
143
+ /// see `build_dep_graph`.
139
144
pub fn staging_dep_graph_path ( sess : & Session ) -> PathBuf {
140
145
in_incr_comp_dir_sess ( sess, STAGING_DEP_GRAPH_FILENAME )
141
146
}
142
-
143
147
pub fn work_products_path ( sess : & Session ) -> PathBuf {
144
148
in_incr_comp_dir_sess ( sess, WORK_PRODUCTS_FILENAME )
145
149
}
146
-
150
+ /// Returns the path to a session's query cache.
147
151
pub fn query_cache_path ( sess : & Session ) -> PathBuf {
148
152
in_incr_comp_dir_sess ( sess, QUERY_CACHE_FILENAME )
149
153
}
150
154
155
+ /// Locks a given session directory.
151
156
pub fn lock_file_path ( session_dir : & Path ) -> PathBuf {
152
157
let crate_dir = session_dir. parent ( ) . unwrap ( ) ;
153
158
@@ -166,23 +171,35 @@ pub fn lock_file_path(session_dir: &Path) -> PathBuf {
166
171
crate_dir. join ( & directory_name[ 0 ..dash_indices[ 2 ] ] ) . with_extension ( & LOCK_FILE_EXT [ 1 ..] )
167
172
}
168
173
174
+ /// Returns the path for a given filename within the incremental compilation directory
175
+ /// in the current session.
169
176
pub fn in_incr_comp_dir_sess ( sess : & Session , file_name : & str ) -> PathBuf {
170
177
in_incr_comp_dir ( & sess. incr_comp_session_dir ( ) , file_name)
171
178
}
172
179
180
+ /// Returns the path for a given filename within the incremental compilation directory,
181
+ /// not necessarily from the current session.
182
+ ///
183
+ /// To ensure the file is part of the current session, use [`in_incr_comp_dir_sess`].
173
184
pub fn in_incr_comp_dir ( incr_comp_session_dir : & Path , file_name : & str ) -> PathBuf {
174
185
incr_comp_session_dir. join ( file_name)
175
186
}
176
187
177
- /// Allocates the private session directory. The boolean in the Ok() result
178
- /// indicates whether we should try loading a dep graph from the successfully
179
- /// initialized directory, or not.
180
- /// The post-condition of this fn is that we have a valid incremental
181
- /// compilation session directory, if the result is `Ok`. A valid session
188
+ /// Allocates the private session directory.
189
+ ///
190
+ /// If the result of this function is `Ok`, we have a valid incremental
191
+ /// compilation session directory. A valid session
182
192
/// directory is one that contains a locked lock file. It may or may not contain
183
193
/// a dep-graph and work products from a previous session.
184
- /// If the call fails, the fn may leave behind an invalid session directory.
194
+ ///
195
+ /// This always attempts to load a dep-graph from the directory.
196
+ /// If loading fails for some reason, we fallback to a disabled `DepGraph`.
197
+ /// See [`rustc_interface::queries::dep_graph`].
198
+ ///
199
+ /// If this function returns an error, it may leave behind an invalid session directory.
185
200
/// The garbage collection will take care of it.
201
+ ///
202
+ /// [`rustc_interface::queries::dep_graph`]: ../../rustc_interface/struct.Queries.html#structfield.dep_graph
186
203
pub fn prepare_session_directory (
187
204
sess : & Session ,
188
205
crate_name : & str ,
@@ -661,6 +678,7 @@ fn is_old_enough_to_be_collected(timestamp: SystemTime) -> bool {
661
678
timestamp < SystemTime :: now ( ) - Duration :: from_secs ( 10 )
662
679
}
663
680
681
+ /// Runs garbage collection for the current session.
664
682
pub fn garbage_collect_session_directories ( sess : & Session ) -> io:: Result < ( ) > {
665
683
debug ! ( "garbage_collect_session_directories() - begin" ) ;
666
684
0 commit comments