From 45c62c08f9740dfcdf64c64c8b183acfc22fb3d6 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Mon, 9 Sep 2013 19:57:08 -0700 Subject: [PATCH] std: rename Option::unwrap_or_default() to unwrap_or() --- src/compiletest/compiletest.rs | 2 +- src/libextra/glob.rs | 2 +- src/librustc/driver/driver.rs | 6 +++--- src/librustc/middle/privacy.rs | 3 +-- src/librustc/middle/typeck/check/_match.rs | 4 ++-- src/librustdoc/attr_pass.rs | 2 +- src/librustdoc/config.rs | 2 +- src/libstd/at_vec.rs | 2 +- src/libstd/option.rs | 2 +- src/libstd/os.rs | 2 +- src/libstd/vec.rs | 2 +- src/libsyntax/parse/parser.rs | 8 ++++---- 12 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index df0462203a9..166638bc359 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -309,7 +309,7 @@ pub fn make_test_name(config: &config, testfile: &Path) -> test::TestName { let filename = path.filename(); let p = path.pop(); let dir = p.filename(); - fmt!("%s/%s", dir.unwrap_or_default(""), filename.unwrap_or_default("")) + fmt!("%s/%s", dir.unwrap_or(""), filename.unwrap_or("")) } test::DynTestName(fmt!("[%s] %s", diff --git a/src/libextra/glob.rs b/src/libextra/glob.rs index 07386b41caa..984a09aed3e 100644 --- a/src/libextra/glob.rs +++ b/src/libextra/glob.rs @@ -312,7 +312,7 @@ impl Pattern { let require_literal = |c| { (options.require_literal_separator && is_sep(c)) || (options.require_literal_leading_dot && c == '.' - && is_sep(prev_char.unwrap_or_default('/'))) + && is_sep(prev_char.unwrap_or('/'))) }; for (ti, token) in self.tokens.slice_from(i).iter().enumerate() { diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index 0fd93d65b70..1841e25ee95 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -681,9 +681,9 @@ pub fn build_session_options(binary: @str, link::output_type_bitcode } else { link::output_type_exe }; let sysroot_opt = getopts::opt_maybe_str(matches, "sysroot").map_move(|m| @Path(m)); - let target = getopts::opt_maybe_str(matches, "target").unwrap_or_default(host_triple()); - let target_cpu = getopts::opt_maybe_str(matches, "target-cpu").unwrap_or_default(~"generic"); - let target_feature = getopts::opt_maybe_str(matches, "target-feature").unwrap_or_default(~""); + let target = getopts::opt_maybe_str(matches, "target").unwrap_or(host_triple()); + let target_cpu = getopts::opt_maybe_str(matches, "target-cpu").unwrap_or(~"generic"); + let target_feature = getopts::opt_maybe_str(matches, "target-feature").unwrap_or(~""); let save_temps = getopts::opt_present(matches, "save-temps"); let opt_level = { if (debugging_opts & session::no_opt) != 0 { diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index b6b03d8369a..51fe2acc72a 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -221,8 +221,7 @@ impl PrivacyVisitor { // If the method is a default method, we need to use the def_id of // the default implementation. // Having to do this this is really unfortunate. - let method_id = ty::method(self.tcx, method_id).provided_source - .unwrap_or_default(method_id); + let method_id = ty::method(self.tcx, method_id).provided_source.unwrap_or(method_id); if method_id.crate == LOCAL_CRATE { let is_private = self.method_is_private(span, method_id.node); diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index 196057e09f7..f08694e4437 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -173,7 +173,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::Pat, path: &ast::Path, fcx.write_error(pat.id); kind_name = "[error]"; arg_types = (*subpats).clone() - .unwrap_or_default(~[]) + .unwrap_or(~[]) .map(|_| ty::mk_err()); } } @@ -222,7 +222,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::Pat, path: &ast::Path, fcx.write_error(pat.id); kind_name = "[error]"; arg_types = (*subpats).clone() - .unwrap_or_default(~[]) + .unwrap_or(~[]) .map(|_| ty::mk_err()); } } diff --git a/src/librustdoc/attr_pass.rs b/src/librustdoc/attr_pass.rs index 2e7c73d3421..bd8d9a65cd3 100644 --- a/src/librustdoc/attr_pass.rs +++ b/src/librustdoc/attr_pass.rs @@ -68,7 +68,7 @@ fn fold_crate( doc::CrateDoc { topmod: doc::ModDoc { item: doc::ItemDoc { - name: attrs.name.clone().unwrap_or_default(doc.topmod.name_()), + name: attrs.name.clone().unwrap_or(doc.topmod.name_()), .. doc.topmod.item.clone() }, .. doc.topmod.clone() diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index e6d80e1443b..c8dd38394c9 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -142,7 +142,7 @@ fn config_from_opts( let output_dir = getopts::opt_maybe_str(matches, opt_output_dir()); let output_dir = output_dir.map_move(|s| Path(s)); result::Ok(Config { - output_dir: output_dir.unwrap_or_default(config.output_dir.clone()), + output_dir: output_dir.unwrap_or(config.output_dir.clone()), .. config }) }; diff --git a/src/libstd/at_vec.rs b/src/libstd/at_vec.rs index a4e841f98f8..ce8e90e1a43 100644 --- a/src/libstd/at_vec.rs +++ b/src/libstd/at_vec.rs @@ -45,7 +45,7 @@ pub fn capacity(v: @[T]) -> uint { #[inline] pub fn build(size: Option, builder: &fn(push: &fn(v: A))) -> @[A] { let mut vec = @[]; - unsafe { raw::reserve(&mut vec, size.unwrap_or_default(4)); } + unsafe { raw::reserve(&mut vec, size.unwrap_or(4)); } builder(|x| unsafe { raw::push(&mut vec, x) }); vec } diff --git a/src/libstd/option.rs b/src/libstd/option.rs index b72046cce72..5ac6fcda043 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -332,7 +332,7 @@ impl Option { /// Returns the contained value or a default #[inline] - pub fn unwrap_or_default(self, def: T) -> T { + pub fn unwrap_or(self, def: T) -> T { match self { Some(x) => x, None => def diff --git a/src/libstd/os.rs b/src/libstd/os.rs index ab1210aabad..95a75b84923 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -611,7 +611,7 @@ pub fn tmpdir() -> Path { if cfg!(target_os = "android") { Path("/data/tmp") } else { - getenv_nonempty("TMPDIR").unwrap_or_default(Path("/tmp")) + getenv_nonempty("TMPDIR").unwrap_or(Path("/tmp")) } } diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 1ff58351886..55b8e3769ea 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -205,7 +205,7 @@ pub fn with_capacity(capacity: uint) -> ~[T] { */ #[inline] pub fn build(size: Option, builder: &fn(push: &fn(v: A))) -> ~[A] { - let mut vec = with_capacity(size.unwrap_or_default(4)); + let mut vec = with_capacity(size.unwrap_or(4)); builder(|x| vec.push(x)); vec } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index b5772a9eede..8725a0426f7 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -802,7 +802,7 @@ impl Parser { */ let opt_abis = self.parse_opt_abis(); - let abis = opt_abis.unwrap_or_default(AbiSet::Rust()); + let abis = opt_abis.unwrap_or(AbiSet::Rust()); let purity = self.parse_unsafety(); self.expect_keyword(keywords::Fn); let (decl, lifetimes) = self.parse_ty_fn_decl(); @@ -3461,7 +3461,7 @@ impl Parser { let ident = self.parse_ident(); let opt_bounds = self.parse_optional_ty_param_bounds(); // For typarams we don't care about the difference b/w "" and "". - let bounds = opt_bounds.unwrap_or_default(opt_vec::Empty); + let bounds = opt_bounds.unwrap_or(opt_vec::Empty); ast::TyParam { ident: ident, id: ast::DUMMY_NODE_ID, bounds: bounds } } @@ -4363,7 +4363,7 @@ impl Parser { self.obsolete(*self.last_span, ObsoleteExternVisibility); } - let abis = opt_abis.unwrap_or_default(AbiSet::C()); + let abis = opt_abis.unwrap_or(AbiSet::C()); let (inner, next) = self.parse_inner_attrs_and_next(); let m = self.parse_foreign_mod_items(sort, abis, next); @@ -4640,7 +4640,7 @@ impl Parser { if self.eat_keyword(keywords::Fn) { // EXTERN FUNCTION ITEM - let abis = opt_abis.unwrap_or_default(AbiSet::C()); + let abis = opt_abis.unwrap_or(AbiSet::C()); let (ident, item_, extra_attrs) = self.parse_item_fn(extern_fn, abis); return iovi_item(self.mk_item(lo, self.last_span.hi, ident,