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

ices/62222.rs: fixed with errors #225

Closed
wants to merge 1 commit into from

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Dec 5, 2019

Issue: rust-lang/rust#62222

#![feature(const_generics)]

use std::mem::MaybeUninit;

#[repr(transparent)]
pub struct Vector<T, const N: usize>([T; N]);

impl<T, const N: usize> Vector<T, {N}> {
    pub fn x(self) -> T {
        let mut head = MaybeUninit::<T>::uninit();
        let mut tail = MaybeUninit::<[T; N - 1]>::uninit();
        let mut from = MaybeUninit::new(self);
        let tailp: *mut T = unsafe { mem::transmute(&mut tail) };
        let fromp: *mut MaybeUninit<T> = unsafe { mem::transmute(&mut from) };
        unsafe {
            head.as_mut_ptr().write(
                fromp
                    .replace(MaybeUninit::uninit())
                    .assume_init()
            );
        }
        for i in 1..N {
            unsafe {
                tailp.add(i - 1).write(
                    fromp
                        .add(i)
                        .replace(MaybeUninit::uninit())
                        .assume_init()
                );
            }
        }
        unsafe { tail.assume_init(); } // Drop the tail
        unsafe { head.assume_init() }
    }
}

fn main() {}
=== stdout ===
=== stderr ===
error[E0433]: failed to resolve: use of undeclared type or module `mem`
  --> /home/runner/work/glacier/glacier/ices/62222.rs:13:38
   |
13 |         let tailp: *mut T = unsafe { mem::transmute(&mut tail) };
   |                                      ^^^ use of undeclared type or module `mem`

error[E0433]: failed to resolve: use of undeclared type or module `mem`
  --> /home/runner/work/glacier/glacier/ices/62222.rs:14:51
   |
14 |         let fromp: *mut MaybeUninit<T> = unsafe { mem::transmute(&mut from) };
   |                                                   ^^^ use of undeclared type or module `mem`

warning: the feature `const_generics` is incomplete and may cause the compiler to crash
 --> /home/runner/work/glacier/glacier/ices/62222.rs:1:12
  |
1 | #![feature(const_generics)]
  |            ^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default

error: aborting due to 2 previous errors

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

=== stdout ===
=== stderr ===
error[E0433]: failed to resolve: use of undeclared type or module `mem`
  --> /home/runner/work/glacier/glacier/ices/62222.rs:13:38
   |
13 |         let tailp: *mut T = unsafe { mem::transmute(&mut tail) };
   |                                      ^^^ use of undeclared type or module `mem`

error[E0433]: failed to resolve: use of undeclared type or module `mem`
  --> /home/runner/work/glacier/glacier/ices/62222.rs:14:51
   |
14 |         let fromp: *mut MaybeUninit<T> = unsafe { mem::transmute(&mut from) };
   |                                                   ^^^ use of undeclared type or module `mem`

warning: the feature `const_generics` is incomplete and may cause the compiler to crash
 --> /home/runner/work/glacier/glacier/ices/62222.rs:1:12
  |
1 | #![feature(const_generics)]
  |            ^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0433`.
==============
@Alexendoo
Copy link
Member

This one is not actually fixed, I'll update it later today (and on the issue thread) to reflect that

I just merged a few that are definitely fixed but I want to double check all these const_generic ones that just came through. I believe some of them are still ICEs but just need updating slightly

@Alexendoo Alexendoo deleted the autofix/ices/62222.rs branch December 6, 2019 12:16
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