1
Fork 0

Rollup merge of #112643 - compiler-errors:sized-obl-for-arg, r=wesleywiser

Always register sized obligation for argument

Removes a "hack" that skips registering sized obligations for parameters that are simple identifiers. This doesn't seem to affect diagnostics because we're probably already being smart enough about deduplicating identical error messages anyways.

Fixes #112608
This commit is contained in:
Matthias Krüger 2023-06-23 19:39:57 +02:00 committed by GitHub
commit 27ae068de3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 57 additions and 22 deletions

View file

@ -92,10 +92,7 @@ pub(super) fn check_fn<'a, 'tcx>(
fcx.check_pat_top(&param.pat, param_ty, ty_span, None);
// Check that argument is Sized.
// The check for a non-trivial pattern is a hack to avoid duplicate warnings
// for simple cases like `fn foo(x: Trait)`,
// where we would error once on the parameter as a whole, and once on the binding `x`.
if param.pat.simple_ident().is_none() && !params_can_be_unsized {
if !params_can_be_unsized {
fcx.require_type_is_sized(
param_ty,
param.pat.span,