rust/compiler
Matthias Krüger c52d58dce1
Rollup merge of #130496 - jder:issue-130400, r=compiler-errors
Fix circular fn_sig queries to correct number of args for methods

Fixes #130400. This was a [debug assert](28e8f01c2a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs (L2557)) added to some argument error reporting code in #129320 which verified that the number of params (from the HIR) matched the `matched_inputs` which ultimately come from ty::FnSig. In the reduced test case:

```
fn foo(&mut self) -> _ {
    foo()
}
```

There is a circular dependency computing the ty::FnSig -- when trying to compute it, we try to figure out the return value, which again depends on this ty::FnSig. In #105162, this was supported by short-circuiting the cycle by synthesizing a FnSig with error types for parameters. The [code in question](https://github.com/rust-lang/rust/pull/105162/files#diff-a65feec6bfffb19fbdc60a80becd1030c82a56c16b177182cd277478fdb04592R44) computes the number of parameters by taking the number of parameters from the hir::FnDecl and adding 1 if there is an implicit self parameter.

I might be missing a subtlety here, but AFAICT the adjustment for implicit self args is unnecessary and results in one too many args. For example, for this non-errorful code:

```
trait Foo {
    fn bar(&self) {}
}
```

The resulting hir::FnDecl and ty::FnSig both have the same number of inputs -- 1. So, this PR removes that adjustment and adds a test for the debug ICE.

