bazelbuild / bazelbuild/rules_rust

`rust_doc_test` Failed to link crates when proc-macro is used in the dependencies

Open
#980 4 comments 0 reactions 0 assignees View on GitHub
bug help wanted needs-triage rustdoc
Dominant language
Starlark
Stars
843
Forks
651
Avg merge
2d 18h
Merged PRs (30d)
15

Description

To describe the situation, I created the following small repository:
https://github.com/vbkaisetsu/rules-rust-link-fails-repro

# Steps to reproduce

1. Clone the repository.
```
git clone https://github.com/vbkaisetsu/rules-rust-link-fails-repro.git
```

2. Run the test.
```
cd rules-rust-link-fails-repro
bazel run //repro:my_lib_doc_test
```

3. The following error occurs:
```
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //repro:my_lib_doc_test
-----------------------------------------------------------------------------
error[E0460]: found possibly newer version of crate `fnv` which `tonic` depends on
--> repro/my_lib.rs:3:5
|
3 | use tonic::Status;
| ^^^^^
|
= note: perhaps that crate needs to be recompiled?
= note: the following crate versions were found:
crate `fnv`: /home/koichi.akabe/.cache/bazel/_bazel_koichi.akabe/65e8d7f25191e794777d18f078967787/execroot/link_fail_repro/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/raze__fnv__1_0_7/libfnv--1978688209.rlib
crate `tonic`: /home/koichi.akabe/.cache/bazel/_bazel_koichi.akabe/65e8d7f25191e794777d18f078967787/execroot/link_fail_repro/bazel-out/k8-fastbuild/bin/external/raze__tonic__0_5_2/libtonic--506703014.rlib

error: aborting due to previous error
```

# Workarounds

* Run the test with optimization.
```
bazel run -c opt //repro:my_lib_doc_test
```

* Change `cfg` of `proc_macro_deps` from `exec` to `target`.
https://github.com/bazelbuild/rules_rust/blob/82b650d5d0709ae4c0ee8584f4ed92112ba11d67/rust/private/rust.bzl#L575

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.