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

Spurious "cannot check whether the hidden type of opaque type satisfies auto traits" errors #115188

Closed
djc opened this issue Aug 24, 2023 · 3 comments · Fixed by #115294
Closed
Labels
C-bug Category: This is a bug. I-cycle Issue: A query cycle occurred while none was expected T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@djc
Copy link
Contributor

djc commented Aug 24, 2023

I have a proprietary code base that contains a GraphQL backend using async-graphql #[Object] macros on top code that uses sqlx compile-time query validation. If the query validation doesn't work correctly, I get a large amount of extra spew from the compiler.

Current output

error[E0063]: missing field `staff` in initializer of `UserRow`
  --> epoxide/src/graphql/feed.rs:51:33
   |
51 |                 Some(User::from(UserRow {
   |                                 ^^^^^^^ missing `staff`

(the actual problem, and then...)

error: cannot check whether the hidden type of opaque type satisfies auto traits
    --> epoxide/src/graphql/site/mutations.rs:1365:1
     |
1365 | #[Object]
     | ^^^^^^^^^
     |
note: opaque type is declared here
    --> epoxide/src/graphql/viewer.rs:202:56
     |
202  |     pub(super) async fn from_id(id: i64, app: &App) -> Option<Self> {
     |                                                        ^^^^^^^^^^^^
note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
    --> epoxide/src/graphql/site/mutations.rs:1365:1
     |
1365 | #[Object]
     | ^^^^^^^^^
     = note: required because it captures the following types: `ResumeTy`, `Follow`, `&Follow`, `i64`, `&ContextBase<'_, &Positioned<Field>>`, `&App`, `&Arc<App>`, `impl Future<Output = Option<User>>`, `()`
note: required because it's used within this `async` block
    --> epoxide/src/graphql/site/mutations.rs:1365:1
     |
1365 | #[Object]
     | ^^^^^^^^^
     = note: required because it captures the following types: `ResumeTy`, `&Follow`, `&ContextBase<'_, &Positioned<Field>>`, `[async block@epoxide/src/graphql/site/mutations.rs:1365:1: 1365:10]`, `()`
note: required because it's used within this `async fn` body
    --> epoxide/src/graphql/site/mutations.rs:1365:1
     |
1365 | #[Object]
     | ^^^^^^^^^
     = note: required because it captures the following types: `ResumeTy`, `&Follow`, `&ContextBase<'life2, &Positioned<Field>>`, `&ContextBase<'life2, &Positioned<Field>>`, `impl Future<Output = Result<Option<User>, Error>>`, `()`
note: required because it's used within this `async` block
    --> epoxide/src/graphql/site/mutations.rs:1365:1
     |
1365 | #[Object]
     | ^^^^^^^^^
     = note: required because it captures the following types: `ResumeTy`, `&Follow`, `bool`, `[async block@epoxide/src/graphql/site/mutations.rs:1365:1: 1365:10]`, `()`, `Option<User>`, `ContextBase<'_, &Positioned<SelectionSet>>`, `&Option<User>`, `&Option<User>`, `&ContextBase<'_, &Positioned<SelectionSet>>`, `&ContextBase<'_, &Positioned<SelectionSet>>`, `ContextBase<'life2, &Positioned<Field>>`, `&ContextBase<'life2, &Positioned<Field>>`, `&Positioned<Field>`, `&Positioned<Field>`, `Pin<Box<dyn Future<Output = Result<Value, ServerError>> + Send>>`, `Pin<Box<dyn Future<Output = Result<Value, ServerError>> + Send>>`, `[async block@epoxide/src/graphql/site/mutations.rs:1365:1: 1365:10]`, `Option<Site>`, `&Option<Site>`, `&Option<Site>`, `[async block@epoxide/src/graphql/site/mutations.rs:1365:1: 1365:10]`, `Option<bool>`, `&Option<bool>`, `&Option<bool>`
note: required because it's used within this `async` block
    --> epoxide/src/graphql/site/mutations.rs:1365:1
     |
1365 | #[Object]
     | ^^^^^^^^^
     = note: required for the cast from `Pin<Box<[async block@epoxide/src/graphql/site/mutations.rs:1365:1: 1365:10]>>` to `Pin<Box<dyn Future<Output = Result<Option<Value>, ServerError>> + Send>>`
     = note: the full name for the target type has been written to '/Users/djc/src/bolt/rust/domains/target/debug/deps/epoxide-e30fab28d4badf93.long-type-5277155311423037496.txt'
     = note: this error originates in the attribute macro `Object` (in Nightly builds, run with -Z macro-backtrace for more info)

(Repeated multiple times.)

Desired output

Only the first, actionable, error.

Rationale and extra context

This seems to be a regression from 1.71 to 1.72.

@djc djc added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 24, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 24, 2023
@compiler-errors compiler-errors self-assigned this Aug 24, 2023
@compiler-errors
Copy link
Member

Minimized:

async fn foo() {
    let y = Wrapper { };
}

struct Wrapper<T> { t: T }

fn is_send<T: Send>(_: T) {}

fn main() {
    is_send(foo());
}

This regressed in #113320, cc @oli-obk. It seems like it's super easy to trigger this (any auto trait on an async fn with a type error in it). That PR probably should get reworked to detect cycles more precisely...

@compiler-errors compiler-errors removed their assignment Aug 24, 2023
@djc
Copy link
Contributor Author

djc commented Aug 25, 2023

@compiler-errors wow, thank you for minimizing from my admittedly high-level description!

@cheesycod
Copy link

I got the same issue and am downgrading to 1.71.0 until fixed since its severely breaking tokio+axum

@bors bors closed this as completed in b4c63f0 Aug 28, 2023
@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 4, 2023
@fmease fmease added I-cycle Issue: A query cycle occurred while none was expected C-bug Category: This is a bug. and removed A-diagnostics Area: Messages for errors, warnings, and lints labels Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-cycle Issue: A query cycle occurred while none was expected T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants