about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
diff options
context:
space:
mode:
authorLeón Orell Valerian Liehr <me@fmease.dev>2024-03-16 23:28:48 +0100
committerGitHub <noreply@github.com>2024-03-16 23:28:48 +0100
commit7b7a7fc8910a944e4fd042aa68ff3807a5ee2bcc (patch)
treeb9565062d5dd412ba75cd7c3d9a7e0babfc455b4 /compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
parentc2b7d77d95cdc05a865a6fc1f40d35936d954346 (diff)
parentb2ed9d0911d010cd6aef2d038a47cb6294f0a443 (diff)
downloadrust-7b7a7fc8910a944e4fd042aa68ff3807a5ee2bcc.tar.gz
rust-7b7a7fc8910a944e4fd042aa68ff3807a5ee2bcc.zip
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:

https://github.com/rust-lang/rust/blob/9023f908cfbe7a475f369717a61cb8eb865cfd25/compiler/rustc_resolve/src/late.rs#L3153-L3162

Which leads to an incorrect `is_in_trait_impl`

https://github.com/rust-lang/rust/blob/9023f908cfbe7a475f369717a61cb8eb865cfd25/compiler/rustc_ast_lowering/src/item.rs#L981-L986

Which leads to an incorrect id for signature inheritance

https://github.com/rust-lang/rust/blob/9023f908cfbe7a475f369717a61cb8eb865cfd25/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
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp')
0 files changed, 0 insertions, 0 deletions