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

Add and use expect methods to hir. #107125

Conversation

WaffleLapkin
Copy link
Member

The future has come.

r? @Nilstrieb

tbh I'm not even sure if it's worth it

@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 Jan 20, 2023
/// Expect an [`ItemKind::ExternCrate`] or panic.
#[track_caller]
pub fn expect_extern_crate(&self) -> Option<Symbol> {
let ItemKind::ExternCrate(s) = self.kind else { unreachable!() };
Copy link
Member

Choose a reason for hiding this comment

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

these should probably be bug!s

Copy link
Member

Choose a reason for hiding this comment

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

even more ideally, they'd say "expected an extern crate, got {:?}" or something -- makes it much easier at a glance (or a stack trace submitted on an issue) to know what's up

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think bug!s are available at this point in the crate graph :(

Copy link
Member

Choose a reason for hiding this comment

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

nooooooo

ok well can u at least improve the panic message?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I'll improve the messages (not today tho, I'm tired and tired)

@rust-log-analyzer

This comment has been minimized.

@Noratrieb Noratrieb 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 Jan 21, 2023
@WaffleLapkin
Copy link
Member Author

@rustbot ready

@rustbot rustbot 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 Jan 30, 2023
#[track_caller]
fn expect_failed(&self, expected: &'static str) -> ! {
panic!("expected {expected} node, found {self:?}")
}
Copy link
Member

Choose a reason for hiding this comment

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

This file is way too big and should be split apart into like defs, helpers, expects etc. at some point :(
But it's fine for this PR

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, a lot of files are like this :(

Copy link
Member

Choose a reason for hiding this comment

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

:(

Copy link
Member

@Noratrieb Noratrieb left a comment

Choose a reason for hiding this comment

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

Looks good, looking forward to follow up PRs using it in more places :)

@Noratrieb
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jan 30, 2023

📌 Commit 883145f has been approved by Nilstrieb

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

Rollup of 7 pull requests

Successful merges:

 - rust-lang#107125 (Add and use expect methods to hir.)
 - rust-lang#107172 (Reimplement NormalizeArrayLen based on SsaLocals)
 - rust-lang#107177 (Keep all theme-updating logic together)
 - rust-lang#107424 (Make Vec::clone_from and slice::clone_into share the same code)
 - rust-lang#107455 (use a more descriptive name)
 - rust-lang#107465 (`has_allow_dead_code_or_lang_attr` micro refactor)
 - rust-lang#107469 (Change turbofish context link to an archive link)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 4ac1796 into rust-lang:master Jan 30, 2023
@rustbot rustbot added this to the 1.69.0 milestone Jan 30, 2023
@WaffleLapkin WaffleLapkin deleted the expect_an_item_in_your_hir_by_the_next_morning branch January 31, 2023 11:06
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.

6 participants