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

ices/80742.rs: fixed with errors #620

Merged
merged 1 commit into from
Jan 22, 2021
Merged

ices/80742.rs: fixed with errors #620

merged 1 commit into from
Jan 22, 2021

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#80742

#![feature(const_evaluatable_checked)]
#![feature(const_generics)]
#![allow(incomplete_features)]

use core::fmt::Debug;
use core::marker::PhantomData;

struct Inline<T>
where
    [u8; ::core::mem::size_of::<T>() + 1]: ,
{
    _phantom: PhantomData<T>,
    buf: [u8; ::core::mem::size_of::<T>() + 1],
}

impl<T> Inline<T>
where
    [u8; ::core::mem::size_of::<T>() + 1]: ,
{
    pub fn new(val: T) -> Inline<T> {
        todo!()
    }
}

fn main() {
    // let dst = Inline::<usize>::new(0); OK
    let dst = Inline::<dyn Debug>::new(0); // BANG!
}
=== stdout ===
=== stderr ===
error[E0599]: no function or associated item named `new` found for struct `Inline<dyn Debug>` in the current scope
   --> /home/runner/work/glacier/glacier/ices/80742.rs:27:36
    |
8   | / struct Inline<T>
9   | | where
10  | |     [u8; ::core::mem::size_of::<T>() + 1]: ,
11  | | {
12  | |     _phantom: PhantomData<T>,
13  | |     buf: [u8; ::core::mem::size_of::<T>() + 1],
14  | | }
    | |_- function or associated item `new` not found for this
...
27  |       let dst = Inline::<dyn Debug>::new(0); // BANG!
    |                                      ^^^ function or associated item not found in `Inline<dyn Debug>`
    |
    = note: the method `new` exists but the following trait bounds were not satisfied:
            `dyn Debug: Sized`

error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time
  --> /home/runner/work/glacier/glacier/ices/80742.rs:27:15
   |
8  | struct Inline<T>
   |               - required by this bound in `Inline`
...
27 |     let dst = Inline::<dyn Debug>::new(0); // BANG!
   |               ^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
   |
   = help: the trait `Sized` is not implemented for `dyn Debug`
help: consider relaxing the implicit `Sized` restriction
   |
8  | struct Inline<T: ?Sized>
   |                ^^^^^^^^

error: aborting due to 2 previous errors

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

=== stdout ===
=== stderr ===
error[E0599]: no function or associated item named `new` found for struct `Inline<dyn Debug>` in the current scope
   --> /home/runner/work/glacier/glacier/ices/80742.rs:27:36
    |
8   | / struct Inline<T>
9   | | where
10  | |     [u8; ::core::mem::size_of::<T>() + 1]: ,
11  | | {
12  | |     _phantom: PhantomData<T>,
13  | |     buf: [u8; ::core::mem::size_of::<T>() + 1],
14  | | }
    | |_- function or associated item `new` not found for this
...
27  |       let dst = Inline::<dyn Debug>::new(0); // BANG!
    |                                      ^^^ function or associated item not found in `Inline<dyn Debug>`
    |
    = note: the method `new` exists but the following trait bounds were not satisfied:
            `dyn Debug: Sized`

error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time
  --> /home/runner/work/glacier/glacier/ices/80742.rs:27:15
   |
8  | struct Inline<T>
   |               - required by this bound in `Inline`
...
27 |     let dst = Inline::<dyn Debug>::new(0); // BANG!
   |               ^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
   |
   = help: the trait `Sized` is not implemented for `dyn Debug`
help: consider relaxing the implicit `Sized` restriction
   |
8  | struct Inline<T: ?Sized>
   |                ^^^^^^^^

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0277, E0599.
For more information about an error, try `rustc --explain E0277`.
==============
@Alexendoo Alexendoo merged commit 1c19382 into master Jan 22, 2021
@Alexendoo Alexendoo deleted the autofix/ices/80742.rs branch January 22, 2021 12:47
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