1
1
use super :: * ;
2
- use crate :: core:: { Shell , Verbosity } ;
2
+ use crate :: core:: Shell ;
3
3
4
+ use crate :: Config ;
4
5
use dissimilar:: Chunk ;
5
6
use itertools:: Itertools ;
6
7
use std:: fmt;
@@ -76,8 +77,8 @@ pub enum DirtyReason {
76
77
}
77
78
78
79
impl DirtyReason {
79
- pub fn presentation ( & self ) -> DirtyReasonPrettyPresentation < ' _ > {
80
- DirtyReasonPrettyPresentation ( self )
80
+ pub fn presentation < ' a > ( & ' a self , unit : & ' a Unit , config : & ' a Config ) -> DirtyReasonPrettyPresentation < ' a > {
81
+ DirtyReasonPrettyPresentation ( self , unit , config )
81
82
}
82
83
}
83
84
@@ -266,7 +267,7 @@ impl fmt::Display for DirtyReason {
266
267
267
268
impl std:: error:: Error for DirtyReason { }
268
269
269
- pub struct DirtyReasonPrettyPresentation < ' a > ( & ' a DirtyReason ) ;
270
+ pub struct DirtyReasonPrettyPresentation < ' a > ( & ' a DirtyReason , & ' a Unit , & ' a Config ) ;
270
271
271
272
pub fn diffed ( a : & str , b : & str ) -> ( String , String ) {
272
273
let mut s1 = String :: new ( ) ;
@@ -415,7 +416,14 @@ impl<'a> DirtyReasonPrettyPresentation<'a> {
415
416
}
416
417
}
417
418
418
- pub fn present_to ( & self , s : & mut Shell , unit : & Unit , root : & Path ) -> CargoResult < ( ) > {
419
+ pub fn present_to ( & self , s : & mut Shell ) -> CargoResult < ( ) > {
420
+ let unit = self . 1 ;
421
+ let ws_roots = self . 2 . ws_roots . borrow ( ) ;
422
+ let root: & Path = ws_roots
423
+ . values ( )
424
+ . next ( )
425
+ . map_or_else ( || self . 2 . cwd ( ) , |it| it. inheritable ( ) . ws_root ( ) . as_ref ( ) ) ;
426
+
419
427
match & self . 0 {
420
428
DirtyReason :: RustcChanged => s. dirty_because ( unit, "the toolchain changed" ) ,
421
429
DirtyReason :: FeaturesChanged { old, new } => {
@@ -449,11 +457,9 @@ impl<'a> DirtyReasonPrettyPresentation<'a> {
449
457
}
450
458
DirtyReason :: LocalLengthsChanged => {
451
459
s. dirty_because ( unit, "the local lengths changed" ) ?;
452
- s. verbose ( |s| {
453
- s. note (
460
+ s. note (
454
461
"This could happen because of added/removed `cargo:rerun-if` instructions in the build script" ,
455
- )
456
- } ) ?;
462
+ ) ?;
457
463
458
464
Ok ( ( ) )
459
465
}
@@ -537,20 +543,14 @@ impl<'a> DirtyReasonPrettyPresentation<'a> {
537
543
..
538
544
} => {
539
545
let file = stale. strip_prefix ( root) . unwrap_or ( & stale) ;
540
- match s. verbosity ( ) {
541
- Verbosity :: Verbose => s. dirty_because (
542
- unit,
543
- format ! (
544
- "the file `{}` has changed({})" ,
545
- file. display( ) ,
546
- Self :: after( * reference_mtime, * stale_mtime, "last build" ) ,
547
- ) ,
548
- ) ,
549
- _ => s. dirty_because (
550
- unit,
551
- format ! ( "the file `{}` has changed" , file. display( ) ) ,
546
+ s. dirty_because (
547
+ unit,
548
+ format ! (
549
+ "the file `{}` has changed ({})" ,
550
+ file. display( ) ,
551
+ Self :: after( * reference_mtime, * stale_mtime, "last build" ) ,
552
552
) ,
553
- }
553
+ )
554
554
}
555
555
StaleItem :: ChangedEnv {
556
556
var,
@@ -571,14 +571,14 @@ impl<'a> DirtyReasonPrettyPresentation<'a> {
571
571
max_mtime,
572
572
..
573
573
} => {
574
- let message = match ( dep_mtime, s . verbosity ( ) ) {
575
- ( Some ( dep_mtime) , Verbosity :: Verbose ) => {
574
+ let message = match dep_mtime {
575
+ Some ( dep_mtime) => {
576
576
format ! (
577
577
"the dependency {name} was rebuilt ({})" ,
578
578
Self :: after( * max_mtime, * dep_mtime, "last build" ) ,
579
579
)
580
580
}
581
- ( None , _ ) | ( Some ( _ ) , _ ) => {
581
+ None => {
582
582
format ! ( "the dependency {name} was rebuilt" )
583
583
}
584
584
} ;
0 commit comments