charon
charon copied to clipboard
Bug: "Item is not monomorphic" for `--monomorphize`
Code snippet to reproduce the bug:
trait Modifiable<T> {
fn modify(&mut self, arg: &T) -> T;
}
impl <T : Clone> Modifiable<T> for i32 {
fn modify(&mut self, arg: &T) -> T {
*self += 1;
arg.clone()
}
}
fn modify_something<T: Clone>(arg: &T) -> T {
let x = &mut 199;
x.modify(arg)
}
fn main() {
let y = &mut 99;
assert!(!modify_something(&"Hello, world!".to_string()).is_empty());
assert_eq!(y.modify(&mut 100), 100);
}
Reproduction of error:
Then, we simply run:
charon rustc --monomorphize -- charon/tests/ui/mono.rs
Bug Report: Then we get the bug:
note: the error occurred when translating `core::fmt::{impl core::fmt::Display::<Str>}::fmt`, which is (transitively) used at the following location(s):
--> charon/tests/ui/mono.rs:16:32
|
16 | assert!(!modify_something(&"Hello, world!".to_string()).is_empty());
| ---------------------------
warning: Item is not monomorphic: Mono(ItemRef { contents: Node { id: Id { id: 1104 }, value: ItemRefContents { def_id: core::fmt::Formatter, generic_args: [Lifetime(Region { kind: ReBound(0, BoundRegion { var: 2, kind: Anon }) })], impl_exprs: [], in_trait: None, has_param: true } } })
Smaller reproduction:
fn main() {
let a = "Hello, world!".to_string();
}
Tried it again just now, this got fixed in the meantime :)