Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
self.body
}

fn unsized_feature_enabled(&self) -> bool {
self.tcx().features().unsized_fn_params()
}

/// Equate the inferred type and the annotated type for user type annotations
#[instrument(skip(self), level = "debug")]
fn check_user_type_annotations(&mut self) {
Expand Down Expand Up @@ -660,7 +656,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
);
}

if !self.unsized_feature_enabled() {
if !self.tcx().features().unsized_fn_params() {
let trait_ref = ty::TraitRef::new(
tcx,
tcx.require_lang_item(LangItem::Sized, self.last_span),
Expand Down Expand Up @@ -936,9 +932,10 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
}
}

// When `unsized_fn_params` is enabled, only function calls
// and nullary ops are checked in `check_call_dest`.
if !self.unsized_feature_enabled() {
// When `unsized_fn_params` is enabled, this is checked in `check_call_dest`,
// and `hir_typeck` still forces all non-argument locals to be sized (i.e., we don't
// fully re-check what was already checked on HIR).
Copy link
Copy Markdown
Member Author

@RalfJung RalfJung Mar 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nullary ops don't exist any more so the comment needed updating.

And from all I can tell, we do not fully re-check non-argument locals to be sized here. Not sure if that is a problem, being sized cannot depend on lifetimes after all. But then I don't know why we re-check any of the sized stuff here.^^

Cc @lqd @lcnr

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, weird. I don't know either...

if !self.tcx().features().unsized_fn_params() {
match self.body.local_kind(local) {
LocalKind::ReturnPointer | LocalKind::Arg => {
// return values of normal functions are required to be
Expand Down Expand Up @@ -1953,8 +1950,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
}

// When `unsized_fn_params` is not enabled,
// this check is done at `check_local`.
if self.unsized_feature_enabled() {
// this check is done at `visit_local_decl`.
if self.tcx().features().unsized_fn_params() {
let span = term.source_info.span;
self.ensure_place_sized(dest_ty, span);
}
Expand Down
Loading