-
Notifications
You must be signed in to change notification settings - Fork 550
Document Ambig vs Unambig Type/Consts #2474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Thanks for the PR. If you have write access, feel free to merge this PR if it does not need reviews. You can request a review using |
3972cf8
to
c963b4a
Compare
parse. | ||
|
||
```rust | ||
fn func<T, const N: usize,>(arg: T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn func<T, const N: usize,>(arg: T) { | |
fn func<T, const N: usize>(arg: T) { |
|
||
1. We have different types in the compiler for when a type or const is in an unambig or ambig position, `hir::Ty<AmbigArg>` and `hir::Ty<()>`. [`AmbigArg`][ambig_arg] is an uninhabited type which we use in the `Infer` variant of `TyKind` and `ConstArgKind` to selectively "disable" it if we are in an ambig position. | ||
|
||
2. The [`visit_ty`][visit_infer] and [`visit_const_arg`][visit_const_arg] methods on HIR visitors only accept the ambig position versions of types/consts. Unambig types/consts are implicitly converted to ambig types/consts during the visiting process, with the `Infer` variant handled by a dedicated [`visit_infer`][visit_infer] method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The visit_infer
link doesn't match the visit_ty
text.
- In unambig const arg position as a `hir::ConstArgKind::Infer` | ||
- In an ambig position as a [`GenericArg::Type(TyKind::Infer)`][generic_arg_ty] | ||
- In an ambig position as a [`GenericArg::Const(ConstArgKind::Infer)`][generic_arg_const] | ||
- In an ambig position as a [`GenericArg::Infer`][generic_arg_infer] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe clarify here that points 3 and 4 are the cases where there was enough other information around to disambiguate into either a type or a const?
No description provided.