Trait alias: Add trait + dyn causes compiler panic #106238
Labels
C-bug
Category: This is a bug.
glacier
ICE tracked in rust-lang/glacier.
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
This problem resulted from the aim to store a Trait Object with generics in another object. When using the
dyn
keyword to store the trait object, the compiler panics, but only when having used a trait alias in defining the trait. If the trait is implemented in a standard (stable complying) manner, compilation succedes.Here is a MWE of a compiler-panic version and a compiling version. This suggests that the used trait alias might be responsible. It seems that the Rust compiler does something different than just syntactic replacements when compiling a trait alias.
https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=05f0dd96c14a4f5ff5a301b21b006be4
I am still a beginner when it comes to Rust so any feedback is highly appreciated!
Meta
Since the trait alias feature is nightly only, this compiler was only tested.
rustc --version --verbose
:Error output
The text was updated successfully, but these errors were encountered: