@@ -974,6 +974,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
974
974
checker
975
975
}
976
976
977
+ fn unsized_feature_enabled ( & self ) -> bool {
978
+ let features = self . tcx ( ) . features ( ) ;
979
+ features. unsized_locals || features. unsized_fn_params
980
+ }
981
+
977
982
/// Equate the inferred type and the annotated type for user type annotations
978
983
fn check_user_type_annotations ( & mut self ) {
979
984
debug ! (
@@ -1456,9 +1461,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1456
1461
}
1457
1462
1458
1463
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 ( ) {
1462
1465
let trait_ref = ty:: TraitRef {
1463
1466
def_id : tcx. require_lang_item ( LangItem :: Sized , Some ( self . last_span ) ) ,
1464
1467
substs : tcx. mk_substs_trait ( place_ty, & [ ] ) ,
@@ -1721,7 +1724,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1721
1724
1722
1725
// When `unsized_fn_params` and `unsized_locals` are both not enabled,
1723
1726
// 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 ( ) {
1725
1728
let span = term. source_info . span ;
1726
1729
self . ensure_place_sized ( dest_ty, span) ;
1727
1730
}
@@ -1884,7 +1887,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1884
1887
1885
1888
// When `unsized_fn_params` or `unsized_locals` is enabled, only function calls
1886
1889
// 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 ( ) {
1888
1891
let span = local_decl. source_info . span ;
1889
1892
let ty = local_decl. ty ;
1890
1893
self . ensure_place_sized ( ty, span) ;
@@ -2026,7 +2029,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
2026
2029
2027
2030
Rvalue :: NullaryOp ( _, ty) => {
2028
2031
// 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 ( ) {
2030
2033
let span = body. source_info ( location) . span ;
2031
2034
self . ensure_place_sized ( ty, span) ;
2032
2035
}
0 commit comments