@@ -746,17 +746,22 @@ impl<'tcx> TypeVisitor<'tcx> for OrphanChecker<'tcx> {
746
746
result
747
747
}
748
748
749
+ /// All possible values for a constant parameter already exist
750
+ /// in the crate defining the trait, so they are always non-local[^1].
751
+ ///
752
+ /// Because there's no way to have an impl where the first local
753
+ /// generic argument is a constant, we also don't have to fail
754
+ /// the orphan check when encountering a parameter or a generic constant.
755
+ ///
756
+ /// This means that we can completely ignore constants during the orphan check.
757
+ ///
758
+ /// See `src/test/ui/coherence/const-generics-orphan-check-ok.rs` for examples.
759
+ ///
760
+ /// [^1]: This might not hold for function pointers or trait objects in the future.
761
+ /// As these should be quite rare as const arguments and especially rare as impl
762
+ /// parameters, allowing uncovered const parameters in impls seems more useful
763
+ /// than allowing `impl<T> Trait<local_fn_ptr, T> for i32` to compile.
749
764
fn visit_const ( & mut self , _c : ty:: Const < ' tcx > ) -> ControlFlow < Self :: BreakTy > {
750
- // All possible values for a constant parameter already exist
751
- // in the crate defining the trait, so they are always non-local.
752
- //
753
- // Because there's no way to have an impl where the first local
754
- // generic argument is a constant, we also don't have to fail
755
- // the orphan check when encountering a parameter or a generic constant.
756
- //
757
- // This means that we can completely ignore constants during the orphan check.
758
- //
759
- // See `src/test/ui/coherence/const-generics-orphan-check-ok.rs` for examples.
760
765
ControlFlow :: CONTINUE
761
766
}
762
767
}
0 commit comments