Skip to content

Commit 45c62c0

Browse files
committed
std: rename Option::unwrap_or_default() to unwrap_or()
1 parent 761ae00 commit 45c62c0

File tree

12 files changed

+18
-19
lines changed

12 files changed

+18
-19
lines changed

src/compiletest/compiletest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ pub fn make_test_name(config: &config, testfile: &Path) -> test::TestName {
309309
let filename = path.filename();
310310
let p = path.pop();
311311
let dir = p.filename();
312-
fmt!("%s/%s", dir.unwrap_or_default(""), filename.unwrap_or_default(""))
312+
fmt!("%s/%s", dir.unwrap_or(""), filename.unwrap_or(""))
313313
}
314314

315315
test::DynTestName(fmt!("[%s] %s",

src/libextra/glob.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl Pattern {
312312
let require_literal = |c| {
313313
(options.require_literal_separator && is_sep(c)) ||
314314
(options.require_literal_leading_dot && c == '.'
315-
&& is_sep(prev_char.unwrap_or_default('/')))
315+
&& is_sep(prev_char.unwrap_or('/')))
316316
};
317317
318318
for (ti, token) in self.tokens.slice_from(i).iter().enumerate() {

src/librustc/driver/driver.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -681,9 +681,9 @@ pub fn build_session_options(binary: @str,
681681
link::output_type_bitcode
682682
} else { link::output_type_exe };
683683
let sysroot_opt = getopts::opt_maybe_str(matches, "sysroot").map_move(|m| @Path(m));
684-
let target = getopts::opt_maybe_str(matches, "target").unwrap_or_default(host_triple());
685-
let target_cpu = getopts::opt_maybe_str(matches, "target-cpu").unwrap_or_default(~"generic");
686-
let target_feature = getopts::opt_maybe_str(matches, "target-feature").unwrap_or_default(~"");
684+
let target = getopts::opt_maybe_str(matches, "target").unwrap_or(host_triple());
685+
let target_cpu = getopts::opt_maybe_str(matches, "target-cpu").unwrap_or(~"generic");
686+
let target_feature = getopts::opt_maybe_str(matches, "target-feature").unwrap_or(~"");
687687
let save_temps = getopts::opt_present(matches, "save-temps");
688688
let opt_level = {
689689
if (debugging_opts & session::no_opt) != 0 {

src/librustc/middle/privacy.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,7 @@ impl PrivacyVisitor {
221221
// If the method is a default method, we need to use the def_id of
222222
// the default implementation.
223223
// Having to do this this is really unfortunate.
224-
let method_id = ty::method(self.tcx, method_id).provided_source
225-
.unwrap_or_default(method_id);
224+
let method_id = ty::method(self.tcx, method_id).provided_source.unwrap_or(method_id);
226225

227226
if method_id.crate == LOCAL_CRATE {
228227
let is_private = self.method_is_private(span, method_id.node);

src/librustc/middle/typeck/check/_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::Pat, path: &ast::Path,
173173
fcx.write_error(pat.id);
174174
kind_name = "[error]";
175175
arg_types = (*subpats).clone()
176-
.unwrap_or_default(~[])
176+
.unwrap_or(~[])
177177
.map(|_| ty::mk_err());
178178
}
179179
}
@@ -222,7 +222,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::Pat, path: &ast::Path,
222222
fcx.write_error(pat.id);
223223
kind_name = "[error]";
224224
arg_types = (*subpats).clone()
225-
.unwrap_or_default(~[])
225+
.unwrap_or(~[])
226226
.map(|_| ty::mk_err());
227227
}
228228
}

src/librustdoc/attr_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn fold_crate(
6868
doc::CrateDoc {
6969
topmod: doc::ModDoc {
7070
item: doc::ItemDoc {
71-
name: attrs.name.clone().unwrap_or_default(doc.topmod.name_()),
71+
name: attrs.name.clone().unwrap_or(doc.topmod.name_()),
7272
.. doc.topmod.item.clone()
7373
},
7474
.. doc.topmod.clone()

src/librustdoc/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ fn config_from_opts(
142142
let output_dir = getopts::opt_maybe_str(matches, opt_output_dir());
143143
let output_dir = output_dir.map_move(|s| Path(s));
144144
result::Ok(Config {
145-
output_dir: output_dir.unwrap_or_default(config.output_dir.clone()),
145+
output_dir: output_dir.unwrap_or(config.output_dir.clone()),
146146
.. config
147147
})
148148
};

src/libstd/at_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn capacity<T>(v: @[T]) -> uint {
4545
#[inline]
4646
pub fn build<A>(size: Option<uint>, builder: &fn(push: &fn(v: A))) -> @[A] {
4747
let mut vec = @[];
48-
unsafe { raw::reserve(&mut vec, size.unwrap_or_default(4)); }
48+
unsafe { raw::reserve(&mut vec, size.unwrap_or(4)); }
4949
builder(|x| unsafe { raw::push(&mut vec, x) });
5050
vec
5151
}

src/libstd/option.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ impl<T> Option<T> {
332332

333333
/// Returns the contained value or a default
334334
#[inline]
335-
pub fn unwrap_or_default(self, def: T) -> T {
335+
pub fn unwrap_or(self, def: T) -> T {
336336
match self {
337337
Some(x) => x,
338338
None => def

src/libstd/os.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ pub fn tmpdir() -> Path {
611611
if cfg!(target_os = "android") {
612612
Path("/data/tmp")
613613
} else {
614-
getenv_nonempty("TMPDIR").unwrap_or_default(Path("/tmp"))
614+
getenv_nonempty("TMPDIR").unwrap_or(Path("/tmp"))
615615
}
616616
}
617617

src/libstd/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ pub fn with_capacity<T>(capacity: uint) -> ~[T] {
205205
*/
206206
#[inline]
207207
pub fn build<A>(size: Option<uint>, builder: &fn(push: &fn(v: A))) -> ~[A] {
208-
let mut vec = with_capacity(size.unwrap_or_default(4));
208+
let mut vec = with_capacity(size.unwrap_or(4));
209209
builder(|x| vec.push(x));
210210
vec
211211
}

src/libsyntax/parse/parser.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ impl Parser {
802802
*/
803803

804804
let opt_abis = self.parse_opt_abis();
805-
let abis = opt_abis.unwrap_or_default(AbiSet::Rust());
805+
let abis = opt_abis.unwrap_or(AbiSet::Rust());
806806
let purity = self.parse_unsafety();
807807
self.expect_keyword(keywords::Fn);
808808
let (decl, lifetimes) = self.parse_ty_fn_decl();
@@ -3461,7 +3461,7 @@ impl Parser {
34613461
let ident = self.parse_ident();
34623462
let opt_bounds = self.parse_optional_ty_param_bounds();
34633463
// For typarams we don't care about the difference b/w "<T>" and "<T:>".
3464-
let bounds = opt_bounds.unwrap_or_default(opt_vec::Empty);
3464+
let bounds = opt_bounds.unwrap_or(opt_vec::Empty);
34653465
ast::TyParam { ident: ident, id: ast::DUMMY_NODE_ID, bounds: bounds }
34663466
}
34673467

@@ -4363,7 +4363,7 @@ impl Parser {
43634363
self.obsolete(*self.last_span, ObsoleteExternVisibility);
43644364
}
43654365

4366-
let abis = opt_abis.unwrap_or_default(AbiSet::C());
4366+
let abis = opt_abis.unwrap_or(AbiSet::C());
43674367

43684368
let (inner, next) = self.parse_inner_attrs_and_next();
43694369
let m = self.parse_foreign_mod_items(sort, abis, next);
@@ -4640,7 +4640,7 @@ impl Parser {
46404640

46414641
if self.eat_keyword(keywords::Fn) {
46424642
// EXTERN FUNCTION ITEM
4643-
let abis = opt_abis.unwrap_or_default(AbiSet::C());
4643+
let abis = opt_abis.unwrap_or(AbiSet::C());
46444644
let (ident, item_, extra_attrs) =
46454645
self.parse_item_fn(extern_fn, abis);
46464646
return iovi_item(self.mk_item(lo, self.last_span.hi, ident,

0 commit comments

Comments
 (0)