@@ -45,7 +45,7 @@ pub enum Os {
45
45
OsFreebsd
46
46
}
47
47
48
- pub struct ViaHash {
48
+ pub struct HashMismatch {
49
49
path : Path ,
50
50
}
51
51
@@ -58,8 +58,7 @@ pub struct Context<'a> {
58
58
pub hash : Option < & ' a Svh > ,
59
59
pub os : Os ,
60
60
pub intr : Rc < IdentInterner > ,
61
- /// Some if rejected
62
- pub rejected_via_hash : Option < ViaHash >
61
+ pub rejected_via_hash : Vec < HashMismatch >
63
62
}
64
63
65
64
pub struct Library {
@@ -81,14 +80,12 @@ pub struct CratePaths {
81
80
}
82
81
83
82
impl CratePaths {
84
- fn describe_paths ( & self ) -> ~ str {
83
+ fn paths ( & self ) -> Vec < Path > {
85
84
match ( & self . dylib , & self . rlib ) {
86
- ( & None , & None )
87
- => ~"",
88
- ( & Some ( ref p) , & None ) | ( & None , & Some ( ref p) )
89
- => format ! ( "{}" , p. display( ) ) ,
90
- ( & Some ( ref p1) , & Some ( ref p2) )
91
- => format ! ( "{}, {}" , p1. display( ) , p2. display( ) ) ,
85
+ ( & None , & None ) => vec ! ( ) ,
86
+ ( & Some ( ref p) , & None ) |
87
+ ( & None , & Some ( ref p) ) => vec ! ( p. clone( ) ) ,
88
+ ( & Some ( ref p1) , & Some ( ref p2) ) => vec ! ( p1. clone( ) , p2. clone( ) ) ,
92
89
}
93
90
}
94
91
}
@@ -111,7 +108,7 @@ impl<'a> Context<'a> {
111
108
Some ( t) => t,
112
109
None => {
113
110
self . sess . abort_if_errors ( ) ;
114
- let message = if self . rejected_via_hash . is_some ( ) {
111
+ let message = if self . rejected_via_hash . len ( ) > 0 {
115
112
format ! ( "found possibly newer version of crate `{}`" ,
116
113
self . ident)
117
114
} else {
@@ -124,17 +121,25 @@ impl<'a> Context<'a> {
124
121
} ;
125
122
self . sess . span_err ( self . span , message) ;
126
123
127
- if self . rejected_via_hash . is_some ( ) {
124
+ if self . rejected_via_hash . len ( ) > 0 {
128
125
self . sess . span_note ( self . span , "perhaps this crate needs \
129
126
to be recompiled?") ;
130
- self . rejected_via_hash . as_ref ( ) . map (
131
- |r| self . sess . note ( format ! (
132
- "crate `{}` at path: {}" ,
133
- self . ident, r. path. display( ) ) ) ) ;
134
- root. as_ref ( ) . map (
135
- |r| self . sess . note ( format ! (
136
- "crate `{}` at path(s): {}" ,
137
- r. ident, r. describe_paths( ) ) ) ) ;
127
+ let mismatches = self . rejected_via_hash . iter ( ) ;
128
+ for ( i, & HashMismatch { ref path } ) in mismatches. enumerate ( ) {
129
+ self . sess . fileline_note ( self . span ,
130
+ format ! ( "crate `{}` path \\ #{}: {}" ,
131
+ self . ident, i+1 , path. display( ) ) ) ;
132
+ }
133
+ match root {
134
+ & None => { }
135
+ & Some ( ref r) => {
136
+ for ( i, path) in r. paths ( ) . iter ( ) . enumerate ( ) {
137
+ self . sess . fileline_note ( self . span ,
138
+ format ! ( "crate `{}` path \\ #{}: {}" ,
139
+ r. ident, i+1 , path. display( ) ) ) ;
140
+ }
141
+ }
142
+ }
138
143
}
139
144
self . sess . abort_if_errors ( ) ;
140
145
unreachable ! ( )
@@ -371,8 +376,7 @@ impl<'a> Context<'a> {
371
376
None => true ,
372
377
Some ( myhash) => {
373
378
if * myhash != hash {
374
- self . rejected_via_hash =
375
- Some ( ViaHash { path : libpath. clone ( ) , } ) ;
379
+ self . rejected_via_hash . push ( HashMismatch { path : libpath. clone ( ) } ) ;
376
380
false
377
381
} else {
378
382
true
0 commit comments