Skip to content

Commit 1320b7d

Browse files
catamorphismemberian
authored andcommitted
---
yaml --- r: 68343 b: refs/heads/auto c: 2b17e47 h: refs/heads/master i: 68341: 36c69df 68339: 94c0cb3 68335: d7012a5 v: v3
1 parent 1b69d2f commit 1320b7d

File tree

2 files changed

+51
-53
lines changed

2 files changed

+51
-53
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 2234f61038f5a91fce0d7f4765eec55fc4b0c622
17+
refs/heads/auto: 2b17e4775c816b59d92e166b8a8db039aaa7ba85
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/librustc/metadata/loader.rs

Lines changed: 50 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -89,70 +89,68 @@ fn find_library_crate_aux(
8989
filesearch: @filesearch::FileSearch
9090
) -> Option<(~str, @~[u8])> {
9191
let crate_name = crate_name_from_metas(cx.metas);
92-
let prefix: ~str = prefix + crate_name + "-";
93-
let suffix: ~str = /*bad*/copy suffix;
92+
let prefix = prefix + crate_name + "-";
9493

9594
let mut matches = ~[];
96-
filesearch::search(filesearch, |path| {
95+
filesearch::search(filesearch, |path| -> Option<()> {
9796
debug!("inspecting file %s", path.to_str());
98-
let f: ~str = path.filename().get();
99-
if !(f.starts_with(prefix) && f.ends_with(suffix)) {
100-
debug!("skipping %s, doesn't look like %s*%s", path.to_str(),
101-
prefix, suffix);
102-
option::None::<()>
103-
} else {
104-
debug!("%s is a candidate", path.to_str());
105-
match get_metadata_section(cx.os, path) {
106-
option::Some(cvec) => {
107-
if !crate_matches(cvec, cx.metas, cx.hash) {
108-
debug!("skipping %s, metadata doesn't match",
109-
path.to_str());
110-
option::None::<()>
111-
} else {
112-
debug!("found %s with matching metadata", path.to_str());
113-
matches.push((path.to_str(), cvec));
114-
option::None::<()>
97+
match path.filename() {
98+
Some(ref f) if f.starts_with(prefix) && f.ends_with(suffix) => {
99+
debug!("%s is a candidate", path.to_str());
100+
match get_metadata_section(cx.os, path) {
101+
Some(cvec) =>
102+
if !crate_matches(cvec, cx.metas, cx.hash) {
103+
debug!("skipping %s, metadata doesn't match",
104+
path.to_str());
105+
None
106+
} else {
107+
debug!("found %s with matching metadata", path.to_str());
108+
matches.push((path.to_str(), cvec));
109+
None
110+
},
111+
_ => {
112+
debug!("could not load metadata for %s", path.to_str());
113+
None
114+
}
115115
}
116-
}
117-
_ => {
118-
debug!("could not load metadata for %s", path.to_str());
119-
option::None::<()>
120-
}
121116
}
122-
}
123-
});
117+
_ => {
118+
debug!("skipping %s, doesn't look like %s*%s", path.to_str(),
119+
prefix, suffix);
120+
None
121+
}
122+
}});
124123

125-
if matches.is_empty() {
126-
None
127-
} else if matches.len() == 1u {
128-
Some(/*bad*/copy matches[0])
129-
} else {
130-
cx.diag.span_err(
131-
cx.span, fmt!("multiple matching crates for `%s`", crate_name));
132-
cx.diag.handler().note("candidates:");
133-
for matches.iter().advance |&(ident, data)| {
134-
cx.diag.handler().note(fmt!("path: %s", ident));
135-
let attrs = decoder::get_crate_attributes(data);
136-
note_linkage_attrs(cx.intr, cx.diag, attrs);
124+
match matches.len() {
125+
0 => None,
126+
1 => Some(matches[0]),
127+
_ => {
128+
cx.diag.span_err(
129+
cx.span, fmt!("multiple matching crates for `%s`", crate_name));
130+
cx.diag.handler().note("candidates:");
131+
for matches.each |&(ident, data)| {
132+
cx.diag.handler().note(fmt!("path: %s", ident));
133+
let attrs = decoder::get_crate_attributes(data);
134+
note_linkage_attrs(cx.intr, cx.diag, attrs);
135+
}
136+
cx.diag.handler().abort_if_errors();
137+
None
138+
}
137139
}
138-
cx.diag.handler().abort_if_errors();
139-
None
140-
}
141140
}
142141

143142
pub fn crate_name_from_metas(metas: &[@ast::meta_item]) -> @str {
144-
let name_items = attr::find_meta_items_by_name(metas, "name");
145-
match name_items.last_opt() {
146-
Some(i) => {
147-
match attr::get_meta_item_value_str(*i) {
148-
Some(n) => n,
149-
// FIXME (#2406): Probably want a warning here since the user
150-
// is using the wrong type of meta item.
151-
_ => fail!()
152-
}
143+
for metas.each |m| {
144+
match m.node {
145+
ast::meta_name_value(s, ref l) if s == @"name" =>
146+
match l.node {
147+
ast::lit_str(s) => return s,
148+
_ => ()
149+
},
150+
_ => ()
153151
}
154-
None => fail!("expected to find the crate name")
155152
}
153+
fail!("expected to find the crate name")
156154
}
157155

158156
pub fn note_linkage_attrs(intr: @ident_interner,

0 commit comments

Comments
 (0)