@@ -59,7 +59,7 @@ use rustc_session::getopts::{self, Matches};
5959use rustc_session:: lint:: { Lint , LintId } ;
6060use rustc_session:: output:: collect_crate_types;
6161use rustc_session:: { EarlyDiagCtxt , Session , config, filesearch} ;
62- use rustc_span:: FileName ;
62+ use rustc_span:: { FileName , def_id :: LOCAL_CRATE } ;
6363use rustc_target:: json:: ToJson ;
6464use rustc_target:: spec:: { Target , TargetTuple } ;
6565use time:: OffsetDateTime ;
@@ -383,14 +383,10 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
383383}
384384
385385fn dump_feature_usage_metrics( tcxt: TyCtxt <' _>, metrics_dir: & Path ) {
386- let output_filenames = tcxt. output_filenames( ( ) ) ;
387- let mut metrics_file_name = std:: ffi:: OsString :: from( "unstable_feature_usage_metrics-" ) ;
388- let mut metrics_path = output_filenames. with_directory_and_extension( metrics_dir, "json" ) ;
389- let metrics_file_stem =
390- metrics_path. file_name( ) . expect( "there should be a valid default output filename" ) ;
391- metrics_file_name. push( metrics_file_stem) ;
392- metrics_path. pop( ) ;
393- metrics_path. push( metrics_file_name) ;
386+ let hash = tcxt. crate_hash( LOCAL_CRATE ) ;
387+ let crate_name = tcxt. crate_name( LOCAL_CRATE ) ;
388+ let metrics_file_name = format!( "unstable_feature_usage_metrics-{crate_name}-{hash}.json" ) ;
389+ let metrics_path = metrics_dir. join( metrics_file_name) ;
394390 if let Err ( error) = tcxt. features( ) . dump_feature_usage_metrics( metrics_path) {
395391 // FIXME(yaahc): once metrics can be enabled by default we will want "failure to emit
396392 // default metrics" to only produce a warning when metrics are enabled by default and emit
0 commit comments