Skip to content

Commit 10612ee

Browse files
committed
Remove superfluous by-ref in option::get, option::get_default, option::expect
Superficial change, no review.
1 parent c97944f commit 10612ee

File tree

13 files changed

+35
-35
lines changed

13 files changed

+35
-35
lines changed

src/fuzzer/fuzzer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ fn check_variants_T<T: Copy>(
296296
}
297297

298298
fn last_part(filename: ~str) -> ~str {
299-
let ix = option::get(&str::rfind_char(filename, '/'));
299+
let ix = option::get(str::rfind_char(filename, '/'));
300300
str::slice(filename, ix + 1u, str::len(filename) - 3u)
301301
}
302302

src/libcore/dlist.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ impl<T> DList<T> {
208208
fn push_head_n(data: T) -> DListNode<T> {
209209
let mut nobe = self.new_link(move data);
210210
self.add_head(nobe);
211-
option::get(&nobe)
211+
option::get(nobe)
212212
}
213213
/// Add data to the tail of the list. O(1).
214214
fn push(data: T) {
@@ -221,7 +221,7 @@ impl<T> DList<T> {
221221
fn push_n(data: T) -> DListNode<T> {
222222
let mut nobe = self.new_link(move data);
223223
self.add_tail(nobe);
224-
option::get(&nobe)
224+
option::get(nobe)
225225
}
226226
/**
227227
* Insert data into the middle of the list, left of the given node.
@@ -245,7 +245,7 @@ impl<T> DList<T> {
245245
fn insert_before_n(data: T, neighbour: DListNode<T>) -> DListNode<T> {
246246
let mut nobe = self.new_link(move data);
247247
self.insert_left(nobe, neighbour);
248-
option::get(&nobe)
248+
option::get(nobe)
249249
}
250250
/**
251251
* Insert data into the middle of the list, right of the given node.
@@ -269,7 +269,7 @@ impl<T> DList<T> {
269269
fn insert_after_n(data: T, neighbour: DListNode<T>) -> DListNode<T> {
270270
let mut nobe = self.new_link(move data);
271271
self.insert_right(neighbour, nobe);
272-
option::get(&nobe)
272+
option::get(nobe)
273273
}
274274
275275
/// Remove a node from the head of the list. O(1).
@@ -385,17 +385,17 @@ impl<T> DList<T> {
385385
let mut link = self.peek_n();
386386
let mut rabbit = link;
387387
while option::is_some(&link) {
388-
let nobe = option::get(&link);
388+
let nobe = option::get(link);
389389
assert nobe.linked;
390390
// check cycle
391391
if option::is_some(&rabbit) {
392-
rabbit = option::get(&rabbit).next;
392+
rabbit = option::get(rabbit).next;
393393
}
394394
if option::is_some(&rabbit) {
395-
rabbit = option::get(&rabbit).next;
395+
rabbit = option::get(rabbit).next;
396396
}
397397
if option::is_some(&rabbit) {
398-
assert !box::ptr_eq(*option::get(&rabbit), *nobe);
398+
assert !box::ptr_eq(*option::get(rabbit), *nobe);
399399
}
400400
// advance
401401
link = nobe.next_link();
@@ -406,17 +406,17 @@ impl<T> DList<T> {
406406
link = self.peek_tail_n();
407407
rabbit = link;
408408
while option::is_some(&link) {
409-
let nobe = option::get(&link);
409+
let nobe = option::get(link);
410410
assert nobe.linked;
411411
// check cycle
412412
if option::is_some(&rabbit) {
413-
rabbit = option::get(&rabbit).prev;
413+
rabbit = option::get(rabbit).prev;
414414
}
415415
if option::is_some(&rabbit) {
416-
rabbit = option::get(&rabbit).prev;
416+
rabbit = option::get(rabbit).prev;
417417
}
418418
if option::is_some(&rabbit) {
419-
assert !box::ptr_eq(*option::get(&rabbit), *nobe);
419+
assert !box::ptr_eq(*option::get(rabbit), *nobe);
420420
}
421421
// advance
422422
link = nobe.prev_link();

src/libcore/iter-trait/dlist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub type IMPL_T<A> = dlist::DList<A>;
1111
pub pure fn EACH<A>(self: &IMPL_T<A>, f: fn(v: &A) -> bool) {
1212
let mut link = self.peek_n();
1313
while option::is_some(&link) {
14-
let nobe = option::get(&link);
14+
let nobe = option::get(link);
1515
assert nobe.linked;
1616
if !f(&nobe.data) { break; }
1717
// Check (weakly) that the user didn't do a remove.

src/libcore/option.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub enum Option<T> {
4242
Some(T),
4343
}
4444

45-
pub pure fn get<T: Copy>(opt: &Option<T>) -> T {
45+
pub pure fn get<T: Copy>(opt: Option<T>) -> T {
4646
/*!
4747
Gets the value out of an option
4848
@@ -58,7 +58,7 @@ pub pure fn get<T: Copy>(opt: &Option<T>) -> T {
5858
case explicitly.
5959
*/
6060

61-
match *opt {
61+
match opt {
6262
Some(copy x) => return x,
6363
None => fail ~"option::get none"
6464
}
@@ -85,7 +85,7 @@ pub pure fn get_ref<T>(opt: &r/Option<T>) -> &r/T {
8585
}
8686
}
8787

88-
pub pure fn expect<T: Copy>(opt: &Option<T>, reason: ~str) -> T {
88+
pub pure fn expect<T: Copy>(opt: Option<T>, reason: ~str) -> T {
8989
/*!
9090
* Gets the value out of an option, printing a specified message on
9191
* failure
@@ -94,7 +94,7 @@ pub pure fn expect<T: Copy>(opt: &Option<T>, reason: ~str) -> T {
9494
*
9595
* Fails if the value equals `none`
9696
*/
97-
match *opt { Some(copy x) => x, None => fail reason }
97+
match opt { Some(copy x) => x, None => fail reason }
9898
}
9999

100100
pub pure fn map<T, U>(opt: &Option<T>, f: fn(x: &T) -> U) -> Option<U> {
@@ -167,10 +167,10 @@ pub pure fn is_some<T>(opt: &Option<T>) -> bool {
167167
!is_none(opt)
168168
}
169169

170-
pub pure fn get_default<T: Copy>(opt: &Option<T>, def: T) -> T {
170+
pub pure fn get_default<T: Copy>(opt: Option<T>, def: T) -> T {
171171
//! Returns the contained value or a default
172172
173-
match *opt { Some(copy x) => x, None => def }
173+
match opt { Some(copy x) => x, None => def }
174174
}
175175

176176
pub pure fn map_default<T, U>(opt: &Option<T>, def: U,
@@ -284,8 +284,8 @@ impl<T: Copy> Option<T> {
284284
Instead, prefer to use pattern matching and handle the `None`
285285
case explicitly.
286286
*/
287-
pure fn get() -> T { get(&self) }
288-
pure fn get_default(def: T) -> T { get_default(&self, def) }
287+
pure fn get() -> T { get(self) }
288+
pure fn get_default(def: T) -> T { get_default(self, def) }
289289
/**
290290
* Gets the value out of an option, printing a specified message on
291291
* failure
@@ -294,7 +294,7 @@ impl<T: Copy> Option<T> {
294294
*
295295
* Fails if the value equals `none`
296296
*/
297-
pure fn expect(reason: ~str) -> T { expect(&self, move reason) }
297+
pure fn expect(reason: ~str) -> T { expect(self, move reason) }
298298
/// Applies a function zero or more times until the result is none.
299299
pure fn while_some(blk: fn(v: T) -> Option<T>) { while_some(self, blk) }
300300
}

src/libcore/os.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ pub fn tmpdir() -> Path {
473473
#[cfg(unix)]
474474
#[allow(non_implicitly_copyable_typarams)]
475475
fn lookup() -> Path {
476-
option::get_default(&getenv_nonempty("TMPDIR"),
476+
option::get_default(getenv_nonempty("TMPDIR"),
477477
Path("/tmp"))
478478
}
479479

src/libstd/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ mod tests {
723723
let map = map::HashMap::<~str, ~str>();
724724
assert (option::is_none(&map.find(key)));
725725
map.insert(key, ~"val");
726-
assert (option::get(&map.find(key)) == ~"val");
726+
assert (option::get(map.find(key)) == ~"val");
727727
}
728728

729729
#[test]

src/rustc/middle/trans/alt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
353353
match p.node {
354354
ast::pat_enum(_, subpats) => {
355355
if opt_eq(tcx, &variant_opt(tcx, p.id), opt) {
356-
Some(option::get_default(&subpats,
356+
Some(option::get_default(subpats,
357357
vec::from_elem(variant_size,
358358
dummy)))
359359
} else {

src/rustc/middle/trans/meth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ fn trans_static_method_callee(bcx: block,
299299

300300
fn method_from_methods(ms: ~[@ast::method], name: ast::ident)
301301
-> ast::def_id {
302-
local_def(option::get(&vec::find(ms, |m| m.ident == name)).id)
302+
local_def(option::get(vec::find(ms, |m| m.ident == name)).id)
303303
}
304304

305305
fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id,

src/rustc/middle/trans/monomorphize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ fn monomorphic_fn(ccx: @crate_ctxt,
113113

114114
ccx.stats.n_monos += 1;
115115

116-
let depth = option::get_default(&ccx.monomorphizing.find(fn_id), 0u);
116+
let depth = option::get_default(ccx.monomorphizing.find(fn_id), 0u);
117117
// Random cut-off -- code that needs to instantiate the same function
118118
// recursively more than ten times can probably safely be assumed to be
119119
// causing an infinite expansion.
@@ -158,7 +158,7 @@ fn monomorphic_fn(ccx: @crate_ctxt,
158158
}
159159
ast_map::node_variant(v, enum_item, _) => {
160160
let tvs = ty::enum_variants(ccx.tcx, local_def(enum_item.id));
161-
let this_tv = option::get(&vec::find(*tvs, |tv| {
161+
let this_tv = option::get(vec::find(*tvs, |tv| {
162162
tv.id.node == fn_id.node}));
163163
let d = mk_lldecl();
164164
set_inline_hint(d);

src/rustc/middle/trans/reflect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl reflector {
5757

5858
fn visit(ty_name: ~str, args: ~[ValueRef]) {
5959
let tcx = self.bcx.tcx();
60-
let mth_idx = option::get(&ty::method_idx(
60+
let mth_idx = option::get(ty::method_idx(
6161
tcx.sess.ident_of(~"visit_" + ty_name),
6262
*self.visitor_methods));
6363
let mth_ty = ty::mk_fn(tcx, self.visitor_methods[mth_idx].fty);

src/rustdoc/attr_pass.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn fold_crate(
5252
{
5353
topmod: doc::ModDoc_({
5454
item: {
55-
name: option::get_default(&attrs.name, doc.topmod.name()),
55+
name: option::get_default(attrs.name, doc.topmod.name()),
5656
.. doc.topmod.item
5757
},
5858
.. *doc.topmod
@@ -151,7 +151,7 @@ fn fold_enum(
151151
node: ast::item_enum(enum_definition, _), _
152152
}, _) => {
153153
let ast_variant = option::get(
154-
&vec::find(enum_definition.variants, |v| {
154+
vec::find(enum_definition.variants, |v| {
155155
to_str(v.node.name) == variant.name
156156
}));
157157

src/rustdoc/doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ impl IndexEntry : cmp::Eq {
377377

378378
impl Doc {
379379
fn CrateDoc() -> CrateDoc {
380-
option::get(&vec::foldl(None, self.pages, |_m, page| {
380+
option::get(vec::foldl(None, self.pages, |_m, page| {
381381
match *page {
382382
doc::CratePage(doc) => Some(doc),
383383
_ => None

src/test/run-pass/test-ignore-cfg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ fn checktests() {
2020
let tests = __test::tests();
2121

2222
let shouldignore = option::get(
23-
&vec::find(tests, |t| t.name == ~"shouldignore" ));
23+
vec::find(tests, |t| t.name == ~"shouldignore" ));
2424
assert shouldignore.ignore == true;
2525

2626
let shouldnotignore = option::get(
27-
&vec::find(tests, |t| t.name == ~"shouldnotignore" ));
27+
vec::find(tests, |t| t.name == ~"shouldnotignore" ));
2828
assert shouldnotignore.ignore == false;
2929
}

0 commit comments

Comments
 (0)