@@ -974,6 +974,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
974974 checker
975975 }
976976
977+ fn unsized_feature_enabled ( & self ) -> bool {
978+ let features = self . tcx ( ) . features ( ) ;
979+ features. unsized_locals || features. unsized_fn_params
980+ }
981+
977982 /// Equate the inferred type and the annotated type for user type annotations
978983 fn check_user_type_annotations ( & mut self ) {
979984 debug ! (
@@ -1456,9 +1461,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
14561461 }
14571462
14581463 self . check_rvalue ( body, rv, location) ;
1459- if !( self . tcx ( ) . features ( ) . unsized_locals
1460- || self . tcx ( ) . features ( ) . unsized_fn_params )
1461- {
1464+ if !self . unsized_feature_enabled ( ) {
14621465 let trait_ref = ty:: TraitRef {
14631466 def_id : tcx. require_lang_item ( LangItem :: Sized , Some ( self . last_span ) ) ,
14641467 substs : tcx. mk_substs_trait ( place_ty, & [ ] ) ,
@@ -1721,7 +1724,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
17211724
17221725 // When `unsized_fn_params` and `unsized_locals` are both not enabled,
17231726 // this check is done at `check_local`.
1724- if self . tcx ( ) . features ( ) . unsized_locals || self . tcx ( ) . features ( ) . unsized_fn_params {
1727+ if self . unsized_feature_enabled ( ) {
17251728 let span = term. source_info . span ;
17261729 self . ensure_place_sized ( dest_ty, span) ;
17271730 }
@@ -1884,7 +1887,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
18841887
18851888 // When `unsized_fn_params` or `unsized_locals` is enabled, only function calls
18861889 // and nullary ops are checked in `check_call_dest`.
1887- if !( self . tcx ( ) . features ( ) . unsized_locals || self . tcx ( ) . features ( ) . unsized_fn_params ) {
1890+ if !self . unsized_feature_enabled ( ) {
18881891 let span = local_decl. source_info . span ;
18891892 let ty = local_decl. ty ;
18901893 self . ensure_place_sized ( ty, span) ;
@@ -2026,7 +2029,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
20262029
20272030 Rvalue :: NullaryOp ( _, ty) => {
20282031 // Even with unsized locals cannot box an unsized value.
2029- if self . tcx ( ) . features ( ) . unsized_locals || self . tcx ( ) . features ( ) . unsized_fn_params {
2032+ if self . unsized_feature_enabled ( ) {
20302033 let span = body. source_info ( location) . span ;
20312034 self . ensure_place_sized ( ty, span) ;
20322035 }
0 commit comments