Skip to content

Commit

Permalink
update comment
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Jul 29, 2022
1 parent c9b21b0 commit 2634309
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions compiler/rustc_trait_selection/src/traits/coherence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,17 +746,22 @@ impl<'tcx> TypeVisitor<'tcx> for OrphanChecker<'tcx> {
result
}

/// All possible values for a constant parameter already exist
/// in the crate defining the trait, so they are always non-local[^1].
///
/// 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.
///
/// [^1]: This might not hold for function pointers or trait objects in the future.
/// As these should be quite rare as const arguments and especially rare as impl
/// parameters, allowing uncovered const parameters in impls seems more useful
/// than allowing `impl<T> Trait<local_fn_ptr, T> for i32` to compile.
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
}
}

0 comments on commit 2634309

Please sign in to comment.