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

Implement RFC 1260 with feature_name imported_main. #84401

Merged
merged 1 commit into from
Apr 30, 2021

Conversation

crlf0710
Copy link
Member

@crlf0710 crlf0710 commented Apr 21, 2021

This is the second extraction part of #84062 plus additional adjustments.
This (mostly) implements RFC 1260.

However there's still one test case failure in the extern crate case. Maybe LocalDefId doesn't work here? I'm not sure.

cc #28937
r? @petrochenkov

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 21, 2021
@crlf0710 crlf0710 force-pushed the impl_main_by_path branch 2 times, most recently from cbc1642 to 84a4ab3 Compare April 21, 2021 15:49
@rust-log-analyzer

This comment has been minimized.

@crlf0710
Copy link
Member Author

crlf0710 commented Apr 22, 2021

status update: still trying to find a way to migrate https://github.com/rust-lang/rust/blob/master/compiler/rustc_typeck/src/lib.rs#L167 to support non-local DefIds. Searched around without much findings. Created a zulip stream at https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/How.20to.20typecheck.20non-local.20DefId.3F

@crlf0710
Copy link
Member Author

Status update: Updated the types and modified rustc_typeck to take care of the non-local case.

Currently still a linking error with the non-local case...

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@crlf0710
Copy link
Member Author

Added a mechanism to ensure there's a codegen unit that's appointed to deal with the main_wrapper generation.

cc @bjorn3 in case there's potential effect on cranelift codegen.

@rust-log-analyzer

This comment has been minimized.

@petrochenkov
Copy link
Contributor

I can't help with codegen issues with foreign main.
As one possible solution I can suggest reporting an error if the imported main points to a different crate in this PR, and then implementing support for it in a separate PR assigned to someone more familiar with the relevant compiler parts.

src/test/ui/rfc-1260/auxiliary/main_functions.rs Outdated Show resolved Hide resolved
src/test/ui/rfc-1260/reexport_from_inner_mod.rs Outdated Show resolved Hide resolved
compiler/rustc_feature/src/active.rs Outdated Show resolved Hide resolved
compiler/rustc_hir/src/hir.rs Outdated Show resolved Hide resolved
compiler/rustc_expand/src/expand.rs Show resolved Hide resolved
compiler/rustc_resolve/src/lib.rs Outdated Show resolved Hide resolved
compiler/rustc_passes/src/entry.rs Outdated Show resolved Hide resolved
compiler/rustc_passes/src/entry.rs Outdated Show resolved Hide resolved
compiler/rustc_resolve/src/lib.rs Outdated Show resolved Hide resolved
compiler/rustc_typeck/src/lib.rs Outdated Show resolved Hide resolved
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 24, 2021
@bors

This comment has been minimized.

@crlf0710 crlf0710 changed the title Implement RFC 1260 with feature_name main_by_path. Implement RFC 1260 with feature_name imported_main. Apr 25, 2021
@crlf0710
Copy link
Member Author

Rebased and addressed the review comments. I'll leave the codegen changes to another PR.

Surprisingly, the last-seen CI-failure is actually not caused by codegen, but by the previously used resolve_ast_path api. Not sure why it caused such issues, but we're no longer using it anyway.

@rust-log-analyzer

This comment has been minimized.

compiler/rustc_typeck/src/check/check.rs Outdated Show resolved Hide resolved
compiler/rustc_resolve/src/lib.rs Outdated Show resolved Hide resolved
compiler/rustc_resolve/src/lib.rs Outdated Show resolved Hide resolved
@crlf0710
Copy link
Member Author

crlf0710 commented Apr 28, 2021

Rebased and address the comments above in a new commit for easier reviewing.

@crlf0710 crlf0710 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 28, 2021
@petrochenkov
Copy link
Contributor

r=me with commits squashed.

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 28, 2021
@crlf0710
Copy link
Member Author

Squashed the commits.

@crlf0710 crlf0710 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 29, 2021
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Apr 29, 2021

📌 Commit d261df4 has been approved by petrochenkov

@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 29, 2021
@bors
Copy link
Contributor

bors commented Apr 30, 2021

⌛ Testing commit d261df4 with merge bcd696d...

@bors
Copy link
Contributor

bors commented Apr 30, 2021

☀️ Test successful - checks-actions
Approved by: petrochenkov
Pushing bcd696d to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 30, 2021
@bors bors merged commit bcd696d into rust-lang:master Apr 30, 2021
@rustbot rustbot added this to the 1.53.0 milestone Apr 30, 2021
@rust-highfive
Copy link
Collaborator

📣 Toolstate changed by #84401!

Tested on commit bcd696d.
Direct link to PR: #84401

💔 miri on windows: test-pass → build-fail (cc @RalfJung @eddyb @oli-obk).
💔 miri on linux: test-pass → build-fail (cc @RalfJung @eddyb @oli-obk).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Apr 30, 2021
Tested on commit rust-lang/rust@bcd696d.
Direct link to PR: <rust-lang/rust#84401>

💔 miri on windows: test-pass → build-fail (cc @RalfJung @eddyb @oli-obk).
💔 miri on linux: test-pass → build-fail (cc @RalfJung @eddyb @oli-obk).
@crlf0710 crlf0710 deleted the impl_main_by_path branch April 30, 2021 11:42
bors added a commit to rust-lang/miri that referenced this pull request Apr 30, 2021
flip1995 pushed a commit to flip1995/rust that referenced this pull request May 6, 2021
…enkov

Implement RFC 1260 with feature_name `imported_main`.

This is the second extraction part of rust-lang#84062 plus additional adjustments.
This (mostly) implements RFC 1260.

However there's still one test case failure in the extern crate case. Maybe `LocalDefId` doesn't work here? I'm not sure.

cc rust-lang#28937
r? `@petrochenkov`
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 1, 2021
…r=varkor

Fix ICE when `main` is declared in an `extern` block

Changes in rust-lang#84401 to implement `imported_main` changed how the crate entry point is found, and a declared `main` in an `extern` block was detected erroneously.  This was causing the ICE described in rust-lang#86110.

This PR adds a check for this case and emits an error instead.  Previously a `main` declaration in an `extern` block was not detected as an entry point at all, so emitting an error shouldn't break anything that worked previously.  In 1.52.1 stable this is demonstrated, with a `` `main` function not found`` error.

Fixes rust-lang#86110
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants