diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/coherence.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index fa94aa19abd..da17a9c3da6 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -746,8 +746,17 @@ impl<'tcx> TypeVisitor<'tcx> for OrphanChecker<'tcx> { result } - // FIXME: Constants should participate in orphan checking. fn visit_const(&mut self, _c: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> { + // All possible values for a constant parameter already exist + // in the crate defining the trait, so they are always non-local. + // + // Because there's no way to have an impl where the first local + // generic argument is a constant, we also don't have to fail + // the orphan check when encountering a parameter or a generic constant. + // + // This means that we can completely ignore constants during the orphan check. + // + // See `src/test/ui/coherence/const-generics-orphan-check-ok.rs` for examples. ControlFlow::CONTINUE } } |
