]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #55014 - ljedrz:lazyboye_unwraps, r=matthewjasper
authorbors <bors@rust-lang.org>
Sat, 20 Oct 2018 11:22:48 +0000 (11:22 +0000)
committerbors <bors@rust-lang.org>
Sat, 20 Oct 2018 11:22:48 +0000 (11:22 +0000)
Prefer unwrap_or_else to unwrap_or in case of function calls/allocations

The contents of `unwrap_or` are evaluated eagerly, so it's not a good pick in case of function calls and allocations. This PR also changes a few `unwrap_or`s with `unwrap_or_default`.

An added bonus is that in some cases this change also reveals if the object it's called on is an `Option` or a `Result` (based on whether the closure takes an argument).

15 files changed:
1  2 
src/librustc/hir/lowering.rs
src/librustc/lint/levels.rs
src/librustc/traits/auto_trait.rs
src/librustc/traits/error_reporting.rs
src/librustc/ty/context.rs
src/librustc/ty/query/on_disk_cache.rs
src/librustc_codegen_llvm/attributes.rs
src/librustc_metadata/locator.rs
src/librustc_mir/borrow_check/error_reporting.rs
src/librustc_mir/transform/elaborate_drops.rs
src/librustc_resolve/resolve_imports.rs
src/librustc_save_analysis/dump_visitor.rs
src/librustc_typeck/check/method/suggest.rs
src/librustc_typeck/check/mod.rs
src/libsyntax/source_map.rs

Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge