Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

ices/62742.rs: fixed with errors #1190

Closed
wants to merge 1 commit into from
Closed

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#62742

use std::marker::PhantomData;

fn _alias_check() {
    WrongImpl::foo(0i32);       // crash
    WrongImpl::<()>::foo(0i32); // fine
    CorrectImpl::foo(0i32);     // fine
}

pub trait Raw<T: ?Sized> {
    type Value;
}

pub type WrongImpl<T> = SafeImpl<T, RawImpl<T>>;

pub type CorrectImpl<T> = SafeImpl<[T], RawImpl<T>>;

pub struct RawImpl<T>(PhantomData<T>);

impl<T> Raw<[T]> for RawImpl<T> {
    type Value = T;
}

pub struct SafeImpl<T: ?Sized, A: Raw<T>>(PhantomData<(A, T)>);

impl<T: ?Sized, A: Raw<T>> SafeImpl<T, A> {
    pub fn foo(value: A::Value) {}
}
=== stdout ===
=== stderr ===
error[E0601]: `main` function not found in crate `62742`
  --> /home/runner/work/glacier/glacier/ices/62742.rs:27:2
   |
27 | }
   |  ^ consider adding a `main` function to `/home/runner/work/glacier/glacier/ices/62742.rs`

error[E0277]: the trait bound `RawImpl<_>: Raw<_>` is not satisfied
  --> /home/runner/work/glacier/glacier/ices/62742.rs:4:5
   |
4  |     WrongImpl::foo(0i32);       // crash
   |     ^^^^^^^^^ the trait `Raw<_>` is not implemented for `RawImpl<_>`
   |
   = help: the following implementations were found:
             <RawImpl<T> as Raw<[T]>>
note: required by a bound in `SafeImpl`
  --> /home/runner/work/glacier/glacier/ices/62742.rs:23:35
   |
23 | pub struct SafeImpl<T: ?Sized, A: Raw<T>>(PhantomData<(A, T)>);
   |                                   ^^^^^^ required by this bound in `SafeImpl`

error[E0599]: the function or associated item `foo` exists for struct `SafeImpl<(), RawImpl<()>>`, but its trait bounds were not satisfied
  --> /home/runner/work/glacier/glacier/ices/62742.rs:5:22
   |
5  |     WrongImpl::<()>::foo(0i32); // fine
   |                      ^^^ function or associated item cannot be called on `SafeImpl<(), RawImpl<()>>` due to unsatisfied trait bounds
...
17 | pub struct RawImpl<T>(PhantomData<T>);
   | -------------------------------------- doesn't satisfy `RawImpl<()>: Raw<()>`
...
23 | pub struct SafeImpl<T: ?Sized, A: Raw<T>>(PhantomData<(A, T)>);
   | --------------------------------------------------------------- function or associated item `foo` not found for this
   |
   = note: the following trait bounds were not satisfied:
           `RawImpl<()>: Raw<()>`
note: the following trait must be implemented
  --> /home/runner/work/glacier/glacier/ices/62742.rs:9:1
   |
9  | / pub trait Raw<T: ?Sized> {
10 | |     type Value;
11 | | }
   | |_^

error[E0277]: the trait bound `RawImpl<()>: Raw<()>` is not satisfied
  --> /home/runner/work/glacier/glacier/ices/62742.rs:5:5
   |
5  |     WrongImpl::<()>::foo(0i32); // fine
   |     ^^^^^^^^^^^^^^^ the trait `Raw<()>` is not implemented for `RawImpl<()>`
   |
   = help: the following implementations were found:
             <RawImpl<T> as Raw<[T]>>
note: required by a bound in `SafeImpl`
  --> /home/runner/work/glacier/glacier/ices/62742.rs:23:35
   |
23 | pub struct SafeImpl<T: ?Sized, A: Raw<T>>(PhantomData<(A, T)>);
   |                                   ^^^^^^ required by this bound in `SafeImpl`

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0277, E0599, E0601.
For more information about an error, try `rustc --explain E0277`.
==============

=== stdout ===
=== stderr ===
error[E0601]: `main` function not found in crate `62742`
  --> /home/runner/work/glacier/glacier/ices/62742.rs:27:2
   |
27 | }
   |  ^ consider adding a `main` function to `/home/runner/work/glacier/glacier/ices/62742.rs`

error[E0277]: the trait bound `RawImpl<_>: Raw<_>` is not satisfied
  --> /home/runner/work/glacier/glacier/ices/62742.rs:4:5
   |
4  |     WrongImpl::foo(0i32);       // crash
   |     ^^^^^^^^^ the trait `Raw<_>` is not implemented for `RawImpl<_>`
   |
   = help: the following implementations were found:
             <RawImpl<T> as Raw<[T]>>
note: required by a bound in `SafeImpl`
  --> /home/runner/work/glacier/glacier/ices/62742.rs:23:35
   |
23 | pub struct SafeImpl<T: ?Sized, A: Raw<T>>(PhantomData<(A, T)>);
   |                                   ^^^^^^ required by this bound in `SafeImpl`

error[E0599]: the function or associated item `foo` exists for struct `SafeImpl<(), RawImpl<()>>`, but its trait bounds were not satisfied
  --> /home/runner/work/glacier/glacier/ices/62742.rs:5:22
   |
5  |     WrongImpl::<()>::foo(0i32); // fine
   |                      ^^^ function or associated item cannot be called on `SafeImpl<(), RawImpl<()>>` due to unsatisfied trait bounds
...
17 | pub struct RawImpl<T>(PhantomData<T>);
   | -------------------------------------- doesn't satisfy `RawImpl<()>: Raw<()>`
...
23 | pub struct SafeImpl<T: ?Sized, A: Raw<T>>(PhantomData<(A, T)>);
   | --------------------------------------------------------------- function or associated item `foo` not found for this
   |
   = note: the following trait bounds were not satisfied:
           `RawImpl<()>: Raw<()>`
note: the following trait must be implemented
  --> /home/runner/work/glacier/glacier/ices/62742.rs:9:1
   |
9  | / pub trait Raw<T: ?Sized> {
10 | |     type Value;
11 | | }
   | |_^

error[E0277]: the trait bound `RawImpl<()>: Raw<()>` is not satisfied
  --> /home/runner/work/glacier/glacier/ices/62742.rs:5:5
   |
5  |     WrongImpl::<()>::foo(0i32); // fine
   |     ^^^^^^^^^^^^^^^ the trait `Raw<()>` is not implemented for `RawImpl<()>`
   |
   = help: the following implementations were found:
             <RawImpl<T> as Raw<[T]>>
note: required by a bound in `SafeImpl`
  --> /home/runner/work/glacier/glacier/ices/62742.rs:23:35
   |
23 | pub struct SafeImpl<T: ?Sized, A: Raw<T>>(PhantomData<(A, T)>);
   |                                   ^^^^^^ required by this bound in `SafeImpl`

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0277, E0599, E0601.
For more information about an error, try `rustc --explain E0277`.
==============
@Alexendoo Alexendoo closed this in 1714f42 Mar 31, 2022
@Alexendoo Alexendoo deleted the autofix/ices/62742.rs branch March 31, 2022 21:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant