mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-28 20:16:58 +03:00
Use unsized_feature_enabled helper function
This commit is contained in:
@@ -974,6 +974,11 @@ fn new(
|
||||
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 @@ fn check_stmt(&mut self, body: &Body<'tcx>, stmt: &Statement<'tcx>, location: Lo
|
||||
}
|
||||
|
||||
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 @@ fn check_call_dest(
|
||||
|
||||
// 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 @@ fn check_local(&mut self, body: &Body<'tcx>, local: Local, local_decl: &LocalDec
|
||||
|
||||
// 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 @@ fn check_rvalue(&mut self, body: &Body<'tcx>, rvalue: &Rvalue<'tcx>, location: L
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user