Skip to content

Handle properly when there is no crate attrs#107836

Merged
bors merged 2 commits into
rust-lang:masterfrom
chenyukang:yukang/fix-107822
Feb 10, 2023
Merged

Handle properly when there is no crate attrs#107836
bors merged 2 commits into
rust-lang:masterfrom
chenyukang:yukang/fix-107822

Conversation

@chenyukang

Copy link
Copy Markdown
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

oli-obk commented Feb 9, 2023

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

chenyukang commented Feb 10, 2023

Copy link
Copy Markdown
Member Author

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

oli-obk commented Feb 10, 2023

Copy link
Copy Markdown
Contributor

@bors r+ rollup

Yea, that error is sufficient imo, thanks

@bors

bors commented Feb 10, 2023

Copy link
Copy Markdown
Collaborator

📌 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