]> git.lizzy.rs Git - rust.git/commitdiff
update comment
authorlcnr <rust@lcnr.de>
Fri, 29 Jul 2022 07:43:22 +0000 (09:43 +0200)
committerlcnr <rust@lcnr.de>
Fri, 29 Jul 2022 07:44:20 +0000 (09:44 +0200)
compiler/rustc_trait_selection/src/traits/coherence.rs

index da17a9c3da6b513a292417fee46c4c95347624d5..337fbb2c15e3ab66a33858a947d47799586ca41d 100644 (file)
@@ -746,17 +746,22 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
         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
     }
 }