about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSantiago Pastorino <spastorino@gmail.com>2020-10-21 07:50:15 -0300
committerSantiago Pastorino <spastorino@gmail.com>2020-10-27 14:45:42 -0300
commit00fd703eb7cd0c9e23d76f0cf0f13c07388dd273 (patch)
tree078059c751c0af3977cd48913faf492f2d3c3f52
parent9584b00b1dc15c6d8211125d959cbaa1d93c0228 (diff)
downloadrust-00fd703eb7cd0c9e23d76f0cf0f13c07388dd273.tar.gz
rust-00fd703eb7cd0c9e23d76f0cf0f13c07388dd273.zip
Use unsized_feature_enabled helper function
-rw-r--r--compiler/rustc_mir/src/borrow_check/type_check/mod.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs
index 48b43e8de52..409399094e8 100644
--- a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs
+++ b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs
@@ -974,6 +974,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
         checker
     }
 
+    fn unsized_feature_enabled(&self) -> bool {
+        let features = self.tcx().features();
+        features.unsized_locals || features.unsized_fn_params
+    }
+
     /// Equate the inferred type and the annotated type for user type annotations
     fn check_user_type_annotations(&mut self) {
         debug!(
@@ -1456,9 +1461,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
                 }
 
                 self.check_rvalue(body, rv, location);
-                if !(self.tcx().features().unsized_locals
-                    || self.tcx().features().unsized_fn_params)
-                {
+                if !self.unsized_feature_enabled() {
                     let trait_ref = ty::TraitRef {
                         def_id: tcx.require_lang_item(LangItem::Sized, Some(self.last_span)),
                         substs: tcx.mk_substs_trait(place_ty, &[]),
@@ -1721,7 +1724,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
 
                 // When `unsized_fn_params` and `unsized_locals` are both not enabled,
                 // this check is done at `check_local`.
-                if self.tcx().features().unsized_locals || self.tcx().features().unsized_fn_params {
+                if self.unsized_feature_enabled() {
                     let span = term.source_info.span;
                     self.ensure_place_sized(dest_ty, span);
                 }
@@ -1884,7 +1887,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
 
         // When `unsized_fn_params` or `unsized_locals` is enabled, only function calls
         // and nullary ops are checked in `check_call_dest`.
-        if !(self.tcx().features().unsized_locals || self.tcx().features().unsized_fn_params) {
+        if !self.unsized_feature_enabled() {
             let span = local_decl.source_info.span;
             let ty = local_decl.ty;
             self.ensure_place_sized(ty, span);
@@ -2026,7 +2029,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
 
             Rvalue::NullaryOp(_, ty) => {
                 // Even with unsized locals cannot box an unsized value.
-                if self.tcx().features().unsized_locals || self.tcx().features().unsized_fn_params {
+                if self.unsized_feature_enabled() {
                     let span = body.source_info(location).span;
                     self.ensure_place_sized(ty, span);
                 }