Skip to content

Commit 2634309

Browse files
committed
update comment
1 parent c9b21b0 commit 2634309

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

compiler/rustc_trait_selection/src/traits/coherence.rs

+15-10
Original file line numberDiff line numberDiff line change
@@ -746,17 +746,22 @@ impl<'tcx> TypeVisitor<'tcx> for OrphanChecker<'tcx> {
746746
result
747747
}
748748

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.
749764
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.
760765
ControlFlow::CONTINUE
761766
}
762767
}

0 commit comments

Comments
 (0)