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

fix: ensure bad #[test] invocs retain correct AST #110035

Merged
merged 2 commits into from
Apr 13, 2023

Conversation

Ezrashaw
Copy link
Contributor

@Ezrashaw Ezrashaw commented Apr 7, 2023

Fixes #109816

Ensures that a StmtKind::Item doesn't get converted into a plain Item (causing the ICE from the linked issue) Also unifies the error path a bit.

@rustbot
Copy link
Collaborator

rustbot commented Apr 7, 2023

r? @davidtwco

(rustbot has picked a reviewer for you, use r? to override)

@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 Apr 7, 2023
Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

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

r=me after fixing these two comments

compiler/rustc_builtin_macros/src/test.rs Outdated Show resolved Hide resolved
@@ -107,6 +107,36 @@ pub fn expand_test_or_bench(
return vec![];
}

let not_testable_error = |item: Option<&ast::Item>| {
let diag = &cx.sess.parse_sess.span_diagnostic;
let msg = "the `#[test]` attribute may only be used on a non-associated function";
Copy link
Member

Choose a reason for hiding this comment

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

Can you make this translatable? See #100717.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I'd prefer not to do this right now. The whole test.rs file hasn't been converted yet so I feel like that should happen all at once. Also there is some complexity with the error being downgraded to a lint in some cases.

I'm happy to do this if you really want, just not sure it's currently worth the effort.

@Ezrashaw
Copy link
Contributor Author

@davidtwco If you are happy with the untranslated diagnostic, can this be merged?

@davidtwco
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Apr 12, 2023

📌 Commit 9e70541 has been approved by davidtwco

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

Rollup of 8 pull requests

Successful merges:

 - rust-lang#109810 (Replace rustdoc-ui/{c,z}-help tests with a stable run-make test )
 - rust-lang#110035 (fix: ensure bad `#[test]` invocs retain correct AST)
 - rust-lang#110089 (sync::mpsc: synchronize receiver disconnect with initialization)
 - rust-lang#110103 (Report overflows gracefully with new solver)
 - rust-lang#110122 (Fix x check --stage 1 when download-ci-llvm=false)
 - rust-lang#110133 (Do not use ImplDerivedObligationCause for inherent impl method error reporting)
 - rust-lang#110135 (Revert "Don't recover lifetimes/labels containing emojis as character literals")
 - rust-lang#110235 (Fix `--extend-css` option)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit d40c827 into rust-lang:master Apr 13, 2023
@rustbot rustbot added this to the 1.70.0 milestone Apr 13, 2023
@Ezrashaw Ezrashaw deleted the improve-test-attr-expansion-code branch April 13, 2023 08:33
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: "expected statement" with rustc --test
4 participants