Skip to content

Closes #12660 and #16973 (ICE) #17653

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

Merged
merged 1 commit into from
Oct 1, 2014
Merged

Closes #12660 and #16973 (ICE) #17653

merged 1 commit into from
Oct 1, 2014

Conversation

kaini
Copy link

@kaini kaini commented Sep 30, 2014

Fixes that unit-like structs cannot be used if they are re-exported and used in another crate. (ICE)
The relevant changes are in rustc::metadata::{decoder, encoder} and rustc::middle::ty.

A test case is included.

The problem is that the expressoin UnitStruct is an ExprPath to an DefFn, which is of expr kind RvalueDatumExpr, but for unit-struct ctors the expr kind should be RvalueDpsExpr. I fixed this (in a I guess clean way) by introducing CtorFn in the metadata and including a is_ctor flag in DefFn.

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

@alexcrichton
Copy link
Member

This looks great, thanks! Could you word the commit message like you worded the PR message as well? In general we like to have a one line summary followed by a more detailed description of what happened in the commit for each commit.

Fixes that unit-like structs cannot be used if they are reexported and
used in another crate. The compiler fails with an ICE, because unit-like
structs are exported as DefFn and the expression `UnitStruct` is
interpreted as function pointer instead of a call to the constructor.

To resolve this ambiguity tuple-like struct constructors are now exported
as CtorFn. When `rustc::metadata::decoder` finds a CtorFn it sets a new
flag `is_ctor` in DefFn to true.

Relevant changes are in `rustc::metadata::{encoder, decoder}` and in
`rustc::middle::ty`.

Closes #12660 and #16973.
@kaini
Copy link
Author

kaini commented Sep 30, 2014

Done.

bors added a commit that referenced this pull request Oct 1, 2014
Fixes that unit-like structs cannot be used if they are re-exported and used in another crate. (ICE)
The relevant changes are in `rustc::metadata::{decoder, encoder}` and `rustc::middle::ty`.

A test case is included.

The problem is that the expressoin `UnitStruct` is an `ExprPath` to an `DefFn`, which is of expr kind `RvalueDatumExpr`, but for unit-struct ctors the expr kind should be `RvalueDpsExpr`. I fixed this (in a I guess clean way) by introducing `CtorFn` in the metadata and including a `is_ctor` flag in `DefFn`.
@bors bors closed this Oct 1, 2014
@bors bors merged commit 065a5b0 into rust-lang:master Oct 1, 2014
lnicola pushed a commit to lnicola/rust that referenced this pull request Jul 28, 2024
Prefer standard library paths over shorter extern deps re-exports

This should generally speed up path finding for std items as we no longer bother looking through all external dependencies. It also makes more sense to prefer importing std items from the std dependencies directly.

Fixes rust-lang/rust-analyzer#17540
RalfJung pushed a commit to RalfJung/rust that referenced this pull request Aug 1, 2024
Prefer standard library paths over shorter extern deps re-exports

This should generally speed up path finding for std items as we no longer bother looking through all external dependencies. It also makes more sense to prefer importing std items from the std dependencies directly.

Fixes rust-lang/rust-analyzer#17540
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

Successfully merging this pull request may close these issues.

4 participants