Repository: rust
Issue: virtual function elimination: llvm error: `Do not know how to promote this operator`
Labels: I-crash,A-LLVM,C-bug,requires-nightly

<!--
[31mICE[0m: Rustc ./cci-class-cast.rs '-Zvirtual-function-elimination=true -Clto=true --crate-type=lib -ooutputfile -Zdump-mir-dir=dir' 'rustc-LLVM ERROR: Do not know how to promote this operator!', 'rustc-LLVM ERROR: Do not know how to promote this operator!'
File: /tmp/im/cci-class-cast.rs
-->

auto-reduced (treereduce-rust):
````rust
pub mod kitty {
    use std::fmt;

    pub struct cat {
        meows: usize,
        pub how_hungry: isize,
        pub name: String,
    }

    impl fmt::Display for cat {
        fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
            write!(f, "{}", self.name)
        }
    }
}


````

<details><summary><strong>original code</strong></summary>
<p>

original:
````rust
pub mod kitty {
    use std::fmt;

    pub struct cat {
      meows : usize,
      pub how_hungry : isize,
      pub name : String,
    }

    impl fmt::Display for cat {
        fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
            write!(f, "{}", self.name)
        }
    }

    impl cat {
        fn meow(&mut self) {
            println!("Meow");
            self.meows += 1;
            if self.meows % 5 == 0 {
                self.how_hungry += 1;
            }
        }

    }

    impl cat {
        pub fn speak(&mut self) { self.meow(); }

        pub fn eat(&mut self) -> bool {
            if self.how_hungry > 0 {
                println!("OM NOM NOM");
                self.how_hungry -= 2;
                return true;
            }
            else {
                println!("Not hungry!");
                return false;
            }
        }
    }

    pub fn cat(in_x : usize, in_y : isize, in_name: String) -> cat {
        cat {
            meows: in_x,
            how_hungry: in_y,
            name: in_name
        }
    }
}

````
</p>
</details>

Version information
````
rustc 1.79.0-nightly (00ed4edb4 2024-04-17)
binary: rustc
commit-hash: 00ed4edb44ccc76d8cc992ef9f9f4634ea6d0e82
commit-date: 2024-04-17
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.3

````

Command:
`/home/matthias/.rustup/toolchains/master/bin/rustc -Zvirtual-function-elimination=true -Clto=true --crate-type=lib`

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary><strong>Program output</strong></summary>
<p>

```
warning: type `cat` should have an upper camel case name
 --> /tmp/icemaker_global_tempdir.8xGPA271RB07/rustc_testrunner_tmpdir_reporting.GzzcQXIiIZoj/mvce.rs:4:16
  |
4 |     pub struct cat {
  |                ^^^ help: convert the identifier to upper camel case (notice the capitalization): `Cat`
  |
  = note: `#[warn(non_camel_case_types)]` on by default

warning: field `meows` is never read
 --> /tmp/icemaker_global_tempdir.8xGPA271RB07/rustc_testrunner_tmpdir_reporting.GzzcQXIiIZoj/mvce.rs:5:9
  |
4 |     pub struct cat {
  |                --- field in this struct
5 |         meows: usize,
  |         ^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

rustc-LLVM ERROR: Do not know how to promote this operator!

```

</p>
</details>

<!--
query stack:

-->