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

rustc: Structures and their constructors have different definitions when defined locally and in other crate #30361

Closed
petrochenkov opened this issue Dec 13, 2015 · 1 comment · Fixed by #31010
Labels
T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@petrochenkov
Copy link
Contributor

Local struct - def::DefTy, struct from some other crate - def::DefStruct
Local struct constructor - def::DefStruct, struct constructor from some other crate - def::DefFn

Is there any rationale for these discrepancies?

I made some quick experiment and fixed the first discrepancy by using DefStruct in both cases. It resulted in better error diagnostics and one discovered bug. Seems like a win.

I'd also like to split DefTy(DefId, bool /* is_enum */) into DefEnum(DefId) and DefTypeAlias(DefId). I have and impression that type aliases may be not always treated correctly, or at least consciously.

cc @arielb1 @eddyb

@arielb1
Copy link
Contributor

arielb1 commented Dec 13, 2015

@petrochenkov

I was aware of this mess but I am not familiar enough with resolve to understand its effects or try to touch it.

@huonw huonw added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jan 6, 2016
bors added a commit that referenced this issue Jan 21, 2016
All structs and their constructors are defined as `DefStruct`.
`DefTy` is splitted into `DefEnum` and `DefTyAlias`.
Ad hoc flag `bool is_structure` is removed from `DefVariant`, it was required in one place in resolve and could be obtained by other means.
Flag `bool is_ctor` is removed from `DefFn`, it wasn't really used for constructors outside of metadata decoding.

Observable effects:
More specific error messages are selected in some cases.
Two name resolution bugs fixed (#30992 and FIXME in compile-fail/empty-struct-braces-expr.rs).

Fixes #30992
Closes #30361
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants