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

Build fails with rustc<=1.68.2 #2670

Closed
4 tasks done
H1rono opened this issue Dec 10, 2023 · 3 comments
Closed
4 tasks done

Build fails with rustc<=1.68.2 #2670

H1rono opened this issue Dec 10, 2023 · 3 comments
Labels
deficiency Something doesn't work as well as it could upstream An unresolvable issue: an upstream dependency bug

Comments

@H1rono
Copy link

H1rono commented Dec 10, 2023

Rocket Version

0.5.0

Operating System

macOS 14.1.2, ubuntu-latest in GitHub Actions

Rust Toolchain Version

rustc 1.68.2 (9eb3afe9e 2023-03-27)

What happened?

With rustc version <=1.68.2, compilation fails like this CI failure.

Test Case

// just include `rocket = "0.5.0"` in Cargo.toml
fn main() {
    println!("Hello, world!")
}

Log Output

error[E0061]: this function takes 1 argument but 0 arguments were supplied
  --> /Users/kh/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket-0.5.0/src/server.rs:76:5
   |
76 |     debug!("Received request: {:#?}", hyp_req);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ an argument of type `UnsafeArg` is missing
   |
note: associated function defined here
  --> /Users/kh/.cargo/registry/src/github.com-1ecc6299db9ec823/yansi-1.0.0-rc.1/src/paint.rs:56:8
   |
56 |     fn new(self) -> Painted<Self> where Self: Sized {
   |        ^^^
   = note: this error originates in the macro `$crate::__private_api::format_args` which comes from the expansion of the macro `debug` (in Nightly builds, run with -Z macro-backtrace for more info)
help: provide the argument
  --> /Users/kh/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.4.20/src/macros.rs:51:62
   |
51 |                 $crate::__private_api::format_args!($($arg)+)(/* UnsafeArg */),
   |                                                              +++++++++++++++++

error[E0308]: mismatched types
  --> /Users/kh/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket-0.5.0/src/server.rs:76:5
   |
76 |     debug!("Received request: {:#?}", hyp_req);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `UnsafeArg`, found struct `Painted`
   |
   = note: expected struct `UnsafeArg`
              found struct `Painted<UnsafeArg>`
   = note: this error originates in the macro `$crate::__private_api::format_args` which comes from the expansion of the macro `debug` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0061]: this function takes 1 argument but 0 arguments were supplied
   --> /Users/kh/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket-0.5.0/src/server.rs:163:9
    |
163 |         debug!("sending response: {:#?}", hyp_response);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ an argument of type `UnsafeArg` is missing
    |
note: associated function defined here
   --> /Users/kh/.cargo/registry/src/github.com-1ecc6299db9ec823/yansi-1.0.0-rc.1/src/paint.rs:56:8
    |
56  |     fn new(self) -> Painted<Self> where Self: Sized {
    |        ^^^
    = note: this error originates in the macro `$crate::__private_api::format_args` which comes from the expansion of the macro `debug` (in Nightly builds, run with -Z macro-backtrace for more info)
help: provide the argument
   --> |/Users/kh/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.4.20/src/macros.rs:51:62
    |
51  |                 $crate::__private_api::format_args!($($arg)+)(/* UnsafeArg */),
    |                                                              +++++++++++++++++

error[E0308]: mismatched types
   --> /Users/kh/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket-0.5.0/src/server.rs:163:9
    |
163 |         debug!("sending response: {:#?}", hyp_response);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `UnsafeArg`, found struct `Painted`
    |
    = note: expected struct `UnsafeArg`
               found struct `Painted<UnsafeArg>`
    = note: this error originates in the macro `$crate::__private_api::format_args` which comes from the expansion of the macro `debug` (in Nightly builds, run with -Z macro-backtrace for more info)

Some errors have detailed explanations: E0061, E0308.
For more information about an error, try `rustc --explain E0061`.
error: could not compile `rocket` due to 4 previous errors

Additional Context

I guessed that some changes in 1.69.0 introduced this bug, so I digged 1.69.0 changes but couldn't find any obvious one. :cry

System Checks

  • My bug report relates to functionality.
  • I have tested against the latest Rocket release or a recent git commit.
  • I have tested against the latest stable rustc toolchain.
  • I was unable to find this issue previously reported.
@H1rono H1rono added the triage A bug report being investigated label Dec 10, 2023
@SergioBenitez
Copy link
Member

It's possible to get Rocket to compile on 1.66 with the following Cargo.toml and cargo update -Z minimal-versions:

[dependencies]
rocket = "0.5.0"
pear = "0.2.7"
tokio-util = "0.6.10"
log = "0.4.20"
multer = "2.1"
percent-encoding = "2.3.1"
mime = "0.3.17"
serde = "1.0.193"
tempfile = "3.7"
tokio = "1.35"
either = "1.9"

This means that the breakage is caused by some dependency and not Rocket itself. I really don't know what is causing this issue, but given the above, it should be possible to perform a bisect of sorts to find the culprit. My best guess is that this was "fixed" (i.e., masked) by rust-lang/rust#106745, though I don't know how.

Given the above, I don't believe there's anything we can do in Rocket, short of downgrading whatever dependency is causing the issue. It would be nice, however, for us to go through all of the declared dependency versions in our Cargo.toml and ensure that the version requirement is minimally correct. It seems that for many dependencies, we're using some feature that was introduced after the stated dependency version, though this isn't what's causing the issue here.

@SergioBenitez SergioBenitez added upstream An unresolvable issue: an upstream dependency bug deficiency Something doesn't work as well as it could and removed triage A bug report being investigated labels Dec 12, 2023
@H1rono
Copy link
Author

H1rono commented Dec 13, 2023

Then, how about upgrading MSRV? The current MSRV is 1.56, as below.

rust-version = "1.56"

But now it is obvious that rocket is incompatible to rustc==1.56.

@SergioBenitez
Copy link
Member

SergioBenitez commented Dec 13, 2023

Then, how about upgrading MSRV? The current MSRV is 1.56, as below.

rust-version = "1.56"

But now it is obvious that rocket is incompatible to rustc==1.56.

That MSRV was correct until our dependencies went and upgraded their MSRV under us. If they were to downgrade their MSRV, Rocket would compile on 1.56, at least that's the theory. A different way to say that is that Rocket itself should compile with 1.56, but its dependencies appear to need at least 1.66, whereas at some point that wasn't the case. This is an issue with the MSRV Cargo.toml field in general: rust-lang/cargo#9930.

I'm not really sure what the best course of action is. If we choose the min MSRV of all of our dependencies, we miss out on a lower MSRV if a dependency were to make that possible in an update. If we choose the min MSRV for Rocket itself, then the MSRV may be incorrect when dependencies are taken into consideration.

There is no correct answer, it seems, at least not today. Even MSRV-aware dependency resolution is fraught with issues: you'd need to hold back updating dependencies, even when those updates are security sensitive. Perhaps the most practical answer is to choose the min MSRV across all dependencies at a point in time, or perhaps it's to eschew setting an MSRV altogether.

SergioBenitez added a commit that referenced this issue Feb 29, 2024
Also includes a work-around for a buggy `format_args!` macro found in
rustc 1.67 and 1.68.

Resolves #2670.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deficiency Something doesn't work as well as it could upstream An unresolvable issue: an upstream dependency bug
Projects
None yet
Development

No branches or pull requests

2 participants