@@ -407,10 +407,8 @@ impl<'hir> PathSegment<'hir> {
407407/// that are [just paths](ConstArgKind::Path) (currently just bare const params)
408408/// versus const args that are literals or have arbitrary computations (e.g., `{ 1 + 3 }`).
409409///
410- /// The `Unambig` generic parameter represents whether the position this const is from is
411- /// unambiguously a const or ambiguous as to whether it is a type or a const. When in an
412- /// ambiguous context the parameter is instantiated with an uninhabited type making the
413- /// [`ConstArgKind::Infer`] variant unusable and [`GenericArg::Infer`] is used instead.
410+ /// For an explanation of the `Unambig` generic parameter see the dev-guide:
411+ /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
414412#[ derive( Clone , Copy , Debug , HashStable_Generic ) ]
415413#[ repr( C ) ]
416414pub struct ConstArg < ' hir , Unambig = ( ) > {
@@ -429,6 +427,9 @@ impl<'hir> ConstArg<'hir, AmbigArg> {
429427 /// In practice this may mean overriding the [`Visitor::visit_infer`][visit_infer] method on hir visitors, or
430428 /// specifically matching on [`GenericArg::Infer`] when handling generic arguments.
431429 ///
430+ /// For an explanation of what it means for a const arg to be ambig or unambig, see the dev-guide:
431+ /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
432+ ///
432433 /// [visit_infer]: [rustc_hir::intravisit::Visitor::visit_infer]
433434 pub fn as_unambig_ct ( & self ) -> & ConstArg < ' hir > {
434435 // SAFETY: `ConstArg` is `repr(C)` and `ConstArgKind` is marked `repr(u8)` so that the
@@ -444,6 +445,9 @@ impl<'hir> ConstArg<'hir> {
444445 ///
445446 /// Functions accepting ambiguous consts will not handle the [`ConstArgKind::Infer`] variant, if
446447 /// infer consts are relevant to you then care should be taken to handle them separately.
448+ ///
449+ /// For an explanation of what it means for a const arg to be ambig or unambig, see the dev-guide:
450+ /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
447451 pub fn try_as_ambig_ct ( & self ) -> Option < & ConstArg < ' hir , AmbigArg > > {
448452 if let ConstArgKind :: Infer ( _, ( ) ) = self . kind {
449453 return None ;
@@ -475,6 +479,9 @@ impl<'hir, Unambig> ConstArg<'hir, Unambig> {
475479}
476480
477481/// See [`ConstArg`].
482+ ///
483+ /// For an explanation of the `Unambig` generic parameter see the dev-guide:
484+ /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
478485#[ derive( Clone , Copy , Debug , HashStable_Generic ) ]
479486#[ repr( u8 , C ) ]
480487pub enum ConstArgKind < ' hir , Unambig = ( ) > {
@@ -3302,10 +3309,8 @@ pub enum AmbigArg {}
33023309#[ repr( C ) ]
33033310/// Represents a type in the `HIR`.
33043311///
3305- /// The `Unambig` generic parameter represents whether the position this type is from is
3306- /// unambiguously a type or ambiguous as to whether it is a type or a const. When in an
3307- /// ambiguous context the parameter is instantiated with an uninhabited type making the
3308- /// [`TyKind::Infer`] variant unusable and [`GenericArg::Infer`] is used instead.
3312+ /// For an explanation of the `Unambig` generic parameter see the dev-guide:
3313+ /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
33093314pub struct Ty < ' hir , Unambig = ( ) > {
33103315 #[ stable_hasher( ignore) ]
33113316 pub hir_id : HirId ,
@@ -3323,6 +3328,9 @@ impl<'hir> Ty<'hir, AmbigArg> {
33233328 /// In practice this may mean overriding the [`Visitor::visit_infer`][visit_infer] method on hir visitors, or
33243329 /// specifically matching on [`GenericArg::Infer`] when handling generic arguments.
33253330 ///
3331+ /// For an explanation of what it means for a type to be ambig or unambig, see the dev-guide:
3332+ /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
3333+ ///
33263334 /// [visit_infer]: [rustc_hir::intravisit::Visitor::visit_infer]
33273335 pub fn as_unambig_ty ( & self ) -> & Ty < ' hir > {
33283336 // SAFETY: `Ty` is `repr(C)` and `TyKind` is marked `repr(u8)` so that the layout is
@@ -3338,6 +3346,9 @@ impl<'hir> Ty<'hir> {
33383346 ///
33393347 /// Functions accepting ambiguous types will not handle the [`TyKind::Infer`] variant, if
33403348 /// infer types are relevant to you then care should be taken to handle them separately.
3349+ ///
3350+ /// For an explanation of what it means for a type to be ambig or unambig, see the dev-guide:
3351+ /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
33413352 pub fn try_as_ambig_ty ( & self ) -> Option < & Ty < ' hir , AmbigArg > > {
33423353 if let TyKind :: Infer ( ( ) ) = self . kind {
33433354 return None ;
@@ -3640,9 +3651,12 @@ pub enum InferDelegationKind {
36403651}
36413652
36423653/// The various kinds of types recognized by the compiler.
3643- #[ derive( Debug , Clone , Copy , HashStable_Generic ) ]
3654+ ///
3655+ /// For an explanation of the `Unambig` generic parameter see the dev-guide:
3656+ /// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
36443657// SAFETY: `repr(u8)` is required so that `TyKind<()>` and `TyKind<!>` are layout compatible
36453658#[ repr( u8 , C ) ]
3659+ #[ derive( Debug , Clone , Copy , HashStable_Generic ) ]
36463660pub enum TyKind < ' hir , Unambig = ( ) > {
36473661 /// Actual type should be inherited from `DefId` signature
36483662 InferDelegation ( DefId , InferDelegationKind ) ,
0 commit comments