Skip to content

Commit fe72752

Browse files
committed
---
yaml --- r: 80722 b: refs/heads/try c: e6c1131 h: refs/heads/master v: v3
1 parent ce8d8a2 commit fe72752

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 4c6bf4872012c010f84dc7fa2cdfe87522533f89
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cbd1eefbd350797b783df119fed7956d7e1c74ad
5-
refs/heads/try: f1374a7044d844fb1f89b651bf4c628ac32ed48a
5+
refs/heads/try: e6c11313c88574aa2500df2f76c5534fbc2e0512
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/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(~[])
176+
.unwrap_or_default()
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(~[])
225+
.unwrap_or_default()
226226
.map(|_| ty::mk_err());
227227
}
228228
}

branches/try/src/libstd/option.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,26 @@ impl<T> Option<T> {
350350
}
351351
}
352352

353+
impl<T: Default> Option<T> {
354+
/// Returns the contained value or default (for this type)
355+
#[inline]
356+
pub fn unwrap_or_default(self) -> T {
357+
match self {
358+
Some(x) => x,
359+
None => Default::default()
360+
}
361+
}
362+
363+
/// Returns self or `Some`-wrapped default value
364+
#[inline]
365+
pub fn or_default(self) -> Option<T> {
366+
match self {
367+
None => Some(Default::default()),
368+
x => x,
369+
}
370+
}
371+
}
372+
353373
impl<T> Default for Option<T> {
354374
fn default() -> Option<T> { None }
355375
}

branches/try/src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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(opt_vec::Empty);
3464+
let bounds = opt_bounds.unwrap_or_default();
34653465
ast::TyParam { ident: ident, id: ast::DUMMY_NODE_ID, bounds: bounds }
34663466
}
34673467

0 commit comments

Comments
 (0)