@@ -407,10 +407,8 @@ impl<'hir> PathSegment<'hir> {
407
407
/// that are [just paths](ConstArgKind::Path) (currently just bare const params)
408
408
/// versus const args that are literals or have arbitrary computations (e.g., `{ 1 + 3 }`).
409
409
///
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
414
412
#[ derive( Clone , Copy , Debug , HashStable_Generic ) ]
415
413
#[ repr( C ) ]
416
414
pub struct ConstArg < ' hir , Unambig = ( ) > {
@@ -429,6 +427,9 @@ impl<'hir> ConstArg<'hir, AmbigArg> {
429
427
/// In practice this may mean overriding the [`Visitor::visit_infer`][visit_infer] method on hir visitors, or
430
428
/// specifically matching on [`GenericArg::Infer`] when handling generic arguments.
431
429
///
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
+ ///
432
433
/// [visit_infer]: [rustc_hir::intravisit::Visitor::visit_infer]
433
434
pub fn as_unambig_ct ( & self ) -> & ConstArg < ' hir > {
434
435
// SAFETY: `ConstArg` is `repr(C)` and `ConstArgKind` is marked `repr(u8)` so that the
@@ -444,6 +445,9 @@ impl<'hir> ConstArg<'hir> {
444
445
///
445
446
/// Functions accepting ambiguous consts will not handle the [`ConstArgKind::Infer`] variant, if
446
447
/// 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
447
451
pub fn try_as_ambig_ct ( & self ) -> Option < & ConstArg < ' hir , AmbigArg > > {
448
452
if let ConstArgKind :: Infer ( _, ( ) ) = self . kind {
449
453
return None ;
@@ -475,6 +479,9 @@ impl<'hir, Unambig> ConstArg<'hir, Unambig> {
475
479
}
476
480
477
481
/// 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
478
485
#[ derive( Clone , Copy , Debug , HashStable_Generic ) ]
479
486
#[ repr( u8 , C ) ]
480
487
pub enum ConstArgKind < ' hir , Unambig = ( ) > {
@@ -3302,10 +3309,8 @@ pub enum AmbigArg {}
3302
3309
#[ repr( C ) ]
3303
3310
/// Represents a type in the `HIR`.
3304
3311
///
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
3309
3314
pub struct Ty < ' hir , Unambig = ( ) > {
3310
3315
#[ stable_hasher( ignore) ]
3311
3316
pub hir_id : HirId ,
@@ -3323,6 +3328,9 @@ impl<'hir> Ty<'hir, AmbigArg> {
3323
3328
/// In practice this may mean overriding the [`Visitor::visit_infer`][visit_infer] method on hir visitors, or
3324
3329
/// specifically matching on [`GenericArg::Infer`] when handling generic arguments.
3325
3330
///
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
+ ///
3326
3334
/// [visit_infer]: [rustc_hir::intravisit::Visitor::visit_infer]
3327
3335
pub fn as_unambig_ty ( & self ) -> & Ty < ' hir > {
3328
3336
// SAFETY: `Ty` is `repr(C)` and `TyKind` is marked `repr(u8)` so that the layout is
@@ -3338,6 +3346,9 @@ impl<'hir> Ty<'hir> {
3338
3346
///
3339
3347
/// Functions accepting ambiguous types will not handle the [`TyKind::Infer`] variant, if
3340
3348
/// 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
3341
3352
pub fn try_as_ambig_ty ( & self ) -> Option < & Ty < ' hir , AmbigArg > > {
3342
3353
if let TyKind :: Infer ( ( ) ) = self . kind {
3343
3354
return None ;
@@ -3640,9 +3651,12 @@ pub enum InferDelegationKind {
3640
3651
}
3641
3652
3642
3653
/// 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
3644
3657
// SAFETY: `repr(u8)` is required so that `TyKind<()>` and `TyKind<!>` are layout compatible
3645
3658
#[ repr( u8 , C ) ]
3659
+ #[ derive( Debug , Clone , Copy , HashStable_Generic ) ]
3646
3660
pub enum TyKind < ' hir , Unambig = ( ) > {
3647
3661
/// Actual type should be inherited from `DefId` signature
3648
3662
InferDelegation ( DefId , InferDelegationKind ) ,
0 commit comments