Go to file
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
.github Update `library/Cargo.toml` in weekly job 2024-08-19 07:30:11 -05:00
LICENSES Rename `LICENSES/GPL-2.0.txt` into `LICENSES/GPL-2.0-only.txt` 2024-09-06 16:01:46 +02:00
compiler Rollup merge of #130496 - jder:issue-130400, r=compiler-errors 2024-09-18 04:42:32 +02:00
library Rollup merge of #130481 - krtab:clamp_partial_ord, r=cuviper 2024-09-18 00:12:19 +02:00
src Auto merge of #130483 - matthiaskrgr:rollup-q1r0g0y, r=matthiaskrgr 2024-09-17 19:37:03 +00:00
tests Rollup merge of #130496 - jder:issue-130400, r=compiler-errors 2024-09-18 04:42:32 +02:00
.clang-format
.editorconfig
.git-blame-ignore-revs Exclude the copy blessing from git blame 2024-08-18 16:09:03 -07:00
.gitattributes
.gitignore gitignore: ignore ICE reports regardless of directory 2024-08-25 14:19:05 +03:00
.gitmodules Make gcc submodule shallow 2024-09-06 16:01:47 +02:00
.ignore
.mailmap Rollup merge of #129906 - BoxyUwU:boxy_mailmap, r=lqd 2024-09-02 22:35:23 +02:00
CODE_OF_CONDUCT.md
CONTRIBUTING.md
COPYRIGHT
Cargo.lock update lockfile 2024-09-17 15:20:50 +02:00
Cargo.toml Switch to using the v2 resolver in most workspaces 2024-08-18 13:59:09 -05:00
INSTALL.md Rollup merge of #127434 - onur-ozkan:use-bootstrap-instead-of-rustbuild, r=Mark-Simulacrum 2024-07-13 20:19:45 -07:00
LICENSE-APACHE
LICENSE-MIT
README.md
RELEASES.md Rollup merge of #129995 - alexcrichton:remove-wasm32-wasip2-release-notes, r=pietroalbini 2024-09-06 07:33:58 +02:00
REUSE.toml Fix licensing information in REUSE.toml 2024-09-06 16:01:47 +02:00
config.example.toml document `dist.vendor` in `config.example.toml` 2024-09-15 12:23:05 +03:00
configure
rust-bors.toml
rustfmt.toml Remove `src/gcc` from `rustfmt` checks 2024-09-06 16:01:46 +02:00
triagebot.toml notify Miri when intrinsics are changed 2024-09-11 16:31:05 +02:00
x
x.ps1
x.py

README.md

This is the main source code repository for Rust. It contains the compiler, standard library, and documentation.

Why Rust?

  • Performance: Fast and memory-efficient, suitable for critical services, embedded devices, and easily integrate with other languages.

  • Reliability: Our rich type system and ownership model ensure memory and thread safety, reducing bugs at compile-time.

  • Productivity: Comprehensive documentation, a compiler committed to providing great diagnostics, and advanced tooling including package manager and build tool (Cargo), auto-formatter (rustfmt), linter (Clippy) and editor support (rust-analyzer).

Quick Start

Read "Installation" from The Book.

Installing from Source

If you really want to install from source (though this is not recommended), see INSTALL.md.

Getting Help

See https://www.rust-lang.org/community for a list of chat platforms and forums.

Contributing

See CONTRIBUTING.md.

License

Rust is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.

See LICENSE-APACHE, LICENSE-MIT, and COPYRIGHT for details.

Trademark

The Rust Foundation owns and protects the Rust and Cargo trademarks and logos (the "Rust Trademarks").

If you want to use these names or brands, please read the media guide.

Third-party logos may be subject to third-party copyrights and trademarks. See Licenses for details.