@@ -133,21 +133,26 @@ const QUERY_CACHE_FILENAME: &str = "query-cache.bin";
133133// case-sensitive (as opposed to base64, for example).
134134const INT_ENCODE_BASE : usize = base_n:: CASE_INSENSITIVE ;
135135
136+ /// Returns the path to a session's dependency graph.
136137pub fn dep_graph_path ( sess : & Session ) -> PathBuf {
137138 in_incr_comp_dir_sess ( sess, DEP_GRAPH_FILENAME )
138139}
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 [`rustc_incremental::persist::save::build_dep_graph`].
139144pub fn staging_dep_graph_path ( sess : & Session ) -> PathBuf {
140145 in_incr_comp_dir_sess ( sess, STAGING_DEP_GRAPH_FILENAME )
141146}
142-
143147pub fn work_products_path ( sess : & Session ) -> PathBuf {
144148 in_incr_comp_dir_sess ( sess, WORK_PRODUCTS_FILENAME )
145149}
146-
150+ /// Returns the path to a session's query cache.
147151pub fn query_cache_path ( sess : & Session ) -> PathBuf {
148152 in_incr_comp_dir_sess ( sess, QUERY_CACHE_FILENAME )
149153}
150154
155+ /// Locks a given session directory.
151156pub fn lock_file_path ( session_dir : & Path ) -> PathBuf {
152157 let crate_dir = session_dir. parent ( ) . unwrap ( ) ;
153158
@@ -166,23 +171,35 @@ pub fn lock_file_path(session_dir: &Path) -> PathBuf {
166171 crate_dir. join ( & directory_name[ 0 ..dash_indices[ 2 ] ] ) . with_extension ( & LOCK_FILE_EXT [ 1 ..] )
167172}
168173
174+ /// Returns the path for a given filename within the incremental compilation directory
175+ /// in the current session.
169176pub fn in_incr_comp_dir_sess ( sess : & Session , file_name : & str ) -> PathBuf {
170177 in_incr_comp_dir ( & sess. incr_comp_session_dir ( ) , file_name)
171178}
172179
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`].
173184pub fn in_incr_comp_dir ( incr_comp_session_dir : & Path , file_name : & str ) -> PathBuf {
174185 incr_comp_session_dir. join ( file_name)
175186}
176187
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
182192/// directory is one that contains a locked lock file. It may or may not contain
183193/// 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.
185200/// The garbage collection will take care of it.
201+ ///
202+ /// [`rustc_interface::queries::dep_graph`]: ../../rustc_interface/struct.Queries.html#structfield.dep_graph
186203pub fn prepare_session_directory (
187204 sess : & Session ,
188205 crate_name : & str ,
@@ -661,6 +678,7 @@ fn is_old_enough_to_be_collected(timestamp: SystemTime) -> bool {
661678 timestamp < SystemTime :: now ( ) - Duration :: from_secs ( 10 )
662679}
663680
681+ /// Runs garbage collection for the current session.
664682pub fn garbage_collect_session_directories ( sess : & Session ) -> io:: Result < ( ) > {
665683 debug ! ( "garbage_collect_session_directories() - begin" ) ;
666684
0 commit comments