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

TAIT fails where RPIT works #101903

Closed
oli-obk opened this issue Sep 16, 2022 · 2 comments · Fixed by #122950
Closed

TAIT fails where RPIT works #101903

oli-obk opened this issue Sep 16, 2022 · 2 comments · Fixed by #122950
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]`

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Sep 16, 2022

I tried this code:

trait Duh {}

impl Duh for i32 {}

trait Trait {
    type Assoc: Duh;
}

impl<R: Duh, F: FnMut() -> R> Trait for F {
    type Assoc = R;
}

type Sendable = impl Send;

type Foo = impl Trait<Assoc = Sendable>;

fn foo() -> Foo {
    || 42
}

I expected to see this happen: it compiles, just like

trait Duh {}

impl Duh for i32 {}

trait Trait {
    type Assoc: Duh;
}

impl<R: Duh, F: FnMut() -> R> Trait for F {
    type Assoc = R;
}

type Sendable = impl Send;

fn foo() -> impl Trait<Assoc = Sendable> {
    || 42
}

Instead, this happened:

error[[E0277]](https://doc.rust-lang.org/nightly/error-index.html#E0277): the trait bound `Sendable: Duh` is not satisfied
  --> src/lib.rs:19:5
   |
19 |     || 42
   |     ^^^^^ the trait `Duh` is not implemented for `Sendable`
   |
   = help: the trait `Duh` is implemented for `i32`
note: required for `[closure@src/lib.rs:19:5: 19:7]` to implement `Trait`
  --> src/lib.rs:10:31
   |
10 | impl<R: Duh, F: FnMut() -> R> Trait for F {
   |                               ^^^^^     ^
@oli-obk oli-obk added C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` labels Sep 16, 2022
@ShoyuVanilla
Copy link
Member

This seems to have been fixed somehow 🤔
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=f9e8edc6895aa6e5015b103594c8db5c
1.79.0-nightly(2024-03-21 0ad927c0c07b65fc0dae)

@oli-obk oli-obk added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Mar 22, 2024
@ShoyuVanilla
Copy link
Member

ShoyuVanilla commented Mar 23, 2024

Well, I've neglected the warning because it is compiled, but

warning: opaque type `Foo` does not satisfy its associated type bounds
  --> src/main.rs:18:23
   |
9  |     type Assoc: Duh;
   |                 --- this associated type bound is unsatisfied for `Sendable`
...
18 | type Foo = impl Trait<Assoc = Sendable>;
   |                       ^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(opaque_hidden_inferred_bound)]` on by default

the warning is almost same as before (though not a hard error) and the rust_lint doc has the same code in this issue and explains why it should be linted 😅

I'll add a test that addressing these.

ShoyuVanilla added a commit to ShoyuVanilla/rust that referenced this issue Mar 23, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 25, 2024
…kingjubilee

Rollup of 10 pull requests

Successful merges:

 - rust-lang#122707 (Fix a typo in the alloc::string::String docs)
 - rust-lang#122769 (extend comments for reachability set computation)
 - rust-lang#122892 (fix(bootstrap/dist): use versioned dirs when vendoring)
 - rust-lang#122896 (Update stdarch submodule)
 - rust-lang#122923 (In `pretty_print_type()`, print `async fn` futures' paths instead of spans.)
 - rust-lang#122950 (Add regression tests for rust-lang#101903)
 - rust-lang#122958 (Port backtrace dylib-dep test to a ui test)
 - rust-lang#123039 (Update books)
 - rust-lang#123044 (`Instance` is `Copy`)
 - rust-lang#123051 (did I mention that tests are super cool? )

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 25, 2024
…kingjubilee

Rollup of 10 pull requests

Successful merges:

 - rust-lang#122707 (Fix a typo in the alloc::string::String docs)
 - rust-lang#122769 (extend comments for reachability set computation)
 - rust-lang#122892 (fix(bootstrap/dist): use versioned dirs when vendoring)
 - rust-lang#122896 (Update stdarch submodule)
 - rust-lang#122923 (In `pretty_print_type()`, print `async fn` futures' paths instead of spans.)
 - rust-lang#122950 (Add regression tests for rust-lang#101903)
 - rust-lang#123039 (Update books)
 - rust-lang#123042 (Import the 2021 prelude in the core crate)
 - rust-lang#123044 (`Instance` is `Copy`)
 - rust-lang#123051 (did I mention that tests are super cool? )

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 26, 2024
…kingjubilee

Rollup of 10 pull requests

Successful merges:

 - rust-lang#122707 (Fix a typo in the alloc::string::String docs)
 - rust-lang#122769 (extend comments for reachability set computation)
 - rust-lang#122892 (fix(bootstrap/dist): use versioned dirs when vendoring)
 - rust-lang#122896 (Update stdarch submodule)
 - rust-lang#122923 (In `pretty_print_type()`, print `async fn` futures' paths instead of spans.)
 - rust-lang#122950 (Add regression tests for rust-lang#101903)
 - rust-lang#123039 (Update books)
 - rust-lang#123042 (Import the 2021 prelude in the core crate)
 - rust-lang#123044 (`Instance` is `Copy`)
 - rust-lang#123051 (did I mention that tests are super cool? )

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in 4856f9a Mar 26, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 26, 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. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]`
Development

Successfully merging a pull request may close this issue.

2 participants