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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

malezjaa
Copy link

@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
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
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
src/etc/pre-push.sh Outdated Show resolved Hide resolved
@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
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.

compiler/rustc_session/src/config.rs Outdated Show resolved Hide resolved
compiler/rustc_session/src/config.rs Outdated Show resolved Hide resolved
@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 removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 25, 2024
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Dec 25, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 25, 2024
…s, 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
Copy link
Contributor

bors commented Dec 25, 2024

⌛ Testing commit b56ec2f with merge a1a97f8b45542f1025e789626a889499c13aa9d9...

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-aux failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@bors
Copy link
Contributor

bors commented Dec 25, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 25, 2024
@clubby789
Copy link
Contributor

Looks like Cargo tests (possibly other tools too) will need some blessing/manual updatimg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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