Skip to content

Commit 4afd060

Browse files
committed
Accumulate list of paths for crate hash mismatch.
(i.e. semi-generalized version of prior errorinfo gathering.) Also revised presentation to put each path on its own line, prefixed by file:linenum information.
1 parent 1599d22 commit 4afd060

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed

Diff for: src/librustc/metadata/creader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ fn resolve_crate<'a>(e: &mut Env,
298298
hash: hash.map(|a| &*a),
299299
os: e.os,
300300
intr: e.intr.clone(),
301-
rejected_via_hash: None,
301+
rejected_via_hash: vec!(),
302302
};
303303
let loader::Library {
304304
dylib, rlib, metadata

Diff for: src/librustc/metadata/loader.rs

+26-22
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub enum Os {
4545
OsFreebsd
4646
}
4747

48-
pub struct ViaHash {
48+
pub struct HashMismatch {
4949
path: Path,
5050
}
5151

@@ -58,8 +58,7 @@ pub struct Context<'a> {
5858
pub hash: Option<&'a Svh>,
5959
pub os: Os,
6060
pub intr: Rc<IdentInterner>,
61-
/// Some if rejected
62-
pub rejected_via_hash: Option<ViaHash>
61+
pub rejected_via_hash: Vec<HashMismatch>
6362
}
6463

6564
pub struct Library {
@@ -81,14 +80,12 @@ pub struct CratePaths {
8180
}
8281

8382
impl CratePaths {
84-
fn describe_paths(&self) -> ~str {
83+
fn paths(&self) -> Vec<Path> {
8584
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()),
9289
}
9390
}
9491
}
@@ -111,7 +108,7 @@ impl<'a> Context<'a> {
111108
Some(t) => t,
112109
None => {
113110
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 {
115112
format!("found possibly newer version of crate `{}`",
116113
self.ident)
117114
} else {
@@ -124,17 +121,25 @@ impl<'a> Context<'a> {
124121
};
125122
self.sess.span_err(self.span, message);
126123

127-
if self.rejected_via_hash.is_some() {
124+
if self.rejected_via_hash.len() > 0 {
128125
self.sess.span_note(self.span, "perhaps this crate needs \
129126
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+
}
138143
}
139144
self.sess.abort_if_errors();
140145
unreachable!()
@@ -371,8 +376,7 @@ impl<'a> Context<'a> {
371376
None => true,
372377
Some(myhash) => {
373378
if *myhash != hash {
374-
self.rejected_via_hash =
375-
Some(ViaHash{ path: libpath.clone(), });
379+
self.rejected_via_hash.push(HashMismatch{ path: libpath.clone() });
376380
false
377381
} else {
378382
true

0 commit comments

Comments
 (0)