Skip to content

Conversation

@sharkdp
Copy link
Contributor

@sharkdp sharkdp commented Nov 26, 2024

Summary

This is about the easiest patch that I can think of. It has a drawback in that there is no real guarantee this won't happen again. I think this might be acceptable, given that all of this is a temporary thing. But there are other approaches we could take:

  • We could get rid of the debug/release distinction and just add @Todo type metadata everywhere. This has possible affects on runtime. The main reason I didn't follow through with this is that the size of Type increases. We would either have to adapt the assert_eq_size! test or get rid of it. Even if we add messages everywhere and get rid of the file-and-line-variant in the enum, it's not enough to get back to the current release-mode size of Type.
  • We could generally discard @Todo meta information when using it in tests. I think this would be a huge drawback. I like that we can have the actual messages in the mdtest. And make sure we get the expected @Todo type, not just any @Todo. It's also helpful when debugging tests.

We could also think about running tests in release mode via CI, if this is something that we need to support.

closes #14594

Test Plan

cargo nextest run --release

@sharkdp sharkdp added the ty Multi-file analysis & type inference label Nov 26, 2024
This is about the easiest patch that I can think of. It's simple, but
has a drawback in that there is no real guarantee this won't happen
again. I think this might be acceptable, given that all of this is a
temporary thing. But there are other approaches we could take:

- We could get rid of the debug/release distinction and just add `@Todo`
  type metadata everywhere. This has possible affects on runtime. The
  main reason I didn't follow through with this is that the size of
  `Type` increases. We would either have to adapt the `assert_eq_size!`
  test or get rid of it. Even if we add messages everywhere and get rid
  of the file-and-line-variant in the enum, it's not enough to get back
  to the current release-mode size of `Type`.
- We could generally discard `@Todo` meta information when using it in
  tests. I think this would be a huge drawback. I like that we can have
  the actual messages in the mdtest. And make sure we get the expected
  `@Todo` type, not just any `@Todo`. It's also helpful when debugging
  tests.
Comment on lines 187 to 189
regex::Regex::new(r"@Todo\([^)]*\)")
.unwrap()
.replace_all(ty, "@Todo")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This uses a regex instead of something like if ty.starts_with("@Todo(") { "@Todo" } else { ty } or similar, because there might be more complicated types like @Todo(…) | str.

Comment on lines +5988 to +5992
if cfg!(debug_assertions) {
"@Todo(async iterables/iterators)"
} else {
"@Todo"
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

An alternative here would be to rename assert_scope_ty to assert_scope_ty_str, and then introduce a new helper to directly assert on the actual Type, not its string representation. I would hope that this test can be migrated to an mdtest sooner or later (#13696).

@github-actions
Copy link
Contributor

github-actions bot commented Nov 26, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

This looks good to me. Considering that it's somewhat easy to introduce a new failure in the future, would you mind adding a test step to the release-job running on main

cargo-build-release:
name: "cargo build (release)"
runs-on: macos-latest
needs: determine_changes
if: ${{ github.ref == 'refs/heads/main' }}
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: "Install Rust toolchain"
run: rustup show
- name: "Install mold"
uses: rui314/setup-mold@v1
- uses: Swatinem/rust-cache@v2
- name: "Build"
run: cargo build --release --locked

@sharkdp sharkdp merged commit 0e71c9e into main Nov 26, 2024
21 checks passed
@sharkdp sharkdp deleted the david/fix-14594 branch November 26, 2024 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests failed for ruff 0.8.0

3 participants