r? `@compiler-errors`
2024-09-18 04:42:32 +02:00
..
rustc disable size asserts in the compiler when randomizing layouts 2024-08-31 23:56:45 +02:00
rustc_abi get rid of an old hack 2024-09-17 00:09:21 +02:00
rustc_arena Remove unnecessary lifetimes from Arena. 2024-09-13 15:33:19 +10:00
rustc_ast Rollup merge of #130314 - compiler-errors:mac-prec, r=davidtwco 2024-09-17 17:28:33 +02:00
rustc_ast_ir Add warn(unreachable_pub) to several crates. 2024-08-16 08:46:13 +10:00
rustc_ast_lowering Re-enable ConstArgKind::Path lowering by default 2024-09-12 13:56:01 -04:00
rustc_ast_passes stabilize const_extern_fn 2024-09-14 18:07:06 +02:00
rustc_ast_pretty Add initial support for raw lifetimes 2024-09-06 10:32:48 -04:00
rustc_attr Remove needless returns detected by clippy in the compiler 2024-09-09 13:32:22 +02:00
rustc_baked_icu_data Don't add warn(unreachable_pub) to rustc_baked_icu. 2024-08-16 08:46:52 +10:00
rustc_borrowck Rollup merge of #130294 - nnethercote:more-lifetimes, r=lcnr 2024-09-14 18:12:13 +02:00
rustc_builtin_macros Rename and reorder lots of lifetimes. 2024-09-13 15:46:20 +10:00
rustc_codegen_cranelift simd_shuffle: require index argument to be a vector 2024-09-14 14:43:24 +02:00
rustc_codegen_gcc simd_shuffle: require index argument to be a vector 2024-09-14 14:43:24 +02:00
rustc_codegen_llvm Rollup merge of #130325 - workingjubilee:plus-minus-zero-redux, r=RalfJung,jieyouxu 2024-09-15 23:51:25 -07:00
rustc_codegen_ssa Rollup merge of #130116 - veera-sivarajan:freeze-suggestions, r=chenyukang 2024-09-18 04:42:31 +02:00
rustc_const_eval layout computation: eagerly error for unexpected unsized fields 2024-09-16 15:53:21 +02:00
rustc_data_structures Add an internal lint that warns when accessing untracked data 2024-09-03 19:14:19 +02:00
rustc_driver Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
rustc_driver_impl Rollup merge of #129988 - arnaudgolfouse:modify-locale_resources, r=davidtwco 2024-09-17 17:28:32 +02:00
rustc_error_codes Introduce distinct error codes for precise capturing 2024-09-16 10:56:22 -04:00
rustc_error_messages Add warn(unreachable_pub) to rustc_error_messages. 2024-08-27 11:52:08 +10:00
rustc_errors Implement a Method to Seal DiagInner's Suggestions 2024-09-12 21:27:44 -04:00
rustc_expand Remove unnecessary lifetimes from rustc_expand. 2024-09-13 15:33:21 +10:00
rustc_feature also stabilize const_refs_to_cell 2024-09-15 10:20:47 +02:00
rustc_fluent_macro fluent_macro: fix diagnostics for fluent parse failures 2024-09-17 14:49:33 +00:00
rustc_fs_util Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_graphviz Add warn(unreachable_pub) to rustc_graphviz. 2024-08-27 12:58:29 +10:00
rustc_hir Rollup merge of #130314 - compiler-errors:mac-prec, r=davidtwco 2024-09-17 17:28:33 +02:00
rustc_hir_analysis Rollup merge of #130116 - veera-sivarajan:freeze-suggestions, r=chenyukang 2024-09-18 04:42:31 +02:00
rustc_hir_pretty Add warn(unreachable_pub) to rustc_hir_pretty. 2024-08-27 13:25:40 +10:00
rustc_hir_typeck Auto merge of #129073 - compiler-errors:receiver-variance, r=lcnr 2024-09-17 12:44:08 +00:00
rustc_incremental Also fix if in else 2024-09-11 17:24:01 -04:00
rustc_index assert that unexpectedly unsized fields are sized in the param env 2024-09-17 00:06:56 +02:00
rustc_index_macros Remove usage of specialization from newtype_index! 2024-06-30 16:42:53 +00:00
rustc_infer Rollup merge of #130114 - eduardosm:needless-returns, r=compiler-errors 2024-09-11 15:53:22 -07:00
rustc_interface Rollup merge of #129988 - arnaudgolfouse:modify-locale_resources, r=davidtwco 2024-09-17 17:28:32 +02:00
rustc_lexer Add initial support for raw lifetimes 2024-09-06 10:32:48 -04:00
rustc_lint Rollup merge of #130469 - compiler-errors:wc-obj-safety, r=jackh726 2024-09-17 17:28:35 +02:00
rustc_lint_defs Rollup merge of #130353 - Zalathar:lint-zero, r=jieyouxu 2024-09-15 12:14:57 +10:00
rustc_llvm Rollup merge of #130477 - tmandry:revert-llvm-20-lto, r=tmandry 2024-09-17 20:45:51 +02:00
rustc_log Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustc_macros Add warn(unreachable_pub) to rustc_metadata. 2024-08-29 20:13:06 +10:00
rustc_metadata Encode coroutine_by_move_body_def_id in crate metadata 2024-09-16 19:59:04 -04:00
rustc_middle Fix circular fn_sig queries to return the correct number of arguments for methods 2024-09-17 20:54:04 -04:00
rustc_mir_build Rollup merge of #130294 - nnethercote:more-lifetimes, r=lcnr 2024-09-14 18:12:13 +02:00
rustc_mir_dataflow Rollup merge of #130294 - nnethercote:more-lifetimes, r=lcnr 2024-09-14 18:12:13 +02:00
rustc_mir_transform Rollup merge of #130201 - compiler-errors:foreign-synthetic-body, r=lcnr 2024-09-17 17:28:32 +02:00
rustc_monomorphize Rollup merge of #130235 - compiler-errors:nested-if, r=michaelwoerister 2024-09-12 20:37:16 +10:00
rustc_next_trait_solver Rollup merge of #130273 - lcnr:overflow-no-constraints, r=compiler-errors 2024-09-12 19:03:43 +02:00
rustc_parse Rollup merge of #130489 - compiler-errors:raw-lt-lint, r=jieyouxu 2024-09-18 04:42:31 +02:00
rustc_parse_format Add warn(unreachable_pub) to rustc_parse_format. 2024-08-29 20:13:06 +10:00
rustc_passes layout computation: eagerly error for unexpected unsized fields 2024-09-16 15:53:21 +02:00
rustc_pattern_analysis Revert warning empty patterns as unreachable 2024-09-11 18:36:45 +02:00
rustc_privacy Rename and reorder lots of lifetimes. 2024-09-13 15:46:20 +10:00
rustc_query_impl Rename and reorder lots of lifetimes. 2024-09-13 15:46:20 +10:00
rustc_query_system chore: Fix typos in 'compiler' (batch 2) 2024-09-02 07:50:22 +02:00
rustc_resolve Rollup merge of #130116 - veera-sivarajan:freeze-suggestions, r=chenyukang 2024-09-18 04:42:31 +02:00
rustc_sanitizers Also fix if in else 2024-09-11 17:24:01 -04:00
rustc_serialize Auto merge of #129777 - nnethercote:unreachable_pub-4, r=Urgau 2024-09-03 01:27:20 +00:00
rustc_session Rollup merge of #128961 - GKFX:issue-128930-explain-missing-option, r=jieyouxu 2024-09-17 17:28:31 +02:00
rustc_smir Auto merge of #129777 - nnethercote:unreachable_pub-4, r=Urgau 2024-09-03 01:27:20 +00:00
rustc_span Auto merge of #107251 - dingxiangfei2009:let-chain-rescope, r=jieyouxu 2024-09-13 03:47:30 +00:00
rustc_symbol_mangling Fix a couple more DefKind discrepancies between DefKind::Closure and DefKind::SyntheticCoroutineBody 2024-09-16 22:09:42 -04:00
rustc_target Fix target-cpu fpu features on Armv8-R. 2024-09-14 21:39:23 -07:00
rustc_trait_selection Rollup merge of #130116 - veera-sivarajan:freeze-suggestions, r=chenyukang 2024-09-18 04:42:31 +02:00
rustc_traits Add warn(unreachable_pub) to rustc_traits. 2024-09-03 08:49:54 +10:00
rustc_transmute layout computation: eagerly error for unexpected unsized fields 2024-09-16 15:53:21 +02:00
rustc_ty_utils get rid of an old hack 2024-09-17 00:09:21 +02:00
rustc_type_ir Rollup merge of #130311 - heiseish:issue-70849-fix, r=fmease 2024-09-14 20:22:41 +10:00
rustc_type_ir_macros Reformat use declarations. 2024-07-29 08:26:52 +10:00
stable_mir chore: Fix typos in 'compiler' (batch 3) 2024-09-02 07:33:41 +02:00