virtual function elimination: llvm error: `Do not know how to promote this operator`
Open
Nobody has claimed this yet.
A-LLVM
C-bug
I-crash
requires-nightly
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
auto-reduced (treereduce-rust):
https://godbolt.org/z/GYMqsbo3j
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)
}
}
}
original code
original:
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
}
}
}
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
Program output
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!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the ICE with the reduced Rust program from the issue or its Godbolt link using -Zvirtual-function-elimination=true -Clto=true --crate-type=lib. Start by tracing the virtual-function-elimination path that reaches LLVM promotion, then verify the command completes without Do not know how to promote this operator!.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100