3 ms·
Yes, that's true but that is an implementation detail that only comes into play when dealing with ABI, and then you should be using #[repr(transparent)] to ensu
by estebank 4y ago
Yes, that's true but that is an implementation detail that only comes into play when dealing with ABI, and then you should be using #[repr(transparent)] to ensure that the compiler won't do something else :)
- codeflo 4y agoSure, it’s good to point out the difference between “the behavior of a typical optimizing compiler” and “things actually guaranteed by the language”. The context of the discussion was the former, I think. I’m not even that certain that monomorphization is actually required in theory.
- estebank 4y agoYes, monomorphization isn't needed in theory, as long as the user-visible behavior remains the same, and in practice the team is exploring options[1] to identify cases where the currently manual practice of writing pub fn foo<T: AsRef<X>>(x: T) { inner_foo(x.as_ref()); } fn inner_foo(_: &X) { todo!() } can be instead done by the compiler automatically (turning monomorphized code back into polymorphic code, hence the polimorphization hame). [1]: https://rustc-dev-guide.rust-lang.org/backend/monomorph.html#polymorphization https://rustc-dev-guide.rust-lang.org/backend/monomorph.html...