@@ -2,8 +2,6 @@ use super::*;
22use crate :: core:: Shell ;
33
44use crate :: Config ;
5- use dissimilar:: Chunk ;
6- use itertools:: Itertools ;
75use std:: fmt;
86
97#[ derive( Debug ) ]
@@ -77,11 +75,16 @@ pub enum DirtyReason {
7775}
7876
7977impl DirtyReason {
80- pub fn presentation < ' a > ( & ' a self , unit : & ' a Unit , config : & ' a Config ) -> DirtyReasonPrettyPresentation < ' a > {
78+ pub fn presentation < ' a > (
79+ & ' a self ,
80+ unit : & ' a Unit ,
81+ config : & ' a Config ,
82+ ) -> DirtyReasonPrettyPresentation < ' a > {
8183 DirtyReasonPrettyPresentation ( self , unit, config)
8284 }
8385}
8486
87+ #[ allow( dead_code) ] // fields to be used in the future
8588pub struct DirtyReasonDeps {
8689 pub ( super ) old : Vec < DepFingerprint > ,
8790 pub ( super ) new : Vec < DepFingerprint > ,
@@ -269,73 +272,14 @@ impl std::error::Error for DirtyReason {}
269272
270273pub struct DirtyReasonPrettyPresentation < ' a > ( & ' a DirtyReason , & ' a Unit , & ' a Config ) ;
271274
272- pub fn diffed ( a : & str , b : & str ) -> ( String , String ) {
273- let mut s1 = String :: new ( ) ;
274- let mut s2 = String :: new ( ) ;
275-
276- for chunk in dissimilar:: diff ( a, b) {
277- match chunk {
278- Chunk :: Equal ( s) => {
279- s1. push_str ( s) ;
280- s2. push_str ( s) ;
281- }
282- Chunk :: Delete ( s) => {
283- s1. push_str ( s) ;
284- s2. push_str ( & " " . repeat ( s. len ( ) ) ) ;
285- }
286- Chunk :: Insert ( s) => {
287- s1. push_str ( & " " . repeat ( s. len ( ) ) ) ;
288- s2. push_str ( s) ;
289- }
290- }
291- }
292-
293- ( s1, s2)
294- }
295-
296275trait ShellExt {
297276 fn dirty_because ( & mut self , unit : & Unit , s : impl fmt:: Display ) -> CargoResult < ( ) > ;
298- fn from ( & mut self , s : impl fmt:: Display ) -> CargoResult < ( ) > ;
299- fn to ( & mut self , s : impl fmt:: Display ) -> CargoResult < ( ) > ;
300-
301- fn changed ( & mut self , old : impl fmt:: Display , new : impl fmt:: Display ) -> CargoResult < ( ) > ;
302- fn changed_diffed ( & mut self , old : impl fmt:: Display , new : impl fmt:: Display )
303- -> CargoResult < ( ) > ;
304277}
305278
306279impl ShellExt for Shell {
307280 fn dirty_because ( & mut self , unit : & Unit , s : impl fmt:: Display ) -> CargoResult < ( ) > {
308281 self . status ( "Dirty" , format ! ( "{}: {s}" , & unit. pkg) )
309282 }
310-
311- fn from ( & mut self , s : impl fmt:: Display ) -> CargoResult < ( ) > {
312- self . status ( "From" , s)
313- }
314-
315- fn to ( & mut self , s : impl fmt:: Display ) -> CargoResult < ( ) > {
316- self . status ( "To" , s)
317- }
318-
319- fn changed ( & mut self , old : impl fmt:: Display , new : impl fmt:: Display ) -> CargoResult < ( ) > {
320- self . verbose ( |s| {
321- s. from ( & old) ?;
322- s. to ( & new) ?;
323-
324- Ok ( ( ) )
325- } )
326- }
327-
328- fn changed_diffed (
329- & mut self ,
330- old : impl fmt:: Display ,
331- new : impl fmt:: Display ,
332- ) -> CargoResult < ( ) > {
333- self . verbose ( |s| {
334- let ( old_pretty, new_pretty) = diffed ( & old. to_string ( ) , & new. to_string ( ) ) ;
335-
336- s. changed ( old_pretty, new_pretty)
337- } )
338- }
339283}
340284
341285struct FileTimeDiff {
@@ -396,15 +340,10 @@ impl<'a> DirtyReasonPrettyPresentation<'a> {
396340 fn present_dependency_diffs (
397341 s : & mut Shell ,
398342 unit : & Unit ,
399- deps : & DirtyReasonDeps ,
343+ _deps : & DirtyReasonDeps ,
400344 ) -> CargoResult < ( ) > {
401345 s. dirty_because ( unit, "the list of dependencies changed" ) ?;
402346
403- let old_deps = deps. old . iter ( ) . map ( |it| & it. name ) . sorted ( ) . join ( ", " ) ;
404- let new_deps = deps. new . iter ( ) . map ( |it| & it. name ) . sorted ( ) . join ( ", " ) ;
405-
406- s. changed_diffed ( old_deps, new_deps) ?;
407-
408347 Ok ( ( ) )
409348 }
410349
@@ -426,9 +365,8 @@ impl<'a> DirtyReasonPrettyPresentation<'a> {
426365
427366 match & self . 0 {
428367 DirtyReason :: RustcChanged => s. dirty_because ( unit, "the toolchain changed" ) ,
429- DirtyReason :: FeaturesChanged { old , new } => {
368+ DirtyReason :: FeaturesChanged { .. } => {
430369 s. dirty_because ( unit, "the list of features changed" ) ?;
431- s. changed_diffed ( old, new) ?;
432370
433371 Ok ( ( ) )
434372 }
@@ -441,11 +379,9 @@ impl<'a> DirtyReasonPrettyPresentation<'a> {
441379 DirtyReason :: ProfileConfigurationChanged => {
442380 s. dirty_because ( unit, "the profile configuration changed" )
443381 }
444- DirtyReason :: RustflagsChanged { old , new } => {
382+ DirtyReason :: RustflagsChanged { .. } => {
445383 s. dirty_because ( unit, "the rustflags changed" ) ?;
446384
447- s. changed_diffed ( & old. join ( " " ) , & new. join ( " " ) ) ?;
448-
449385 Ok ( ( ) )
450386 }
451387 DirtyReason :: MetadataChanged => s. dirty_because ( unit, "the metadata changed" ) ,
@@ -463,60 +399,39 @@ impl<'a> DirtyReasonPrettyPresentation<'a> {
463399
464400 Ok ( ( ) )
465401 }
466- DirtyReason :: PrecalculatedComponentsChanged { old , new } => {
402+ DirtyReason :: PrecalculatedComponentsChanged { .. } => {
467403 s. dirty_because ( unit, "the precalculated components changed" ) ?;
468- s. changed ( old, new) ?;
469404
470405 Ok ( ( ) )
471406 }
472407 DirtyReason :: DepInfoOutputChanged { .. } => {
473408 s. dirty_because ( unit, "the dependency info output changed" )
474409 }
475- DirtyReason :: RerunIfChangedOutputRootChanged { old , new } => {
410+ DirtyReason :: RerunIfChangedOutputRootChanged { .. } => {
476411 s. dirty_because (
477412 unit,
478413 "the working directories for `rerun-if-changed` instructions changed" ,
479414 ) ?;
480415
481- s. changed ( old. display ( ) , new. display ( ) ) ?;
482-
483416 Ok ( ( ) )
484417 }
485- DirtyReason :: RerunIfChangedOutputChanged { old , new } => {
418+ DirtyReason :: RerunIfChangedOutputChanged { .. } => {
486419 s. dirty_because ( unit, "the rerun-if-changed instructions changed" ) ?;
487420
488- s. verbose ( |s| {
489- let old_str = old. iter ( ) . map ( |it| format ! ( "{it:?}" ) ) . join ( ", " ) ;
490- let new_str = new. iter ( ) . map ( |it| format ! ( "{it:?}" ) ) . join ( ", " ) ;
491-
492- s. changed_diffed ( old_str, new_str) ?;
493-
494- Ok ( ( ) )
495- } ) ?;
496-
497421 Ok ( ( ) )
498422 }
499423 DirtyReason :: EnvVarsChanged { .. } => {
500424 s. dirty_because ( unit, "the environment variables changed" ) ?;
501425
502426 Ok ( ( ) )
503427 }
504- DirtyReason :: EnvVarChanged {
505- name,
506- old_value,
507- new_value,
508- } => {
428+ DirtyReason :: EnvVarChanged { name, .. } => {
509429 s. dirty_because ( unit, format ! ( "the env variable {name} changed" ) ) ?;
510- s. changed (
511- old_value. as_ref ( ) . map_or ( "<missing>" , String :: as_str) ,
512- new_value. as_ref ( ) . map_or ( "<missing>" , String :: as_str) ,
513- ) ?;
514430
515431 Ok ( ( ) )
516432 }
517- DirtyReason :: LocalFingerprintTypeChanged { old , new } => {
433+ DirtyReason :: LocalFingerprintTypeChanged { .. } => {
518434 s. dirty_because ( unit, "the local fingerprint type changed" ) ?;
519- s. changed ( old, new) ?;
520435
521436 Ok ( ( ) )
522437 }
@@ -552,16 +467,8 @@ impl<'a> DirtyReasonPrettyPresentation<'a> {
552467 ) ,
553468 )
554469 }
555- StaleItem :: ChangedEnv {
556- var,
557- previous,
558- current,
559- } => {
470+ StaleItem :: ChangedEnv { var, .. } => {
560471 s. dirty_because ( unit, format ! ( "the environment variable {var} changed" ) ) ?;
561- s. changed (
562- previous. as_ref ( ) . map_or ( "<missing>" , String :: as_str) ,
563- current. as_ref ( ) . map_or ( "<missing>" , String :: as_str) ,
564- ) ?;
565472 Ok ( ( ) )
566473 }
567474 } ,
0 commit comments