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

Display valid crate types in error message for --crate-type flag #134720

Merged
merged 1 commit into from
Mar 14, 2025

Conversation

malezjaa
Copy link
Contributor

@malezjaa malezjaa commented Dec 24, 2024

This PR improves the error message for the --crate-type flag. When an invalid crate type is provided, the compiler will now show a list of valid options.

Before

image

After

image

I based the implementation on OutputType::shorthands_display

Closes #70183

@rustbot
Copy link
Collaborator

rustbot commented Dec 24, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @BoxyUwU (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@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 Dec 24, 2024
@jieyouxu
Copy link
Member

jieyouxu commented Dec 24, 2024

I seem to recall not all the targets support all the crate types. For example, does all of the wasm targets support dylib crate type?

Example: https://github.com/rust-lang/rust/pull/130599/files#diff-ec897fdc27fe33a590c42303d7adda80b03a9af4860440e41a235d7081aa2165

Though I suppose the user will get another follow-up error anyway 😄

@malezjaa
Copy link
Contributor Author

malezjaa commented Dec 24, 2024

You're right 🙂 This error is just to show the valid values for --crate-type.

Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add an ui test for this diagnostics?

@malezjaa
Copy link
Contributor Author

Hi, I added the tests. I'm not sure if I did it the right way, though.

@malezjaa malezjaa requested a review from jieyouxu December 24, 2024 17:34
@malezjaa malezjaa force-pushed the feat/crate-type-valid-values branch from 980ca14 to 62353f8 Compare December 24, 2024 19:27
@clubby789
Copy link
Contributor

The UI test looks good. You'll should squash all your changes into one commit

@malezjaa malezjaa force-pushed the feat/crate-type-valid-values branch from a60dbd4 to 6315245 Compare December 24, 2024 20:39
@malezjaa
Copy link
Contributor Author

Done 👍

@jieyouxu jieyouxu assigned jieyouxu and unassigned BoxyUwU Dec 25, 2024
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks like a nice improvement, only some tiny stylistic nits, then LGTM.

@jieyouxu jieyouxu 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 Dec 25, 2024
@jieyouxu
Copy link
Member

Thanks, I'll r+ after PR CI is green.

@jieyouxu jieyouxu 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 Dec 25, 2024
@rust-log-analyzer

This comment has been minimized.

@jieyouxu
Copy link
Member

(You might need to rebless the test)

@jieyouxu
Copy link
Member

Also, can you squash the commits into one? Thanks.

@malezjaa malezjaa force-pushed the feat/crate-type-valid-values branch from 9a2ef0a to b56ec2f Compare December 25, 2024 12:41
@jieyouxu
Copy link
Member

Cool.
@bors r+ rollup

@bors
Copy link
Contributor

bors commented Dec 25, 2024

📌 Commit b56ec2f has been approved by jieyouxu

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 Dec 25, 2024
@jieyouxu jieyouxu added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 6, 2025
@jieyouxu
Copy link
Member

jieyouxu commented Jan 6, 2025

Thanks for the reminder, I missed the cargo bump.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 6, 2025

📌 Commit 0d5087d has been approved by jieyouxu

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 Jan 6, 2025
jhpratt added a commit to jhpratt/rust that referenced this pull request Jan 7, 2025
…ues, r=jieyouxu

Display valid crate types in error message for --crate-type flag

This PR improves the error message for the --crate-type flag. When an invalid crate type is provided, the compiler will now show a list of valid options.

### Before
![image](https://github.com/user-attachments/assets/4922e4e5-eeca-40cd-ac1c-1c6319a81aee)

### After
![image](https://github.com/user-attachments/assets/67ea1f35-aa41-4e4f-8691-47c273d0cff9)

I based the implementation on `OutputType::shorthands_display`

Closes rust-lang#70183
@jhpratt
Copy link
Member

jhpratt commented Jan 7, 2025

@bors r-

presumptive (partial) cause of #135181 (comment)

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 7, 2025
@jieyouxu
Copy link
Member

jieyouxu commented Jan 7, 2025

Ah right, I added a new test, may have to rebless it

@jieyouxu jieyouxu closed this Jan 7, 2025
@jieyouxu jieyouxu reopened this Jan 7, 2025
@rust-log-analyzer

This comment has been minimized.

@alex-semenyuk
Copy link
Member

@malezjaa
Thanks for your contribution
From wg-triage. Could you please handle this

Ah right, I added a new test, may have to rebless it

Co-authored-by: Jieyou Xu <jieyouxu@outlook.com>
@jieyouxu jieyouxu force-pushed the feat/crate-type-valid-values branch from 0d5087d to 90bf2b1 Compare March 14, 2025 08:03
@jieyouxu
Copy link
Member

I reblessed the test, no significant changes.
@bors r+ rollup

@bors
Copy link
Contributor

bors commented Mar 14, 2025

📌 Commit 90bf2b1 has been approved by jieyouxu

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 14, 2025
jhpratt added a commit to jhpratt/rust that referenced this pull request Mar 14, 2025
…ues, r=jieyouxu

Display valid crate types in error message for --crate-type flag

This PR improves the error message for the --crate-type flag. When an invalid crate type is provided, the compiler will now show a list of valid options.

### Before
![image](https://github.com/user-attachments/assets/4922e4e5-eeca-40cd-ac1c-1c6319a81aee)

### After
![image](https://github.com/user-attachments/assets/67ea1f35-aa41-4e4f-8691-47c273d0cff9)

I based the implementation on `OutputType::shorthands_display`

Closes rust-lang#70183
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 14, 2025
Rollup of 6 pull requests

Successful merges:

 - rust-lang#134720 (Display valid crate types in error message for --crate-type flag)
 - rust-lang#137424 (uefi: helpers: Add DevicePathNode abstractions)
 - rust-lang#137736 (Don't attempt to export compiler-builtins symbols from rust dylibs)
 - rust-lang#138451 (Build GCC on CI with GCC, not Clang)
 - rust-lang#138454 (Improve post-merge workflow)
 - rust-lang#138477 (Deny impls for `BikeshedGuaranteedNoDrop`)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 14, 2025
Rollup of 9 pull requests

Successful merges:

 - rust-lang#134720 (Display valid crate types in error message for --crate-type flag)
 - rust-lang#137619 (Provide helpful diagnostics for shebang lookalikes)
 - rust-lang#138353 (remove must_use from <*const T>::expose_provenance)
 - rust-lang#138452 (Remove `RUN_CHECK_WITH_PARALLEL_QUERIES`)
 - rust-lang#138469 (remove comment regarding a removed test directive)
 - rust-lang#138477 (Deny impls for `BikeshedGuaranteedNoDrop`)
 - rust-lang#138485 (Rustc dev guide subtree update)
 - rust-lang#138487 (Pass `CI_JOB_DOC_URL` to Docker)
 - rust-lang#138495 (Take a break from reviews)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f8842bd into rust-lang:master Mar 14, 2025
6 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Mar 14, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 14, 2025
Rollup merge of rust-lang#134720 - malezjaa:feat/crate-type-valid-values, r=jieyouxu

Display valid crate types in error message for --crate-type flag

This PR improves the error message for the --crate-type flag. When an invalid crate type is provided, the compiler will now show a list of valid options.

### Before
![image](https://github.com/user-attachments/assets/4922e4e5-eeca-40cd-ac1c-1c6319a81aee)

### After
![image](https://github.com/user-attachments/assets/67ea1f35-aa41-4e4f-8691-47c273d0cff9)

I based the implementation on `OutputType::shorthands_display`

Closes rust-lang#70183
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request Mar 19, 2025
Rollup of 9 pull requests

Successful merges:

 - rust-lang#134720 (Display valid crate types in error message for --crate-type flag)
 - rust-lang#137619 (Provide helpful diagnostics for shebang lookalikes)
 - rust-lang#138353 (remove must_use from <*const T>::expose_provenance)
 - rust-lang#138452 (Remove `RUN_CHECK_WITH_PARALLEL_QUERIES`)
 - rust-lang#138469 (remove comment regarding a removed test directive)
 - rust-lang#138477 (Deny impls for `BikeshedGuaranteedNoDrop`)
 - rust-lang#138485 (Rustc dev guide subtree update)
 - rust-lang#138487 (Pass `CI_JOB_DOC_URL` to Docker)
 - rust-lang#138495 (Take a break from reviews)

r? `@ghost`
`@rustbot` modify labels: rollup
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.

rustc --crate-type flag should display valid values
10 participants