Skip to content

Commit 53d81b8

Browse files
committed
Add explanatory comments for GenericArg::Infer and TyKind::Infer
1 parent bcf1fda commit 53d81b8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

compiler/rustc_hir/src/hir.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ pub enum ConstArgKind<'hir> {
290290
/// However, in the future, we'll be using it for all of those.
291291
Path(QPath<'hir>),
292292
Anon(&'hir AnonConst),
293-
/// **Note:** Not all const inference variables are represented as
293+
/// **Note:** Not all inferred consts are represented as
294294
/// `ConstArgKind::Infer`. In cases where it is ambiguous whether
295295
/// a generic arg is a type or a const, inference variables are
296296
/// represented as `GenericArg::Infer` instead.
@@ -314,6 +314,10 @@ pub enum GenericArg<'hir> {
314314
Lifetime(&'hir Lifetime),
315315
Type(&'hir Ty<'hir>),
316316
Const(&'hir ConstArg<'hir>),
317+
/// **Note:** Inference variables are only represented as
318+
/// `GenericArg::Infer` in cases where it is ambiguous whether
319+
/// a generic arg is a type or a const. Otherwise, inference variables
320+
/// are represented as `TyKind::Infer` or `ConstArgKind::Infer`.
317321
Infer(InferArg),
318322
}
319323

@@ -2844,6 +2848,11 @@ pub enum TyKind<'hir> {
28442848
Typeof(&'hir AnonConst),
28452849
/// `TyKind::Infer` means the type should be inferred instead of it having been
28462850
/// specified. This can appear anywhere in a type.
2851+
///
2852+
/// **Note:** Not all inferred types are represented as
2853+
/// `TyKind::Infer`. In cases where it is ambiguous whether
2854+
/// a generic arg is a type or a const, inference variables are
2855+
/// represented as `GenericArg::Infer` instead.
28472856
Infer,
28482857
/// Placeholder for a type that has failed to be defined.
28492858
Err(rustc_span::ErrorGuaranteed),

0 commit comments

Comments
 (0)