diff options
| author | bors <bors@rust-lang.org> | 2013-08-05 16:47:01 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-08-05 16:47:01 -0700 |
| commit | bbda3fa9383dba653b20bd064102caceef91897a (patch) | |
| tree | 8fa4abc474568ca3a63992b5eea6cf62b7e04259 /src/libsyntax/parse | |
| parent | 29099e450a912cfcd0a0ccc72f55751bc2e209f2 (diff) | |
| parent | 0ac7a219f043d3b1c8c239089d9dd6e6c9fa830b (diff) | |
| download | rust-bbda3fa9383dba653b20bd064102caceef91897a.tar.gz rust-bbda3fa9383dba653b20bd064102caceef91897a.zip | |
auto merge of #8288 : Kimundi/rust/opteitres4, r=brson
This is an alternative version to https://github.com/mozilla/rust/pull/8268, where instead of transitioning to `get()` completely, I transitioned to `unwrap()` completely. My reasoning for also opening this PR is that having two different functions with identical behavior on a common datatype is bad for consistency and confusing for users, and should be solved as soon as possible. The fact that apparently half the code uses `get()`, and the other half `unwrap()` only makes it worse. If the final naming decision ends up different, there needs to be a big renaming anyway, but until then it should at least be consistent. --- - Made naming schemes consistent between Option, Result and Either - Lifted the quality of the either and result module to that of option - Changed Options Add implementation to work like the maybe Monad (return None if any of the inputs is None) See https://github.com/mozilla/rust/issues/6002, especially my last comment. - Removed duplicate Option::get and renamed all related functions to use the term `unwrap` instead See also https://github.com/mozilla/rust/issues/7887. Todo: Adding testcases for all function in the three modules. Even without the few functions I added, the coverage wasn't complete to begin with. But I'd rather do that as a follow up PR, I've touched to much code here already, need to go through them again later.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index afa2e7a5e42..a0932729930 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -691,7 +691,7 @@ impl Parser { */ let opt_abis = self.parse_opt_abis(); - let abis = opt_abis.get_or_default(AbiSet::Rust()); + let abis = opt_abis.unwrap_or_default(AbiSet::Rust()); let purity = self.parse_unsafety(); self.expect_keyword(keywords::Fn); let (decl, lifetimes) = self.parse_ty_fn_decl(); @@ -3326,7 +3326,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 "<T>" and "<T:>". - let bounds = opt_bounds.get_or_default(opt_vec::Empty); + let bounds = opt_bounds.unwrap_or_default(opt_vec::Empty); ast::TyParam { ident: ident, id: self.get_id(), bounds: bounds } } @@ -4196,7 +4196,7 @@ impl Parser { self.obsolete(*self.last_span, ObsoleteExternVisibility); } - let abis = opt_abis.get_or_default(AbiSet::C()); + let abis = opt_abis.unwrap_or_default(AbiSet::C()); let (inner, next) = self.parse_inner_attrs_and_next(); let m = self.parse_foreign_mod_items(sort, abis, next); @@ -4463,7 +4463,7 @@ impl Parser { if self.eat_keyword(keywords::Fn) { // EXTERN FUNCTION ITEM - let abis = opt_abis.get_or_default(AbiSet::C()); + let abis = opt_abis.unwrap_or_default(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, |
