Skip to content

Commit 690edba

Browse files
Rollup merge of rust-lang#154036 - RalfJung:unsized-locals-helper-rm, r=nnethercote
borrowck/type_check: remove helper left-over from unsized locals This used to check two features, but ever since rust-lang#141811 it's only one so there's no reason any more to have a helper function here.
2 parents 94386a3 + 38aa322 commit 690edba

File tree

1 file changed

+7
-10
lines changed
  • compiler/rustc_borrowck/src/type_check

1 file changed

+7
-10
lines changed

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
374374
self.body
375375
}
376376

377-
fn unsized_feature_enabled(&self) -> bool {
378-
self.tcx().features().unsized_fn_params()
379-
}
380-
381377
/// Equate the inferred type and the annotated type for user type annotations
382378
#[instrument(skip(self), level = "debug")]
383379
fn check_user_type_annotations(&mut self) {
@@ -660,7 +656,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
660656
);
661657
}
662658

663-
if !self.unsized_feature_enabled() {
659+
if !self.tcx().features().unsized_fn_params() {
664660
let trait_ref = ty::TraitRef::new(
665661
tcx,
666662
tcx.require_lang_item(LangItem::Sized, self.last_span),
@@ -936,9 +932,10 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
936932
}
937933
}
938934

939-
// When `unsized_fn_params` is enabled, only function calls
940-
// and nullary ops are checked in `check_call_dest`.
941-
if !self.unsized_feature_enabled() {
935+
// When `unsized_fn_params` is enabled, this is checked in `check_call_dest`,
936+
// and `hir_typeck` still forces all non-argument locals to be sized (i.e., we don't
937+
// fully re-check what was already checked on HIR).
938+
if !self.tcx().features().unsized_fn_params() {
942939
match self.body.local_kind(local) {
943940
LocalKind::ReturnPointer | LocalKind::Arg => {
944941
// return values of normal functions are required to be
@@ -1953,8 +1950,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
19531950
}
19541951

19551952
// When `unsized_fn_params` is not enabled,
1956-
// this check is done at `check_local`.
1957-
if self.unsized_feature_enabled() {
1953+
// this check is done at `visit_local_decl`.
1954+
if self.tcx().features().unsized_fn_params() {
19581955
let span = term.source_info.span;
19591956
self.ensure_place_sized(dest_ty, span);
19601957
}

0 commit comments

Comments
 (0)