Keep generic types when translating trait alias in monomorphized mode#1087
Keep generic types when translating trait alias in monomorphized mode#1087Sam-Ni wants to merge 8 commits intoAeneasVerif:mainfrom
Conversation
|
Hm that feels wrong, the way trait aliases are translated is that they're translated twice: once as |
I see. I misunderstood how impl blocks work for trait aliases. So we should keep a single trait declaration and provide separate impl blocks for different types, just like the normal traits. Is that correct? |
|
Yep, that's what I had in mind so that trait aliases can be as close to normal traits as possible |
| // Exclude trait impl of trait alias, | ||
| // For exmaple., we use the name `{impl B for i32}` rather than `{impl B for i32}::i32`, | ||
| // where `B` is a trait alias and `i32` is the generic argument for `Self`. |
There was a problem hiding this comment.
I'm confused by that remark: I don't see how we can ever get {impl B for i32}::i32. We can get {impl B for i32} or we can get {impl<T> B for T}::i32. To me {impl B for i32}::i32 feels like something got messed up in the generics handling, no?
There was a problem hiding this comment.
Yes, you’re right. The remark is misleading. What I meant to say is that, to avoid generating names like {impl B for i32}::i32 for the trait impl of a trait alias, we need to check src.kind in the if statement below the remark.
Is it better not to include such incorrect examples in the remark (since they can cause confusion)?
There was a problem hiding this comment.
It is obviously better not to include incorrect examples, but what I'd really want is a correct example and explanation
There was a problem hiding this comment.
Got it. I'll do that.
|
The remark is updated to include clearer explanations and examples on how trait implementations for aliases are translated in mono mode. If anything is still unclear or confusing, please let me know. |
This PR closes #1086 . We keep the generic types (such as
Self) of trait aliases in their declarations and impl blocks to make it consistent with the "normal" trait declarations in mono mode.