Skip to content

Commit fa5895e

Browse files
committed
Reviews
1 parent 2411fba commit fa5895e

File tree

2 files changed

+6
-41
lines changed

2 files changed

+6
-41
lines changed

compiler/rustc_hir/src/hir.rs

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ impl<'hir> PathSegment<'hir> {
408408
/// versus const args that are literals or have arbitrary computations (e.g., `{ 1 + 3 }`).
409409
///
410410
/// 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
411+
/// <https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html>
412412
#[derive(Clone, Copy, Debug, HashStable_Generic)]
413413
#[repr(C)]
414414
pub struct ConstArg<'hir, Unambig = ()> {
@@ -420,16 +420,13 @@ pub struct ConstArg<'hir, Unambig = ()> {
420420
impl<'hir> ConstArg<'hir, AmbigArg> {
421421
/// Converts a `ConstArg` in an ambiguous position to one in an unambiguous position.
422422
///
423-
/// Functions accepting an unambiguous consts may expect the [`ConstArgKind::Infer`] variant
423+
/// Functions accepting unambiguous consts may expect the [`ConstArgKind::Infer`] variant
424424
/// to be used. Care should be taken to separately handle infer consts when calling this
425425
/// function as it cannot be handled by downstream code making use of the returned const.
426426
///
427427
/// In practice this may mean overriding the [`Visitor::visit_infer`][visit_infer] method on hir visitors, or
428428
/// specifically matching on [`GenericArg::Infer`] when handling generic arguments.
429429
///
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-
///
433430
/// [visit_infer]: [rustc_hir::intravisit::Visitor::visit_infer]
434431
pub fn as_unambig_ct(&self) -> &ConstArg<'hir> {
435432
// SAFETY: `ConstArg` is `repr(C)` and `ConstArgKind` is marked `repr(u8)` so that the
@@ -445,9 +442,6 @@ impl<'hir> ConstArg<'hir> {
445442
///
446443
/// Functions accepting ambiguous consts will not handle the [`ConstArgKind::Infer`] variant, if
447444
/// 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
451445
pub fn try_as_ambig_ct(&self) -> Option<&ConstArg<'hir, AmbigArg>> {
452446
if let ConstArgKind::Infer(_, ()) = self.kind {
453447
return None;
@@ -479,9 +473,6 @@ impl<'hir, Unambig> ConstArg<'hir, Unambig> {
479473
}
480474

481475
/// 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
485476
#[derive(Clone, Copy, Debug, HashStable_Generic)]
486477
#[repr(u8, C)]
487478
pub enum ConstArgKind<'hir, Unambig = ()> {
@@ -3305,12 +3296,12 @@ impl<'hir> AssocItemConstraintKind<'hir> {
33053296
#[derive(Debug, Clone, Copy, HashStable_Generic)]
33063297
pub enum AmbigArg {}
33073298

3308-
#[derive(Debug, Clone, Copy, HashStable_Generic)]
3309-
#[repr(C)]
33103299
/// Represents a type in the `HIR`.
33113300
///
33123301
/// 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
3302+
/// <https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html>
3303+
#[derive(Debug, Clone, Copy, HashStable_Generic)]
3304+
#[repr(C)]
33143305
pub struct Ty<'hir, Unambig = ()> {
33153306
#[stable_hasher(ignore)]
33163307
pub hir_id: HirId,
@@ -3328,9 +3319,6 @@ impl<'hir> Ty<'hir, AmbigArg> {
33283319
/// In practice this may mean overriding the [`Visitor::visit_infer`][visit_infer] method on hir visitors, or
33293320
/// specifically matching on [`GenericArg::Infer`] when handling generic arguments.
33303321
///
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-
///
33343322
/// [visit_infer]: [rustc_hir::intravisit::Visitor::visit_infer]
33353323
pub fn as_unambig_ty(&self) -> &Ty<'hir> {
33363324
// SAFETY: `Ty` is `repr(C)` and `TyKind` is marked `repr(u8)` so that the layout is
@@ -3346,9 +3334,6 @@ impl<'hir> Ty<'hir> {
33463334
///
33473335
/// Functions accepting ambiguous types will not handle the [`TyKind::Infer`] variant, if
33483336
/// 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
33523337
pub fn try_as_ambig_ty(&self) -> Option<&Ty<'hir, AmbigArg>> {
33533338
if let TyKind::Infer(()) = self.kind {
33543339
return None;
@@ -3653,7 +3638,7 @@ pub enum InferDelegationKind {
36533638
/// The various kinds of types recognized by the compiler.
36543639
///
36553640
/// 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
3641+
/// <https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html>
36573642
// SAFETY: `repr(u8)` is required so that `TyKind<()>` and `TyKind<!>` are layout compatible
36583643
#[repr(u8, C)]
36593644
#[derive(Debug, Clone, Copy, HashStable_Generic)]

compiler/rustc_hir/src/intravisit.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,6 @@ pub trait Visitor<'v>: Sized {
364364
/// All types are treated as ambiguous types for the purposes of hir visiting in
365365
/// order to ensure that visitors can handle infer vars without it being too error-prone.
366366
///
367-
/// For an explanation of what it means for a type to be ambig, see the dev-guide:
368-
/// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
369-
///
370367
/// The [`Visitor::visit_infer`] method should be overridden in order to handle infer vars.
371368
fn visit_ty(&mut self, t: &'v Ty<'v, AmbigArg>) -> Self::Result {
372369
walk_ty(self, t)
@@ -375,9 +372,6 @@ pub trait Visitor<'v>: Sized {
375372
/// All consts are treated as ambiguous consts for the purposes of hir visiting in
376373
/// order to ensure that visitors can handle infer vars without it being too error-prone.
377374
///
378-
/// For an explanation of what it means for a const arg to be ambig, see the dev-guide:
379-
/// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
380-
///
381375
/// The [`Visitor::visit_infer`] method should be overridden in order to handle infer vars.
382376
fn visit_const_arg(&mut self, c: &'v ConstArg<'v, AmbigArg>) -> Self::Result {
383377
walk_const_arg(self, c)
@@ -516,9 +510,6 @@ pub trait VisitorExt<'v>: Visitor<'v> {
516510
///
517511
/// Named `visit_ty_unambig` instead of `visit_unambig_ty` to aid in discovery
518512
/// by IDes when `v.visit_ty` is written.
519-
///
520-
/// For an explanation of what it means for a type to be unambig, see the dev-guide:
521-
/// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
522513
fn visit_ty_unambig(&mut self, t: &'v Ty<'v>) -> Self::Result {
523514
walk_unambig_ty(self, t)
524515
}
@@ -527,9 +518,6 @@ pub trait VisitorExt<'v>: Visitor<'v> {
527518
///
528519
/// Named `visit_const_arg_unambig` instead of `visit_unambig_const_arg` to aid in
529520
/// discovery by IDes when `v.visit_const_arg` is written.
530-
///
531-
/// For an explanation of what it means for a const arg to be unambig, see the dev-guide:
532-
/// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
533521
fn visit_const_arg_unambig(&mut self, c: &'v ConstArg<'v>) -> Self::Result {
534522
walk_unambig_const_arg(self, c)
535523
}
@@ -981,8 +969,6 @@ pub fn walk_generic_arg<'v, V: Visitor<'v>>(
981969
}
982970
}
983971

984-
/// For an explanation of what it means for a type to be unambig, see the dev-guide:
985-
/// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
986972
pub fn walk_unambig_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v>) -> V::Result {
987973
match typ.try_as_ambig_ty() {
988974
Some(ambig_ty) => visitor.visit_ty(ambig_ty),
@@ -993,8 +979,6 @@ pub fn walk_unambig_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v>) ->
993979
}
994980
}
995981

996-
/// For an explanation of what it means for a type to be ambig, see the dev-guide:
997-
/// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
998982
pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v, AmbigArg>) -> V::Result {
999983
let Ty { hir_id, span: _, kind } = typ;
1000984
try_visit!(visitor.visit_id(*hir_id));
@@ -1047,8 +1031,6 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v, AmbigArg>) -
10471031
V::Result::output()
10481032
}
10491033

1050-
/// For an explanation of what it means for a const arg to be unambig, see the dev-guide:
1051-
/// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
10521034
pub fn walk_unambig_const_arg<'v, V: Visitor<'v>>(
10531035
visitor: &mut V,
10541036
const_arg: &'v ConstArg<'v>,
@@ -1062,8 +1044,6 @@ pub fn walk_unambig_const_arg<'v, V: Visitor<'v>>(
10621044
}
10631045
}
10641046

1065-
/// For an explanation of what it means for a const arg to be ambig, see the dev-guide:
1066-
/// https://rustc-dev-guide.rust-lang.org/hir/ambig-unambig-ty-and-consts.html
10671047
pub fn walk_const_arg<'v, V: Visitor<'v>>(
10681048
visitor: &mut V,
10691049
const_arg: &'v ConstArg<'v, AmbigArg>,

0 commit comments

Comments
 (0)