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

ices/79690.rs: fixed with errors #658

Merged
merged 1 commit into from
Feb 17, 2021
Merged

ices/79690.rs: fixed with errors #658

merged 1 commit into from
Feb 17, 2021

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#79690

union Transmute<T: Copy, U: Copy> {
    t: T,
    u: U,
}
trait Bar {
    fn bar(&self) -> bool;
}
struct Foo {
    foo: bool,
    bar: bool,
}
impl Bar for Foo {
    fn bar(&self) -> bool {
        self.foo
    }
}
#[derive(Copy, Clone)]
struct Fat<'a>(&'a Foo, &'static VTable);
struct VTable {
    size: Foo,
}
const FOO: &Bar = &Foo {
    foo: true,
    bar: false,
};
const G: Fat = unsafe { Transmute { t: FOO }.u };

fn main() {}
=== stdout ===
=== stderr ===
warning: trait objects without an explicit `dyn` are deprecated
  --> /home/runner/work/glacier/glacier/ices/79690.rs:22:13
   |
22 | const FOO: &Bar = &Foo {
   |             ^^^ help: use `dyn`: `dyn Bar`
   |
   = note: `#[warn(bare_trait_objects)]` on by default

warning: union is never used: `Transmute`
 --> /home/runner/work/glacier/glacier/ices/79690.rs:1:7
  |
1 | union Transmute<T: Copy, U: Copy> {
  |       ^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: field is never read: `bar`
  --> /home/runner/work/glacier/glacier/ices/79690.rs:10:5
   |
10 |     bar: bool,
   |     ^^^^^^^^^

warning: field is never read: `size`
  --> /home/runner/work/glacier/glacier/ices/79690.rs:20:5
   |
20 |     size: Foo,
   |     ^^^^^^^^^

warning: constant is never used: `FOO`
  --> /home/runner/work/glacier/glacier/ices/79690.rs:22:1
   |
22 | / const FOO: &Bar = &Foo {
23 | |     foo: true,
24 | |     bar: false,
25 | | };
   | |__^

warning: constant is never used: `G`
  --> /home/runner/work/glacier/glacier/ices/79690.rs:26:1
   |
26 | const G: Fat = unsafe { Transmute { t: FOO }.u };
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0080]: it is undefined behavior to use this value
  --> /home/runner/work/glacier/glacier/ices/79690.rs:26:1
   |
26 | const G: Fat = unsafe { Transmute { t: FOO }.u };
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered (potentially part of) a pointer at .1.<deref>.size.foo, but expected plain (non-pointer) bytes
   |
   = 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.

error: aborting due to previous error; 6 warnings emitted

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

=== stdout ===
=== stderr ===
warning: trait objects without an explicit `dyn` are deprecated
  --> /home/runner/work/glacier/glacier/ices/79690.rs:22:13
   |
22 | const FOO: &Bar = &Foo {
   |             ^^^ help: use `dyn`: `dyn Bar`
   |
   = note: `#[warn(bare_trait_objects)]` on by default

warning: union is never used: `Transmute`
 --> /home/runner/work/glacier/glacier/ices/79690.rs:1:7
  |
1 | union Transmute<T: Copy, U: Copy> {
  |       ^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: field is never read: `bar`
  --> /home/runner/work/glacier/glacier/ices/79690.rs:10:5
   |
10 |     bar: bool,
   |     ^^^^^^^^^

warning: field is never read: `size`
  --> /home/runner/work/glacier/glacier/ices/79690.rs:20:5
   |
20 |     size: Foo,
   |     ^^^^^^^^^

warning: constant is never used: `FOO`
  --> /home/runner/work/glacier/glacier/ices/79690.rs:22:1
   |
22 | / const FOO: &Bar = &Foo {
23 | |     foo: true,
24 | |     bar: false,
25 | | };
   | |__^

warning: constant is never used: `G`
  --> /home/runner/work/glacier/glacier/ices/79690.rs:26:1
   |
26 | const G: Fat = unsafe { Transmute { t: FOO }.u };
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0080]: it is undefined behavior to use this value
  --> /home/runner/work/glacier/glacier/ices/79690.rs:26:1
   |
26 | const G: Fat = unsafe { Transmute { t: FOO }.u };
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered (potentially part of) a pointer at .1.<deref>.size.foo, but expected plain (non-pointer) bytes
   |
   = 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.

error: aborting due to previous error; 6 warnings emitted

For more information about this error, try `rustc --explain E0080`.
==============
@JohnTitor JohnTitor merged commit fc982bf into master Feb 17, 2021
@JohnTitor JohnTitor deleted the autofix/ices/79690.rs branch February 17, 2021 16:44
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