Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crate fails to compile #570

Closed
Razican opened this issue Oct 24, 2023 · 3 comments · Fixed by #676
Closed

Crate fails to compile #570

Razican opened this issue Oct 24, 2023 · 3 comments · Fixed by #676
Labels
C-bug Category: doesn't meet expectations

Comments

@Razican
Copy link

Razican commented Oct 24, 2023

Steps to reproduce the bug with the above code

The 0.17.3 version of the boa_icu_provider crate fails to compile:
https://github.com/boa-dev/boa/tree/v0.17.3/boa_icu_provider

So:

  1. Clone the boa repo
  2. Checkout the v0.17.3 tag
  3. cd boa_icu_provider
  4. cargo semver-checks

With the latest cargo-semver-checks version in crates.io

Behaviour has also been observed in the CI/CD in Ubuntu Linux:
boa-dev/boa#3173

Actual Behaviour

It gives a bunch of errors, such as:

error[E0433]: failed to resolve: could not find `locid` in `_internal`
  --> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/icu_decimal-1.2.0/src/provider.rs:84:1
   |
84 | / #[icu_provider::data_struct(marker(
85 | |     DecimalSymbolsV1Marker,
86 | |     "decimal/symbols@1",
87 | |     extension_key = "nu"
88 | | ))]
   | |___^ could not find `locid` in `_internal`
   |
   = note: this error originates in the attribute macro `icu_provider::data_struct` (in Nightly builds, run with -Z macro-backtrace for more info)

Expected Behaviour

Compilation works, since cargo build, cargo test and cargo doc all work fine.

Generated System Information

Software version

cargo-semver-checks 0.24.1

Operating system

macOS 14.0 (Darwin 23.0.0)

Command-line

~/.cargo/bin/cargo-semver-checks semver-checks --bugreport 

cargo version

> cargo -V 
cargo 1.73.0 (9c4383fb5 2023-08-26)

Compile time information

  • Profile: release
  • Target triple: aarch64-apple-darwin
  • Family: unix
  • OS: macos
  • Architecture: aarch64
  • Pointer width: 64
  • Endian: little
  • CPU features: aes,crc,dit,dotprod,dpb,dpb2,fcma,fhm,flagm,fp16,frintts,jsconv,lor,lse,neon,paca,pacg,pan,pmuv3,ras,rcpc,rcpc2,rdm,sb,sha2,sha3,ssbs,vh
  • Host: aarch64-apple-darwin

Build Configuration

[target.x86_64-apple-darwin]
rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/zld"]

Additional Context

It seems the error only happens with that particular crate in the workspace, and seems that the 0.18.0 (current semver-checks branch) works fine.

@Razican Razican added the C-bug Category: doesn't meet expectations label Oct 24, 2023
@obi1kenobi
Copy link
Owner

obi1kenobi commented Oct 27, 2023

Hi! Unfortunately I'm currently in the middle of moving to a new apartment, and debugging is hard when everything is being put into boxes 😅

If you happen to have some spare time to look into it, I'd recommend looking at the directory target/semver-checks to find the placeholder projects cargo-semver-checks generates. One of those placeholders should have a path dependency on boa_icu_providercd into its project directory and run the following command on nightly Rust:

RUSTDOCFLAGS="-Z unstable-options --document-private-items --document-hidden-items --output-format=json --cap-lints allow" cargo doc --no-deps --package boa_icu_provider

That's the equivalent of the command that cargo-semver-checks runs under the hood to generate the rustdoc which is currently failing. It should reproduce the cargo doc failure, and hopefully might give you a clue as to why this is failing.

If you don't have time to look into this, no worries. I'll need a few weeks to settle into my new place, and I'll try to circle back after that.

@obi1kenobi
Copy link
Owner

Sorry for the wait! I finally had a bit of time to dig into this issue:

I was able to confirm that this crate indeed fails to build, and the issue is not in cargo-semver-checks. Here's a way you can reproduce it:

cargo new --lib example
cd example
cargo add boa_icu_provider@=0.17.3 --no-default-features --features bin,default,full,std
cargo check

The cargo check command now fails with the same massive stream of error messages that cargo semver-checks was reporting, since this example crate construction closely matches what cargo-semver-checks does under the hood to generate rustdoc JSON.

This is an area where I've been working to improve the user experience — I'd like to help users self-diagnose these issues as often as possible. New versions of cargo-semver-checks output the following at the end of the error message:

error: failed to build rustdoc for crate boa_icu_provider v0.17.3
note: this is usually due to a compilation error in the crate,
      and is unlikely to be a bug in cargo-semver-checks
note: running the following command on the crate should reproduce the error:
      cargo build --no-default-features --features bin,default,full,std

However, in this case the suggested command does not reproduce the error, and I'm not sure why. I'm going to change it to instead suggest something like my repro above which should work ~100% of the time, since it exactly mirrors what cargo-semver-checks itself does.

Thanks for trying out cargo-semver-checks and sorry I couldn't dig into this issue sooner! Please let me know if you run into any other issues and I'd be happy to take a look.

obi1kenobi added a commit that referenced this issue Feb 28, 2024
Resolves #570 by making it more likely that users are able to resolve the build error on their own, instead of being confused about why cargo-semver-checks is failing to build their project.
@obi1kenobi
Copy link
Owner

Here's the error text I'm adding in #676:

error: failed to build rustdoc for crate boa_icu_provider v0.17.3
note: this is usually due to a compilation error in the crate,
      and is unlikely to be a bug in cargo-semver-checks
note: the following command can be used to reproduce the compilation error:
      cargo new --lib example &&
          cd example &&
          echo '[workspace]' >> Cargo.toml &&
          cargo add --path /tmp/boa/boa_icu_provider --no-default-features --features bin,default,full,std &&
          cargo check

I have confirmed this also reproduces the error. It's using --path /tmp/boa/boa_icu_provider instead of an exact version because I checked the project at that path instead of checking a specific registry version.

obi1kenobi added a commit that referenced this issue Feb 28, 2024
…676)

Resolves #570 by making it more likely that users are able to resolve the build error on their own, instead of being confused about why cargo-semver-checks is failing to build their project.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: doesn't meet expectations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants