rust-lang / rust-lang/rust

Can't find `thiserror_impl` crate with `-Z sanitizer`

Open
#132,109 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-sanitizers C-bug D-confusing T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I tried this code:

// (empty lib.rs)

Cargo.toml:

[package]
name = "nightly-cant-find-crate-test"
version = "0.1.0"
edition = "2021"

[dependencies]
thiserror = "1.0.65"

Compiling with env RUSTFLAGS="-Z sanitizer=address" cargo +nightly build

I expected to see this happen: Library compiles

Instead, this happened: Rust fails to find the crate thiserror_impl, even though it's a transitive dependency:

> env RUSTFLAGS="-Z sanitizer=address" cargo +nightly build
   Compiling proc-macro2 v1.0.89
   Compiling unicode-ident v1.0.13
   Compiling thiserror v1.0.65
   Compiling quote v1.0.37
   Compiling syn v2.0.85
   Compiling thiserror-impl v1.0.65
error[E0463]: can't find crate for `thiserror_impl`
   --> /home/col/.cargo/registry/src/index.crates.io-6f17d22bba15001f/thiserror-1.0.65/src/lib.rs:278:9
    |
278 | pub use thiserror_impl::*;
    |         ^^^^^^^^^^^^^^ can't find crate

For more information about this error, try `rustc --explain E0463`.

The crate builds without errors if I omit the sanitizer option, or replace it with something else like -Zub-checks. It also obviously builds with stable Rust.

Meta

rustc --version --verbose:

> rustup run nightly rustc --version
rustc 1.84.0-nightly (4f2f477fd 2024-10-23)
> cargo --version
cargo 1.82.0 (8f40fc59f 2024-08-21)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the empty lib.rs, the shown Cargo.toml, and RUSTFLAGS="-Z sanitizer=address" cargo +nightly build. Compare the sanitizer build with the successful build without that flag, focusing on the reported thiserror-1.0.65/src/lib.rs:278 lookup for thiserror_impl. Done means the nightly sanitizer build succeeds for this minimal project.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.