about summary refs log tree commit diff
path: root/src/librustc/ty
diff options
context:
space:
mode:
authorljedrz <ljedrz@gmail.com>2018-10-12 16:16:00 +0200
committerljedrz <ljedrz@gmail.com>2018-10-19 09:45:45 +0200
commitd28aed6dc45ffccc790469cb04f3f775ddb2283a (patch)
treec1a3c356ba1ffc8173746e03f0f630ae4032624f /src/librustc/ty
parentcb5e1b93e300cf9772a24c6de27d9f21cdae3123 (diff)
downloadrust-d28aed6dc45ffccc790469cb04f3f775ddb2283a.tar.gz
rust-d28aed6dc45ffccc790469cb04f3f775ddb2283a.zip
Prefer unwrap_or_else to unwrap_or in case of function calls/allocations
Diffstat (limited to 'src/librustc/ty')
-rw-r--r--src/librustc/ty/context.rs2
-rw-r--r--src/librustc/ty/query/on_disk_cache.rs2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs
index 1bccd05af83..29474032ddc 100644
--- a/src/librustc/ty/context.rs
+++ b/src/librustc/ty/context.rs
@@ -565,7 +565,7 @@ impl<'tcx> TypeckTables<'tcx> {
 
     pub fn node_substs(&self, id: hir::HirId) -> &'tcx Substs<'tcx> {
         validate_hir_id_for_typeck_tables(self.local_id_root, id, false);
-        self.node_substs.get(&id.local_id).cloned().unwrap_or(Substs::empty())
+        self.node_substs.get(&id.local_id).cloned().unwrap_or_else(|| Substs::empty())
     }
 
     pub fn node_substs_opt(&self, id: hir::HirId) -> Option<&'tcx Substs<'tcx>> {
diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs
index ce580c78033..368ec9bbaf5 100644
--- a/src/librustc/ty/query/on_disk_cache.rs
+++ b/src/librustc/ty/query/on_disk_cache.rs
@@ -342,7 +342,7 @@ impl<'sess> OnDiskCache<'sess> {
             &self.prev_diagnostics_index,
             "diagnostics");
 
-        diagnostics.unwrap_or(Vec::new())
+        diagnostics.unwrap_or_default()
     }
 
     /// Store a diagnostic emitted during the current compilation session.