Trait object (vtable) construction seems too imprecise about constraints on methods #135462
Labels
A-monomorphization
Area: Monomorphization
A-trait-objects
Area: trait objects, vtable layout
C-bug
Category: This is a bug.
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
S-has-mcve
Status: A Minimal Complete and Verifiable Example has been found for this issue
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
If I write a trait like this
where the method comes with a bound
T: Bound<A>
, and I instantiate a trait object with a typeT
(here,String
) which only meetsT: Bound<B>
, the method seems to be monomorphized nonetheless, despite the mismatching type; as long as the typeB
only differs fromA
in higher-ranked-lifetime stuff, and theBound<B> for String
impl is the only one among types sufficiently “similar” toA
.(compiler explorer)
The behavior I would have expected: The method's entry becomes
0
instead, and it's never monomorphized.This monomorphization then can become … “unhappy” … about the bad types:
(playground)
@rustbot label T-compiler, A-trait-objects, A-monomorphization, I-ICE
The text was updated successfully, but these errors were encountered: