1
Fork 0
Empowering everyone to build reliable and efficient software. Gabriel's commits. https://www.rust-lang.org/
Find a file
León Orell Valerian Liehr 7b7a7fc891
Rollup merge of #122564 - Bryanskiy:delegation-fixes, r=compiler-errors
Delegation: fix ICE on duplicated associative items

Currently, functions delegation is only supported for delegation items with early resolved paths e.g. free functions and trait methods. During name resolution, information about function signatures is collected, including the number of parameters and whether there are self arguments. This information is then used when lowering from a delegation item into a regular function(`rustc_ast_lowering/src/delegation.rs`). The signature is usually inherited from path resolution id(`path_id`). However, in the case of trait impls `path_id` and `item_id` may be different:

```rust
trait Trait {
    fn foo(&self) -> u32 { 0 }
}

struct S;

mod to_reuse {
    use crate::S;

    pub fn foo(_: &S) -> u32 { 0 }
}

impl Trait for S {
    reuse to_reuse::foo { self }
    //~^ The signature should be inherited from item id instead of resolution id
}

```

Let's now consider an example from [issue](https://github.com/rust-lang/rust/issues/119920). Due to duplicated associative elements partial resolution for one of them will not be recorded:

9023f908cf/compiler/rustc_resolve/src/late.rs (L3153-L3162)

Which leads to an incorrect `is_in_trait_impl`

9023f908cf/compiler/rustc_ast_lowering/src/item.rs (L981-L986)

Which leads to an incorrect id for signature inheritance

9023f908cf/compiler/rustc_ast_lowering/src/delegation.rs (L99-L105)

Which lead to an ICE from original issue.

This patch fixes wrong `is_in_trait_impl`  calculation.

fixes https://github.com/rust-lang/rust/issues/119920
2024-03-16 23:28:48 +01:00
.github Bump cargo update PR more often 2024-03-14 11:24:09 +00:00
.reuse std: move Once implementations to sys 2024-03-12 15:41:06 +01:00
compiler Rollup merge of #122564 - Bryanskiy:delegation-fixes, r=compiler-errors 2024-03-16 23:28:48 +01:00
library Rollup merge of #122583 - Zoxc:tls-non-mut, r=joboet 2024-03-16 18:27:34 +00:00
LICENSES
src Rollup merge of #121720 - tmandry:split-refining, r=compiler-errors 2024-03-16 23:28:47 +01:00
tests Rollup merge of #122564 - Bryanskiy:delegation-fixes, r=compiler-errors 2024-03-16 23:28:48 +01:00
.editorconfig
.git-blame-ignore-revs
.gitattributes
.gitignore Merge commit '54cbb6e753' into sync_cg_clif-2024-03-08 2024-03-08 20:41:29 +00:00
.gitmodules
.mailmap
Cargo.lock Rollup merge of #122390 - ChrisDenton:bindgen, r=Mark-Simulacrum 2024-03-16 18:27:33 +00:00
Cargo.toml LLVM Bitcode Linker: Added crate 2024-03-11 13:35:35 +01:00
CODE_OF_CONDUCT.md
config.example.toml [bootstrap] Move the split-debuginfo setting to the per-target section 2024-03-11 20:17:00 +01:00
configure
CONTRIBUTING.md
COPYRIGHT
INSTALL.md Revert back to Git-for-Windows for MinGW CI builds 2024-03-07 03:09:29 +00:00
LICENSE-APACHE
LICENSE-MIT
README.md
RELEASES.md
rust-bors.toml Increase timeout for new bors bot 2024-03-13 08:31:07 +01:00
rustfmt.toml Remove exception for deleted file from rustfmt.toml 2024-03-08 20:46:33 +00:00
triagebot.toml Rollup merge of #122429 - rcvalle:rust-triagebot-add-exploit-mitigations-pg, r=wesleywiser 2024-03-13 20:01:56 +01:00
x
x.ps1
x.py

The Rust Programming Language

Rust Community

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

Note: this README is for users rather than contributors. If you wish to contribute to the compiler, you should read CONTRIBUTING.md instead.

Table of Contents

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.