@@ -64,6 +64,7 @@ use rustc_session::lint::{Lint, LintId};
64
64
use rustc_session:: output:: { CRATE_TYPES , collect_crate_types, invalid_output_for_target} ;
65
65
use rustc_session:: { EarlyDiagCtxt , Session , config, filesearch} ;
66
66
use rustc_span:: FileName ;
67
+ use rustc_span:: def_id:: LOCAL_CRATE ;
67
68
use rustc_target:: json:: ToJson ;
68
69
use rustc_target:: spec:: { Target , TargetTuple } ;
69
70
use time:: OffsetDateTime ;
@@ -392,14 +393,10 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
392
393
}
393
394
394
395
fn dump_feature_usage_metrics( tcxt: TyCtxt <' _>, metrics_dir: & Path ) {
395
- let output_filenames = tcxt. output_filenames( ( ) ) ;
396
- let mut metrics_file_name = std:: ffi:: OsString :: from( "unstable_feature_usage_metrics-" ) ;
397
- let mut metrics_path = output_filenames. with_directory_and_extension( metrics_dir, "json" ) ;
398
- let metrics_file_stem =
399
- metrics_path. file_name( ) . expect( "there should be a valid default output filename" ) ;
400
- metrics_file_name. push( metrics_file_stem) ;
401
- metrics_path. pop( ) ;
402
- metrics_path. push( metrics_file_name) ;
396
+ let hash = tcxt. crate_hash( LOCAL_CRATE ) ;
397
+ let crate_name = tcxt. crate_name( LOCAL_CRATE ) ;
398
+ let metrics_file_name = format!( "unstable_feature_usage_metrics-{crate_name}-{hash}.json" ) ;
399
+ let metrics_path = metrics_dir. join( metrics_file_name) ;
403
400
if let Err ( error) = tcxt. features( ) . dump_feature_usage_metrics( metrics_path) {
404
401
// FIXME(yaahc): once metrics can be enabled by default we will want "failure to emit
405
402
// default metrics" to only produce a warning when metrics are enabled by default and emit
0 commit comments