Skip to content

Conversation

@Ezrashaw
Copy link
Contributor

Fixes #107454

Simple fix to emit error instead of ICEing. At some point, all the code in tests.rs should be refactored, there is a bit of duplication (this PR's code is repeated five times over lol).

r? @Nilstrieb (active on the linked issue?)

@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 Mar 18, 2023
@Noratrieb
Copy link
Member

Noratrieb commented Mar 18, 2023

Interesting, with #[test] it compiles but gives a warning (and doesn't run the inner test)

#[test]
fn uwu() {
    #[test]
    fn owo() {}
}
warning: cannot test inner items
 --> a.rs:3:2
  |
3 |     #[test]
  |     ^^^^^^^
  |
  = note: `#[warn(unnameable_test_items)]` on by default
  = note: this warning originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
running 1 test
test uwu ... ok

The lint also applies to #[test_case], so I think it would be more correct to not emit a hard error here and simple continue as normal, building the result and then letting the lint fire. Here, we have an Annotatable::Stmt with the StmtKind::Item. I guess this should just also be supported. (having it on something that isn't an item like a let statement is also a hard error for #[test].

@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 Mar 18, 2023
@Ezrashaw
Copy link
Contributor Author

@Nilstrieb Updated to match your description. I plan on doing something with custom_test_frameworks soonish but this is a good stopgap to stop an ICE.

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.

👀 sounds cool

@Ezrashaw
Copy link
Contributor Author

@Nilstrieb CI passing, can we land this?

@Noratrieb
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Mar 19, 2023

📌 Commit c05bebc 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 19, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 20, 2023
…iaskrgr

Rollup of 13 pull requests

Successful merges:

 - rust-lang#109249 (Update names/comments for new return-position impl trait in trait lowering strategy)
 - rust-lang#109259 (rustdoc: Fix missing private inlining)
 - rust-lang#109269 (rustdoc: cleanup some intermediate allocs)
 - rust-lang#109301 (fix: fix ICE in `custom-test-frameworks` feature)
 - rust-lang#109319 (Add test for `c_variadic` in rustdoc-json)
 - rust-lang#109323 (Ignore files in .gitignore in mir opt check)
 - rust-lang#109331 (rustdoc: implement bag semantics for function parameter search)
 - rust-lang#109337 (Improve `Iterator::collect_into` documentation)
 - rust-lang#109351 (rustdoc: Remove footnote references from doc summary)
 - rust-lang#109353 (Fix wrong crate name in custom MIR docs)
 - rust-lang#109362 (Split `items` from `-Zmeta-stats` in two.)
 - rust-lang#109370 (fix ClashingExternDeclarations lint ICE)
 - rust-lang#109375 (rustdoc: Fix improper escaping of deprecation reasons)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 5d3f460 into rust-lang:master Mar 20, 2023
@rustbot rustbot added this to the 1.70.0 milestone Mar 20, 2023
@Ezrashaw Ezrashaw deleted the fix-ctf-ice branch March 20, 2023 08:46
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 with inner function #[test_case]

4 participants