Skip to content

Commit a18bf8c

Browse files
committed
rustc: minor code cleanup
1 parent 8f263dd commit a18bf8c

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

src/librustc/metadata/loader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ fn find_library_crate_aux(
9797
filesearch::search(filesearch, |path| {
9898
debug!("inspecting file %s", path.to_str());
9999
let f: ~str = path.filename().get();
100-
if !(str::starts_with(f, prefix) && str::ends_with(f, suffix)) {
100+
if !(f.starts_with(prefix) && f.ends_with(suffix)) {
101101
debug!("skipping %s, doesn't look like %s*%s", path.to_str(),
102102
prefix, suffix);
103103
option::None::<()>

src/librustc/middle/check_match.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub fn raw_pat(p: @pat) -> @pat {
133133

134134
pub fn check_exhaustive(cx: @MatchCheckCtxt, sp: span, pats: ~[@pat]) {
135135
assert(!pats.is_empty());
136-
let ext = match is_useful(cx, vec::map(pats, |p| ~[*p]), ~[wild()]) {
136+
let ext = match is_useful(cx, &pats.map(|p| ~[*p]), ~[wild()]) {
137137
not_useful => {
138138
// This is good, wildcard pattern isn't reachable
139139
return;
@@ -165,7 +165,7 @@ pub fn check_exhaustive(cx: @MatchCheckCtxt, sp: span, pats: ~[@pat]) {
165165
ty::ty_unboxed_vec(*) | ty::ty_evec(*) => {
166166
match *ctor {
167167
vec(n) => Some(@fmt!("vectors of length %u", n)),
168-
_ => None
168+
_ => None
169169
}
170170
}
171171
_ => None
@@ -205,10 +205,10 @@ pub enum ctor {
205205
206206
// Note: is_useful doesn't work on empty types, as the paper notes.
207207
// So it assumes that v is non-empty.
208-
pub fn is_useful(cx: @MatchCheckCtxt, +m: matrix, +v: &[@pat]) -> useful {
208+
pub fn is_useful(cx: @MatchCheckCtxt, m: &matrix, v: &[@pat]) -> useful {
209209
if m.len() == 0u { return useful_; }
210210
if m[0].len() == 0u { return not_useful; }
211-
let real_pat = match vec::find(m, |r| r[0].id != 0) {
211+
let real_pat = match m.find(|r| r[0].id != 0) {
212212
Some(r) => r[0], None => v[0]
213213
};
214214
let left_ty = if real_pat.id == 0 { ty::mk_nil(cx.tcx) }
@@ -264,7 +264,7 @@ pub fn is_useful(cx: @MatchCheckCtxt, +m: matrix, +v: &[@pat]) -> useful {
264264
}
265265
Some(ref ctor) => {
266266
match is_useful(cx,
267-
vec::filter_map(m, |r| default(cx, r)),
267+
&m.filter_mapped(|r| default(cx, *r)),
268268
v.tail()) {
269269
useful_ => useful(left_ty, (/*bad*/copy *ctor)),
270270
ref u => (/*bad*/copy *u)
@@ -280,15 +280,15 @@ pub fn is_useful(cx: @MatchCheckCtxt, +m: matrix, +v: &[@pat]) -> useful {
280280
}
281281
282282
pub fn is_useful_specialized(cx: @MatchCheckCtxt,
283-
m: matrix,
283+
m: &matrix,
284284
v: &[@pat],
285285
+ctor: ctor,
286286
arity: uint,
287287
lty: ty::t)
288288
-> useful {
289289
let ms = m.filter_mapped(|r| specialize(cx, *r, ctor, arity, lty));
290290
let could_be_useful = is_useful(
291-
cx, ms, specialize(cx, v, ctor, arity, lty).get());
291+
cx, &ms, specialize(cx, v, ctor, arity, lty).get());
292292
match could_be_useful {
293293
useful_ => useful(lty, ctor),
294294
ref u => (/*bad*/copy *u)
@@ -347,7 +347,7 @@ pub fn is_wild(cx: @MatchCheckCtxt, p: @pat) -> bool {
347347
}
348348
349349
pub fn missing_ctor(cx: @MatchCheckCtxt,
350-
m: matrix,
350+
m: &matrix,
351351
left_ty: ty::t)
352352
-> Option<ctor> {
353353
match ty::get(left_ty).sty {

src/librustc/middle/pat_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub fn pat_id_map(dm: resolve::DefMap, pat: @pat) -> PatIdMap {
2626
do pat_bindings(dm, pat) |_bm, p_id, _s, n| {
2727
map.insert(path_to_ident(n), p_id);
2828
};
29-
return map;
29+
map
3030
}
3131

3232
pub fn pat_is_variant_or_struct(dm: resolve::DefMap, pat: @pat) -> bool {

src/librustdoc/config.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,18 @@ pub fn parse_config_(
130130
let args = args.tail();
131131
let opts = vec::unzip(opts()).first();
132132
match getopts::getopts(args, opts) {
133-
result::Ok(matches) => {
133+
Ok(matches) => {
134134
if matches.free.len() == 1 {
135-
let input_crate = Path(copy *matches.free.head());
135+
let input_crate = Path(*matches.free.head());
136136
config_from_opts(&input_crate, &matches, program_output)
137137
} else if matches.free.is_empty() {
138-
result::Err(~"no crates specified")
138+
Err(~"no crates specified")
139139
} else {
140-
result::Err(~"multiple crates specified")
140+
Err(~"multiple crates specified")
141141
}
142142
}
143-
result::Err(f) => {
144-
result::Err(getopts::fail_str(f))
143+
Err(f) => {
144+
Err(getopts::fail_str(f))
145145
}
146146
}
147147
}

0 commit comments

Comments
 (0)