Skip to content

StableMIR: Add associated_items. #138826

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Apr 5, 2025
Merged

Conversation

makai410
Copy link
Contributor

@makai410 makai410 commented Mar 22, 2025

@rustbot
Copy link
Collaborator

rustbot commented Mar 22, 2025

r? @celinval

rustbot has assigned @celinval.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 22, 2025
@makai410
Copy link
Contributor Author

Lack of the ui-test for it. I open this pr for some feedback first.

@makai410
Copy link
Contributor Author

makai410 commented Mar 22, 2025

My question is what data structure should be used for AssocItems (Currently Vec<(Symbol, AssocItem)>)? btw, I think there may be some problem with OpaqueDef, unsure if my version is correct.

@makai410
Copy link
Contributor Author

Forgot to mention that there may be some issues with the retrieved associated items that the compiler generated after RPITIT desugaring.

For example:

        trait Ciallo {
            fn rpitit(&self) -> impl std::fmt::Debug {
                "RPITIT"
            }
        }

get all associated items of this trait by associated_items():

AssocItems {
    items: [
        (
            "rpitit",
            AssocItem {
                def_id: AssocDef(
                    DefId {
                        id: 17336,
                        name: "Ciallo::rpitit",
                    },
                ),
                name: "rpitit",
                kind: Fn,
                container: Trait,
                trait_item_def_id: Some(
                    AssocDef(
                        DefId {
                            id: 17336,
                            name: "Ciallo::rpitit",
                        },
                    ),
                ),
                fn_has_self_parameter: true,
                opt_rpitit_info: None,
            },
        ),
        (
            "",
            AssocItem {
                def_id: AssocDef(
                    DefId {
                        id: 17338,
                        name: "Ciallo::{synthetic#0}",
                    },
                ),
                name: "",
                kind: Type,
                container: Trait,
                trait_item_def_id: None,
                fn_has_self_parameter: false,
                opt_rpitit_info: Some(
                    Trait {
                        fn_def_id: FnDef(
                            DefId {
                                id: 17336,
                                name: "Ciallo::rpitit",
                            },
                        ),
                        opaque_def_id: OpaqueDef(
                            DefId {
                                id: 17339,
                                name: "Ciallo::rpitit::{opaque#0}",
                            },
                        ),
                    },
                ),
            },
        ),
    ],
}

The problem is the name of the generated associated type is "". I have no knowledge of RPITIT desugaring, unsure if this is an issue and whether we should slap a name to it.

@celinval
Copy link
Contributor

My question is what data structure should be used for AssocItems (Currently Vec<(Symbol, AssocItem)>)?

Can you do Vec<AssocItem> instead? From what I understood, the Symbol is redundant since it duplicates name from AssocItem.

@makai410
Copy link
Contributor Author

Oh yes, it makes sense.

@makai410 makai410 marked this pull request as ready for review April 1, 2025 09:15
@rustbot
Copy link
Collaborator

rustbot commented Apr 1, 2025

This PR changes Stable MIR

cc @oli-obk, @celinval, @ouz-a

@celinval
Copy link
Contributor

celinval commented Apr 5, 2025

@bors r+ rollup

Thanks!

@bors
Copy link
Collaborator

bors commented Apr 5, 2025

📌 Commit f9ef456 has been approved by celinval

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 5, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 5, 2025
Rollup of 11 pull requests

Successful merges:

 - rust-lang#136457 (Expose algebraic floating point intrinsics)
 - rust-lang#137880 (Autodiff batching)
 - rust-lang#137897 (fix pthread-based tls on apple targets)
 - rust-lang#138024 (Allow optimizing out `panic_bounds_check` in Unicode checks.)
 - rust-lang#138546 (Add integer to string formatting tests)
 - rust-lang#138826 (StableMIR: Add `associated_items`.)
 - rust-lang#138950 (replace extra_filename with strict version hash in metrics file names)
 - rust-lang#139274 (Rustdoc: typecheck settings.js)
 - rust-lang#139285 (use lower case to match other error messages)
 - rust-lang#139341 (Apply `Recovery::Forbidden` when reparsing pasted macro fragments.)
 - rust-lang#139389 (make `Arguments::as_statically_known_str` doc(hidden))

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 93f7583 into rust-lang:master Apr 5, 2025
6 checks passed
@rustbot rustbot added this to the 1.88.0 milestone Apr 5, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 5, 2025
Rollup merge of rust-lang#138826 - makai410:assoc-items, r=celinval

StableMIR: Add `associated_items`.

Resolves: rust-lang/project-stable-mir#87
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an API to get associated items
4 participants