Skip to content

leptos regression #173

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

Open
compiler-errors opened this issue Apr 11, 2025 · 4 comments · May be fixed by rust-lang/rust#139762
Open

leptos regression #173

compiler-errors opened this issue Apr 11, 2025 · 4 comments · May be fixed by rust-lang/rust#139762
Assignees
Labels
from-crater A regression found via a crater run, not part of our test suite

Comments

@compiler-errors
Copy link
Member

compiler-errors commented Apr 11, 2025

edit: While this looks like a regression with tachys, turns out that leptos has its own fork of tachys: https://github.com/leptos-rs/leptos/tree/main/tachys

Not yet minimized.

https://crater-reports.s3.amazonaws.com/pr-133502-1/try%23fa8e241660363f48d64b66b05eea58c93ab828fb/reg/leptos-0.7.8/log.txt

[INFO] [stdout] error[E0391]: cycle detected when computing type of `reactive_graph::<impl at /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/reactive_graph/mod.rs:124:1: 128:23>::{synthetic#0}`
[INFO] [stdout]    --> /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/reactive_graph/mod.rs:138:5
[INFO] [stdout]     |
[INFO] [stdout] 138 |     async fn resolve(mut self) -> Self::AsyncOutput {
[INFO] [stdout]     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[INFO] [stdout]     |
[INFO] [stdout] note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
[INFO] [stdout]    --> /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/reactive_graph/mod.rs:138:5
[INFO] [stdout]     |
[INFO] [stdout] 138 |     async fn resolve(mut self) -> Self::AsyncOutput {
[INFO] [stdout]     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[INFO] [stdout] note: ...which requires computing type of `reactive_graph::<impl at /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/reactive_graph/mod.rs:124:1: 128:23>::resolve::{opaque#0}`...
[INFO] [stdout]    --> /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/reactive_graph/mod.rs:138:5
[INFO] [stdout]     |
[INFO] [stdout] 138 |     async fn resolve(mut self) -> Self::AsyncOutput {
[INFO] [stdout]     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[INFO] [stdout] note: ...which requires computing type of opaque `reactive_graph::<impl at /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/reactive_graph/mod.rs:124:1: 128:23>::resolve::{opaque#0}`...
[INFO] [stdout]    --> /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/reactive_graph/mod.rs:138:5
[INFO] [stdout]     |
[INFO] [stdout] 138 |     async fn resolve(mut self) -> Self::AsyncOutput {
[INFO] [stdout]     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[INFO] [stdout] note: ...which requires borrow-checking `reactive_graph::<impl at /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/reactive_graph/mod.rs:124:1: 128:23>::resolve`...
[INFO] [stdout]    --> /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/reactive_graph/mod.rs:138:5
[INFO] [stdout]     |
[INFO] [stdout] 138 |     async fn resolve(mut self) -> Self::AsyncOutput {
[INFO] [stdout]     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[INFO] [stdout] note: ...which requires promoting constants in MIR for `reactive_graph::<impl at /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/reactive_graph/mod.rs:124:1: 128:23>::resolve`...
[INFO] [stdout]    --> /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/reactive_graph/mod.rs:138:5
[INFO] [stdout]     |
[INFO] [stdout] 138 |     async fn resolve(mut self) -> Self::AsyncOutput {
[INFO] [stdout]     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[INFO] [stdout] note: ...which requires checking if `reactive_graph::<impl at /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/reactive_graph/mod.rs:124:1: 128:23>::resolve` contains FFI-unwind calls...
[INFO] [stdout]    --> /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/reactive_graph/mod.rs:138:5
[INFO] [stdout]     |
[INFO] [stdout] 138 |     async fn resolve(mut self) -> Self::AsyncOutput {
[INFO] [stdout]     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[INFO] [stdout] note: ...which requires building MIR for `reactive_graph::<impl at /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/reactive_graph/mod.rs:124:1: 128:23>::resolve`...
[INFO] [stdout]    --> /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/reactive_graph/mod.rs:138:5
[INFO] [stdout]     |
[INFO] [stdout] 138 |     async fn resolve(mut self) -> Self::AsyncOutput {
[INFO] [stdout]     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[INFO] [stdout] note: ...which requires match-checking `reactive_graph::<impl at /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/reactive_graph/mod.rs:124:1: 128:23>::resolve`...
[INFO] [stdout]    --> /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/reactive_graph/mod.rs:138:5
[INFO] [stdout]     |
[INFO] [stdout] 138 |     async fn resolve(mut self) -> Self::AsyncOutput {
[INFO] [stdout]     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[INFO] [stdout] note: ...which requires type-checking `reactive_graph::<impl at /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/reactive_graph/mod.rs:124:1: 128:23>::resolve`...
[INFO] [stdout]    --> /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/reactive_graph/mod.rs:138:5
[INFO] [stdout]     |
[INFO] [stdout] 138 |     async fn resolve(mut self) -> Self::AsyncOutput {
[INFO] [stdout]     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[INFO] [stdout]     = note: ...which again requires computing type of `reactive_graph::<impl at /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/reactive_graph/mod.rs:124:1: 128:23>::{synthetic#0}`, completing the cycle
[INFO] [stdout] note: cycle used when checking assoc item `html::<impl at /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/html/mod.rs:53:1: 53:28>::resolve` is compatible with trait definition
[INFO] [stdout]    --> /opt/rustwide/cargo-home/registry/src/index.crates.io-1949cf8c6b5b557f/tachys-0.1.8/src/html/mod.rs:60:5
[INFO] [stdout]     |
[INFO] [stdout] 60  |     async fn resolve(self) -> Self::AsyncOutput {
[INFO] [stdout]     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[INFO] [stdout]     = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
@compiler-errors
Copy link
Member Author

compiler-errors commented Apr 11, 2025

Smells like #158 though.

edit: possibly not. IDK.

@compiler-errors
Copy link
Member Author

compiler-errors commented Apr 11, 2025

Edit: THIS IS ON CRATES.IO'S VERSION OF TACHYS, NOT THE FORK!

Interestingly enough, there are more/different regressions when building tachys on nightly with the new solver:

error[E0275]: overflow evaluating the requirement `<InertElement as AddAnyAttr>::Output<NewAttr>: RenderHtml`
   --> src/html/mod.rs:141:32
    |
141 |         Self::Output<NewAttr>: RenderHtml,
    |                                ^^^^^^^^^^
    |
note: the requirement `<InertElement as AddAnyAttr>::Output<NewAttr>: RenderHtml` appears on the `impl`'s method `add_any_attr` but not on the corresponding trait's method
   --> src/view/add_attr.rs:16:8
    |
11  | pub trait AddAnyAttr {
    |           ---------- in this trait
...
16  |     fn add_any_attr<NewAttr: Attribute>(
    |        ^^^^^^^^^^^^ this trait's method doesn't have the requirement `<InertElement as AddAnyAttr>::Output<NewAttr>: RenderHtml`

error[E0275]: overflow evaluating the requirement `<InertElement as AddAnyAttr>::Output<NewAttr>: RenderHtml`
   --> src/html/mod.rs:141:32
    |
141 |         Self::Output<NewAttr>: RenderHtml,
    |                                ^^^^^^^^^^

error[E0275]: overflow evaluating the requirement `<InertElement as AddAnyAttr>::Output<NewAttr>: Sized`
   --> src/html/mod.rs:139:10
    |
139 |     ) -> Self::Output<NewAttr>
    |          ^^^^^^^^^^^^^^^^^^^^^
    |
    = note: the return type of a function must have a statically known size

error[E0275]: overflow evaluating the requirement `<InertElement as AddAnyAttr>::Output<NewAttr> well-formed`
   --> src/html/mod.rs:139:10
    |
139 |     ) -> Self::Output<NewAttr>
    |          ^^^^^^^^^^^^^^^^^^^^^

error[E0275]: overflow evaluating the requirement `<InertElement as AddAnyAttr>::Output<NewAttr> well-formed`
   --> src/html/mod.rs:141:32
    |
141 |         Self::Output<NewAttr>: RenderHtml,
    |                                ^^^^^^^^^^

error[E0275]: overflow evaluating the requirement `<AnyView as AddAnyAttr>::Output<NewAttr>: RenderHtml`
   --> src/view/any_view.rs:346:32
    |
346 |         Self::Output<NewAttr>: RenderHtml,
    |                                ^^^^^^^^^^
    |
note: the requirement `<AnyView as AddAnyAttr>::Output<NewAttr>: RenderHtml` appears on the `impl`'s method `add_any_attr` but not on the corresponding trait's method
   --> src/view/add_attr.rs:16:8
    |
11  | pub trait AddAnyAttr {
    |           ---------- in this trait
...
16  |     fn add_any_attr<NewAttr: Attribute>(
    |        ^^^^^^^^^^^^ this trait's method doesn't have the requirement `<AnyView as AddAnyAttr>::Output<NewAttr>: RenderHtml`

error[E0275]: overflow evaluating the requirement `<AnyView as AddAnyAttr>::Output<NewAttr>: RenderHtml`
   --> src/view/any_view.rs:346:32
    |
346 |         Self::Output<NewAttr>: RenderHtml,
    |                                ^^^^^^^^^^

error[E0275]: overflow evaluating the requirement `<AnyView as AddAnyAttr>::Output<NewAttr>: Sized`
   --> src/view/any_view.rs:344:10
    |
344 |     ) -> Self::Output<NewAttr>
    |          ^^^^^^^^^^^^^^^^^^^^^
    |
    = note: the return type of a function must have a statically known size

error[E0275]: overflow evaluating the requirement `<AnyView as AddAnyAttr>::Output<NewAttr> well-formed`
   --> src/view/any_view.rs:344:10
    |
344 |     ) -> Self::Output<NewAttr>
    |          ^^^^^^^^^^^^^^^^^^^^^

error[E0275]: overflow evaluating the requirement `<AnyView as AddAnyAttr>::Output<NewAttr> well-formed`
   --> src/view/any_view.rs:346:32
    |
346 |         Self::Output<NewAttr>: RenderHtml,

@compiler-errors compiler-errors changed the title tachys regression leptos ~~tachys~~ regression Apr 11, 2025
@compiler-errors
Copy link
Member Author

compiler-errors commented Apr 11, 2025

Minimal-ish:

//@ check-pass
//@ edition: 2018
//@ revisions: current next
//@[next] compile-flags: -Znext-solver
//@ ignore-compare-mode-next-solver (explicit revisions)

// Regression test for leptos when building it with the new solver. Unlike
// avoid-query-cycle-via-item-bound.rs we never actually use the auto trait bound
// of the opaque here, as that one is only necessary when trying to normalize the
// `<V as AttributeValue>::{synthetic#0}` RPITIT via the impl. Given the explicit
// `V: AttributeValue` where-bound, this associated item is rigid and we don't
// care whether the impl may apply.

use std::future::Future;

pub trait ReactiveFunction: Send {
    type Output;

    fn invoke(self) -> Self::Output;
}

trait AttributeValue {
    fn resolve(self) -> impl Future<Output = ()> + Send;
}

impl<F, V> AttributeValue for F
where
    F: ReactiveFunction<Output = V>,
    V: AttributeValue,
{
    async fn resolve(self) {
        // this require `Self::Output: `
        self.invoke().resolve().await
    }
}

fn main() {}

@compiler-errors
Copy link
Member Author

So, it seems that we're doing "unnecessary work" when normalizing the <V as AttributeValue>::{synthetic#0} RPITIT. Although the V: AttributeValue where clause in the impl should keep that associated type as rigid, we're still assembling the impl candidate which inevitably leads to a cycle error.

We could perhaps rework candidate assembly for NormalizesTo goals to only assemble param-env/alias-bound candidates when the trait goal is TraitGoalProvenVia::ParamEnv/AliasBound. 🤷

@compiler-errors compiler-errors changed the title leptos ~~tachys~~ regression leptos regression Apr 11, 2025
@lcnr lcnr added the from-crater A regression found via a crater run, not part of our test suite label Apr 14, 2025
@lcnr lcnr moved this from unknown to todo in -Znext-solver=globally Apr 14, 2025
@compiler-errors compiler-errors self-assigned this Apr 14, 2025
Zalathar added a commit to Zalathar/rust that referenced this issue Apr 15, 2025
…=compiler-errors

do not unnecessarily leak auto traits in item bounds

fixes rust-lang/trait-system-refactor-initiative#158

Not a fix for rust-lang/trait-system-refactor-initiative#173 as you may have realized/tried yourself, cc rust-lang#139788. However, fixing this feels desirable regardless and I don't see any reason not to.

r? `@compiler-errors`
jieyouxu added a commit to jieyouxu/rust that referenced this issue Apr 15, 2025
…=compiler-errors

do not unnecessarily leak auto traits in item bounds

fixes rust-lang/trait-system-refactor-initiative#158

Not a fix for rust-lang/trait-system-refactor-initiative#173 as you may have realized/tried yourself, cc rust-lang#139788. However, fixing this feels desirable regardless and I don't see any reason not to.

r? ``@compiler-errors``
Zalathar added a commit to Zalathar/rust that referenced this issue Apr 15, 2025
…=compiler-errors

do not unnecessarily leak auto traits in item bounds

fixes rust-lang/trait-system-refactor-initiative#158

Not a fix for rust-lang/trait-system-refactor-initiative#173 as you may have realized/tried yourself, cc rust-lang#139788. However, fixing this feels desirable regardless and I don't see any reason not to.

r? ```@compiler-errors```
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 15, 2025
Rollup merge of rust-lang#139789 - lcnr:opaques-auto-trait-leakage, r=compiler-errors

do not unnecessarily leak auto traits in item bounds

fixes rust-lang/trait-system-refactor-initiative#158

Not a fix for rust-lang/trait-system-refactor-initiative#173 as you may have realized/tried yourself, cc rust-lang#139788. However, fixing this feels desirable regardless and I don't see any reason not to.

r? ```@compiler-errors```
@lcnr lcnr moved this from todo to in progress in -Znext-solver=globally Apr 16, 2025
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this issue Apr 17, 2025
…-errors

do not unnecessarily leak auto traits in item bounds

fixes rust-lang/trait-system-refactor-initiative#158

Not a fix for rust-lang/trait-system-refactor-initiative#173 as you may have realized/tried yourself, cc #139788. However, fixing this feels desirable regardless and I don't see any reason not to.

r? ```@compiler-errors```
ChrisDenton added a commit to ChrisDenton/rust that referenced this issue Apr 19, 2025
Don't assemble non-env/bound candidates if projection is rigid

Putting this up for an initial review, it's still missing comments, clean-up, and possibly a tweak to deal with ambiguities in the `BestObligation` folder.

This PR fixes rust-lang/trait-system-refactor-initiative#173. Specifically, we're creating an unnecessary query cycle in normalization by assembling an *impl candidate* even if we know later on during `merge_candidates` that we'll be filtering out that impl candidate.

This PR adjusts the `merge_candidates` to assemble *only* env/bound candidates if we have `TraitGoalProvenVia::ParamEnv | TraitGoalProvenVia::AliasBound`.

I'll leave some thoughts/comments in the code.

r? lcnr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
from-crater A regression found via a crater run, not part of our test suite
Projects
Status: in progress
Development

Successfully merging a pull request may close this issue.

2 participants