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

ices/101667.rs: fixed with errors #1417

Merged
merged 1 commit into from
Sep 13, 2022
Merged

ices/101667.rs: fixed with errors #1417

merged 1 commit into from
Sep 13, 2022

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#101667

#![feature(return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]

use core::fmt::Debug;

trait Foo {
    fn baz(&self) -> impl Debug;
}

impl Foo for u32{
    fn baz(&self) -> u32{
        32
    }
}

fn main() {
    let i = Box::new(42_u32) as Box<dyn Foo>;
}
=== stdout ===
=== stderr ===
error[E0038]: the trait `Foo` cannot be made into an object
  --> /home/runner/work/glacier/glacier/ices/101667.rs:17:33
   |
17 |     let i = Box::new(42_u32) as Box<dyn Foo>;
   |                                 ^^^^^^^^^^^^ `Foo` cannot be made into an object
   |
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
  --> /home/runner/work/glacier/glacier/ices/101667.rs:7:8
   |
6  | trait Foo {
   |       --- this trait cannot be made into an object...
7  |     fn baz(&self) -> impl Debug;
   |        ^^^ ...because method `baz` references an `impl Trait` type in its return type
   = help: consider moving `baz` to another trait

error[E0038]: the trait `Foo` cannot be made into an object
  --> /home/runner/work/glacier/glacier/ices/101667.rs:17:13
   |
17 |     let i = Box::new(42_u32) as Box<dyn Foo>;
   |             ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
   |
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
  --> /home/runner/work/glacier/glacier/ices/101667.rs:7:8
   |
6  | trait Foo {
   |       --- this trait cannot be made into an object...
7  |     fn baz(&self) -> impl Debug;
   |        ^^^ ...because method `baz` references an `impl Trait` type in its return type
   = help: consider moving `baz` to another trait
   = note: required for `Box<u32>` to implement `CoerceUnsized<Box<dyn Foo>>`
   = note: required by cast to type `Box<dyn Foo>`

error: aborting due to 2 previous errors

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

=== stdout ===
=== stderr ===
error[E0038]: the trait `Foo` cannot be made into an object
  --> /home/runner/work/glacier/glacier/ices/101667.rs:17:33
   |
17 |     let i = Box::new(42_u32) as Box<dyn Foo>;
   |                                 ^^^^^^^^^^^^ `Foo` cannot be made into an object
   |
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
  --> /home/runner/work/glacier/glacier/ices/101667.rs:7:8
   |
6  | trait Foo {
   |       --- this trait cannot be made into an object...
7  |     fn baz(&self) -> impl Debug;
   |        ^^^ ...because method `baz` references an `impl Trait` type in its return type
   = help: consider moving `baz` to another trait

error[E0038]: the trait `Foo` cannot be made into an object
  --> /home/runner/work/glacier/glacier/ices/101667.rs:17:13
   |
17 |     let i = Box::new(42_u32) as Box<dyn Foo>;
   |             ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
   |
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
  --> /home/runner/work/glacier/glacier/ices/101667.rs:7:8
   |
6  | trait Foo {
   |       --- this trait cannot be made into an object...
7  |     fn baz(&self) -> impl Debug;
   |        ^^^ ...because method `baz` references an `impl Trait` type in its return type
   = help: consider moving `baz` to another trait
   = note: required for `Box<u32>` to implement `CoerceUnsized<Box<dyn Foo>>`
   = note: required by cast to type `Box<dyn Foo>`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0038`.
==============
@JohnTitor JohnTitor merged commit 931a1e0 into master Sep 13, 2022
@JohnTitor JohnTitor deleted the autofix/ices/101667.rs branch September 13, 2022 09:28
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