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

Inconsistent reporting of [E0733] between cargo check and cargo run #13877

Closed
bragov4ik opened this issue May 7, 2024 · 3 comments
Closed

Inconsistent reporting of [E0733] between cargo check and cargo run #13877

bragov4ik opened this issue May 7, 2024 · 3 comments
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.

Comments

@bragov4ik
Copy link

Problem

I encountered a weird issue where cargo check reports success, whereas cargo run (or build, test, etc.) results in compilation error (of course with exactly the same feature flags and cfg(test)).

I expected them to be consistent, (check should report all build failures as far as I undestand)

Steps

  1. Use the following minimal reproducible example
pub trait Foo {
    type Dependency: Foo;

    async fn foo() {
        Self::Dependency::foo().await;
    }
}

impl Foo for () {
    type Dependency = ();
}

#[tokio::main]
async fn main() {
    <()>::foo().await;
}
  1. Run cargo check - only warning is shown:
warning: `test-play` (bin "test-play") generated 1 warning
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.08s
  1. cargo build results in error:
error[E0733]: recursion in an async fn requires boxing
 --> src/main.rs:4:5
  |
4 |     async fn foo() {
  |     ^^^^^^^^^^^^^^
5 |         Self::Dependency::foo().await;
  |         ----------------------------- recursive call here
  |
  = note: a recursive `async fn` call must introduce indirection such as `Box::pin` to avoid an infinitely sized future

For more information about this error, try `rustc --explain E0733`.
error: could not compile `test-play` (bin "test-play") due to 1 previous error

Possible Solution(s)

Usage of associated type is an important part of repro. So the reason is somehow related to this

Notes

No response

Version

cargo 1.78.0 (54d8815d0 2024-03-26)
release: 1.78.0
commit-hash: 54d8815d04fa3816edc207bbc4dd36bf18014dbc
commit-date: 2024-03-26
host: aarch64-apple-darwin
libgit2: 1.7.2 (sys:0.18.2 vendored)
libcurl: 8.1.2 (sys:0.4.72+curl-8.6.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Mac OS 14.1.0 [64-bit]
@bragov4ik bragov4ik added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels May 7, 2024
@epage
Copy link
Contributor

epage commented May 7, 2024

I expected them to be consistent, (check should report all build failures as far as I undestand)

This is not actually true. There are post-monomorphization errors that do not get reported by check.

@bragov4ik
Copy link
Author

I expected them to be consistent, (check should report all build failures as far as I undestand)

This is not actually true. There are post-monomorphization errors that do not get reported by check.

So this is a feature rather than bug?
Did not expect this, thanks for explaining!

Should I close the issue then?..

@epage
Copy link
Contributor

epage commented May 7, 2024

You aren't the only one; I had the same perception until rust-lang/rfcs#3477 was posted.

The challenge is knowing whether this is a "bug" from that or something else. I think its likely safe to assume it is so I'll close this.

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants