Skip to content

Debug assertions are turned off in alloctests #162469

Closed

Description

@maxdexh

The alloc collections make generous use of debug_assert to check their invariants in debug mode. But they don't get run in alloctests!

This led to confusion in #162462 (comment).

Steps to reproduce:

  • Add debug_assert!(false); to the body of VecDeque::new
  • ./x test alloctests runs without failures

Activity

  1. added
    T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
    C-bugCategory: This is a bug.
    on Sep 8, 2026
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 8, 2026
  3. bjorn3 commented on Sep 8, 2026

    @bjorn3
    Member

    Enabling debug assertions for the standard library tests would require recompiling the standard library with debug assertions enabled too as standard library tests must run with the exact same cargo configuration as the sysroot standard library was compiled with to prevent libcore getting duplicated (once from the sysroot through libtest and once as regular dependency of the crate that is being tested) and duplicate lang item errors getting emitted.

  4. maxdexh commented on Sep 8, 2026

    @maxdexh
    MemberAuthor

    Hmm, that's unfortunate. I still think the current state isn't ideal. Do the assertions at least run in CI, or are they actually just fancy code comments?

  5. bjorn3 commented on Sep 8, 2026

    @bjorn3
    Member

    Maybe the -alt builders enable them for the standard library? At least for the compiler the -alt builders should enable debug assertions.

  6. Kobzol commented on Sep 8, 2026

    @Kobzol
    Member

    We should be running all tests on test runners on CI with debug assertions enabled.

  7. maxdexh commented on Sep 8, 2026

    @maxdexh
    MemberAuthor

    By "we should", do you mean "I think we do this" or "we should do this"?

  8. Kobzol commented on Sep 8, 2026

    @Kobzol
    Member

    Sorry for not being clear :)

    RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-debug-assertions"
    we are doing this.

  9. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 8, 2026
  10. maxdexh commented on Sep 8, 2026

    @maxdexh
    MemberAuthor

    Good enough for me. Might lead to more confusion, but at least we don't have broken assertions anywhere :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions