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 #624

Closed
wants to merge 1 commit into from

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) -> u32;
}
struct Foo {
    foo: u32,
    bar: bool,
}
impl Bar for Foo {
    fn bar(&self) -> u32 {
        self.foo
    }
}
#[derive(Copy, Clone)]
struct Fat<'a>(&'a Foo, &'static VTable);
struct VTable {
    size: Foo,
}
const FOO: &Bar = &Foo {
    foo: 128,
    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: 128,
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 read of part of a pointer at .1.<deref>.size.foo
   |
   = 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: 128,
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 read of part of a pointer at .1.<deref>.size.foo
   |
   = 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`.
==============
@camelid camelid deleted the autofix/ices/79690.rs branch January 28, 2021 03:00
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.

1 participant