special-casing 'static
when winnowing trivial candidates
#118965
Labels
A-traits
Area: Trait system
T-types
Relevant to the types team, which will review and decide on the PR/issue.
WG-trait-system-refactor
The Rustc Trait System Refactor Initiative (-Znext-solver)
The following code compiles (adapted from
tests/ui/trivial-bounds/trivial-bounds-object.rs
):while this doesn't:
There are two candidates to satisfy the bound
dyn A + '?0: A
:for the first case:
ObjectCandidate(_)
; no region constraintsParamCandidate(dyn A + 'static: A)
; requires'?0 = 'static
for the seecond one:
ObjectCandidate(_)
; no region constraintsParamCandidate(dyn A + 's: A)
; requires'?0 = 's
The different behavior arises because the param candidate in the first case is considered "global", unlike second case. Global param candidates are dropped in favor of any other candidate. This behavior was introduced by #51042 here:
rust/compiler/rustc_trait_selection/src/traits/select/mod.rs
Line 1816 in 604f185
The text was updated successfully, but these errors were encountered: