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

ices/83182.rs: fixed with errors #757

Merged
merged 1 commit into from
May 17, 2021
Merged

ices/83182.rs: fixed with errors #757

merged 1 commit into from
May 17, 2021

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#83182

use std::mem;
struct MyStr(str);
const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) };

fn main() {}
=== stdout ===
=== stderr ===
warning: struct is never constructed: `MyStr`
 --> /home/runner/work/glacier/glacier/ices/83182.rs:2:8
  |
2 | struct MyStr(str);
  |        ^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: constant is never used: `MYSTR_NO_INIT`
 --> /home/runner/work/glacier/glacier/ices/83182.rs:3:1
  |
3 | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) };
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0080]: it is undefined behavior to use this value
 --> /home/runner/work/glacier/glacier/ices/83182.rs:3:1
  |
3 | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) };
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer in `str` at .<deref>.0
  |
  = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
  = note: the raw bytes of the constant (size: 16, align: 8) {
              ╾───────alloc3────────╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........
          }

error: aborting due to previous error; 2 warnings emitted

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

=== stdout ===
=== stderr ===
warning: struct is never constructed: `MyStr`
 --> /home/runner/work/glacier/glacier/ices/83182.rs:2:8
  |
2 | struct MyStr(str);
  |        ^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: constant is never used: `MYSTR_NO_INIT`
 --> /home/runner/work/glacier/glacier/ices/83182.rs:3:1
  |
3 | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) };
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0080]: it is undefined behavior to use this value
 --> /home/runner/work/glacier/glacier/ices/83182.rs:3:1
  |
3 | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) };
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer in `str` at .<deref>.0
  |
  = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
  = note: the raw bytes of the constant (size: 16, align: 8) {
              ╾───────alloc3────────╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........
          }

error: aborting due to previous error; 2 warnings emitted

For more information about this error, try `rustc --explain E0080`.
==============
@Alexendoo Alexendoo merged commit 91410fc into master May 17, 2021
@Alexendoo Alexendoo deleted the autofix/ices/83182.rs branch May 17, 2021 16:24
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