Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

save-analysis: don't leak information about constructor ids #33398

Closed
aochagavia opened this issue May 4, 2016 · 1 comment
Closed

save-analysis: don't leak information about constructor ids #33398

aochagavia opened this issue May 4, 2016 · 1 comment

Comments

@aochagavia
Copy link
Contributor

aochagavia commented May 4, 2016

Note: the paths in this issue assume that #33370 is merged

Problem

external_data::StructData contains a ctor_id field that represents the Id of the struct constructor. However, this adds no value to the client of the API, since decl_id is enough to identify a struct.

Currently, some type references contain a ref_id that corresponds to the ctor_id of the type, instead of the decl_id. This forces clients of the API to keep a hashtable mapping from ctor_id to decl_id in case they want to get the original struct declaration.

Note: I have observed this only in tuple structs. It seems like normal structs don't even have a valid ctor_id

Example

Imagine you want to get all references to MyStruct in the following program:

struct MyStruct; // decl_id: 1, ctor_id: 2
fn main() {
    let x = foo();
}

fn foo() -> MyStruct { // Here, the reference to MyStruct has ref_id: 1
    MyStruct // Here, the reference to MyStruct has ref_id: 2 (the constructor)
}

Ideally, both references should have ref_id = 1

Solution

Remove the ctor_id field and modify the save code in such a way that references always point to a decl_id instead of a ctor_id.

cc @nrc do you think this makes sense?

@Mark-Simulacrum
Copy link
Member

The save-analysis output appears to no longer have a ctor_id field, so I'm going to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants