Skip to content

liballoc doc tests are "silently" failing #52243

Closed

Description

@glandium

I noticed this in the output running python x.py test locally:

   Doc-tests alloc
error: no global memory allocator found but one is required; link to std or add #[global_allocator] to a static item that implements the GlobalAlloc trait.

and that didn't make tests fail.

Cc: @SimonSapin

Activity

  1. glandium commented on Jul 11, 2018

    @glandium
    ContributorAuthor

    Same with panic_unwind:

       Doc-tests panic_unwind
    error: no global memory allocator found but one is required; link to std or add #[global_allocator] to a static item that implements the GlobalAlloc trait.
    
  2. SimonSapin commented on Jul 11, 2018

    @SimonSapin
    Contributor

    This error message is printed when running rustdoc --test src/liballoc/lib.rs […], but before running any test. The code printing it is in src/librustc_metadata/creader.rs. It looks like rustdoc is using that code in order to load the crate and find doctests in it. But since it’s not actually compiling this crate, not having an allocator is not a problem.

    So I think there are two issues:

    • rustdoc keeps doing its thing even though there are errors. It probably should call something like abort_if_errors on its rustc::session::Session instance at some point.
    • This error should not occur in the first place. One way to inhibit it would be to tell creader that we’re "compiling" an rlib (CrateTypeRlib) rather than some other crate type. rlibs do not need (yet) to have an allocator defined. This is possibly this line:

    crate_types: vec![config::CrateTypeDylib],

    The first issue could in some other situation hide a real problem, but in this case it makes the second one mostly harmless. The only bad consequence is some noise in the output of a test run.

  3. added
    A-testsuiteArea: The testsuite used to check the correctness of rustc
    T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
    on Jan 19, 2019
  4. RalfJung commented on Apr 18, 2019

    @RalfJung
    Member

    Related: #54010

  5. jethrogb commented on Jul 3, 2019

    @jethrogb
    Contributor

    @rustbot modify labels: +T-rustdoc

  6. rustbot commented on Jul 3, 2019

    @rustbot
    Collaborator

    Error: Parsing label command in comment failed: ...ify labels|error: must have : or to as label starter at >| +T-rustdo...

    Please let @rust-lang/release know if you're having trouble with this bot.

  7. added
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    on Jul 3, 2019
  8. added a commit that references this issue on Jan 20, 2020
    cd4652a
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

    A-testsuiteArea: The testsuite used to check the correctness of rustcC-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions