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

Handle properly when there is no crate attrs #107836

Merged
merged 2 commits into from
Feb 10, 2023

Conversation

chenyukang
Copy link
Member

Fixes #107822

r? @oli-obk

@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 Feb 9, 2023
@oli-obk
Copy link
Contributor

oli-obk commented Feb 9, 2023

I think we should stop compilation and report an error instead of silently continueing. The user asked for something to get printed and we just don't print anything, that seems suboptimal.

You can add a test for this in tests/run-make. The valid-print-requests test looks very similar to this, so you can copy it to a new test and adjust it to test this situation.

@chenyukang
Copy link
Member Author

The current fix return Compilation::Continue actually will stop compilation and report an an error, because of this line:

early_error(sopts.error_format, "no input filename given")

the output is:

gh-chenyukang@dev-desktop-us-2:~/rust$ rustc +dev --print crate-name
error: no input filename given

The naming and code path seems easy to misinterpret, I will have a cleanup and add test.

@chenyukang
Copy link
Member Author

chenyukang commented Feb 10, 2023

For command line:

rustc +dev -o /tmp/out

error: no input filename given

it's returned by this line, seems not relevant code logic but just works by expection 😂

return Compilation::Continue;

then

early_error(sopts.error_format, "no input filename given")

@oli-obk
Copy link
Contributor

oli-obk commented Feb 10, 2023

@bors r+ rollup

Yea, that error is sufficient imo, thanks

@bors
Copy link
Contributor

bors commented Feb 10, 2023

📌 Commit 2573898 has been approved by oli-obk

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 Feb 10, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 10, 2023
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#107789 (Avoid exposing type parameters and implementation details sourced from macro expansions)
 - rust-lang#107836 (Handle properly when there is no crate attrs)
 - rust-lang#107839 (avoid duplicating the RUSTC_LOG env var name)
 - rust-lang#107866 (Allow wasi-libc to initialize its environment variables lazily.)
 - rust-lang#107876 (create symlink only for non-windows operating systems)
 - rust-lang#107882 (Cleanup typos in en_US/borrowck.ftl)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit d494cd3 into rust-lang:master Feb 10, 2023
@rustbot rustbot added this to the 1.69.0 milestone Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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.

ICE when executing rustc --print crate-name
4 participants