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

ices/71659.rs: fixed with errors #498

Merged
merged 1 commit into from
Oct 7, 2020
Merged

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Oct 7, 2020

Issue: rust-lang/rust#71659

#![feature(unsize)]

use core::marker::Unsize;

pub trait CastTo<T: ?Sized>: Unsize<T> {
    fn cast_to(&self) -> &T;
}

impl<T: ?Sized, U: ?Sized + Unsize<T>> CastTo<T> for U {
    fn cast_to(&self) -> &T {
        self
    }
}

impl<T: ?Sized> Cast for T {}
pub trait Cast {
    fn cast<T: ?Sized>(&self) -> &T
    where
        Self: CastTo<T>,
    {
        self
    }
}

pub trait Foo: CastTo<[i32]> {}
impl Foo for [i32; 0] {}

fn main() {
    let x: &dyn Foo = &[];
    let x = x.cast::<[i32]>();
}
=== stdout ===
=== stderr ===
error[E0277]: the trait bound `dyn Foo: CastTo<[i32]>` is not satisfied
  --> /home/runner/work/glacier/glacier/ices/71659.rs:30:15
   |
30 |     let x = x.cast::<[i32]>();
   |               ^^^^ the trait `CastTo<[i32]>` is not implemented for `dyn Foo`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
==============

=== stdout ===
=== stderr ===
error[E0277]: the trait bound `dyn Foo: CastTo<[i32]>` is not satisfied
  --> /home/runner/work/glacier/glacier/ices/71659.rs:30:15
   |
30 |     let x = x.cast::<[i32]>();
   |               ^^^^ the trait `CastTo<[i32]>` is not implemented for `dyn Foo`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
==============
@JohnTitor JohnTitor merged commit 8fa8640 into master Oct 7, 2020
@JohnTitor JohnTitor deleted the autofix/ices/71659.rs branch October 7, 2020 13:06
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.

2 participants