@@ -547,32 +547,36 @@ fn compute_metadata<'a, 'cfg>(
547547 // settings like debuginfo and whatnot.
548548 unit. profile . hash ( & mut hasher) ;
549549 unit. mode . hash ( & mut hasher) ;
550- if let Some ( args) = bcx. extra_args_for ( unit) {
551- args. hash ( & mut hasher) ;
552- }
553550
554551 // Throw in the rustflags we're compiling with.
555552 // This helps when the target directory is a shared cache for projects with different cargo configs,
556553 // or if the user is experimenting with different rustflags manually.
557- let mut flags = if unit. mode . is_doc ( ) {
558- cx. bcx . rustdocflags_args ( unit)
559- } else {
560- cx. bcx . rustflags_args ( unit)
561- }
562- . iter ( ) ;
563-
564- // Ignore some flags. These may affect reproducible builds if they affect
565- // the path. The fingerprint will handle recompilation if these change.
566- while let Some ( flag) = flags. next ( ) {
567- if flag. starts_with ( "--remap-path-prefix=" ) {
568- continue ;
569- }
570- if flag == "--remap-path-prefix" {
571- flags. next ( ) ;
572- continue ;
554+ let mut hash_flags = |flags : & [ String ] | {
555+ // Ignore some flags. These may affect reproducible builds if they affect
556+ // the path. The fingerprint will handle recompilation if these change.
557+ let mut iter = flags. iter ( ) ;
558+ while let Some ( flag) = iter. next ( ) {
559+ if flag. starts_with ( "--remap-path-prefix=" ) {
560+ continue ;
561+ }
562+ if flag == "--remap-path-prefix" {
563+ iter. next ( ) ;
564+ continue ;
565+ }
566+ flag. hash ( & mut hasher) ;
573567 }
574- flag. hash ( & mut hasher) ;
568+ } ;
569+ if let Some ( args) = bcx. extra_args_for ( unit) {
570+ // Arguments passed to `cargo rustc`.
571+ hash_flags ( args) ;
575572 }
573+ // Arguments passed in via RUSTFLAGS env var.
574+ let flags = if unit. mode . is_doc ( ) {
575+ bcx. rustdocflags_args ( unit)
576+ } else {
577+ bcx. rustflags_args ( unit)
578+ } ;
579+ hash_flags ( flags) ;
576580
577581 // Artifacts compiled for the host should have a different metadata
578582 // piece than those compiled for the target, so make sure we throw in
0 commit comments