Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ffa246b

Browse files
fmeaseoli-obk
authored andcommittedMar 23, 2024
Rename AstConv to HIR ty lowering
1 parent 8f6a4f6 commit ffa246b

7 files changed

+29
-26
lines changed
 

‎src/SUMMARY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
- [Feature Gate Checking](./feature-gate-ck.md)
9898
- [Lang Items](./lang-items.md)
9999
- [The HIR (High-level IR)](./hir.md)
100-
- [Lowering AST to HIR](./lowering.md)
100+
- [Lowering AST to HIR](./ast-lowering.md)
101101
- [Debugging](./hir-debugging.md)
102102
- [The THIR (Typed High-level IR)](./thir.md)
103103
- [The MIR (Mid-level IR)](./mir/index.md)

‎src/lowering.md ‎src/ast-lowering.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Lowering
1+
# AST lowering
22

3-
The lowering step converts AST to [HIR](hir.html).
3+
The AST lowering step converts AST to [HIR](hir.html).
44
This means many structures are removed if they are irrelevant
55
for type analysis or similar syntax agnostic analyses. Examples
66
of such structures include but are not limited to

‎src/diagnostics.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ are:
519519
macros.
520520

521521
- Early lint pass: Works on [AST nodes] after [macro expansion] and name
522-
resolution, just before [HIR lowering]. These lints are for purely
522+
resolution, just before [AST lowering]. These lints are for purely
523523
syntactical lints.
524524
- Example: The [`unused_parens`] lint checks for parenthesized-expressions
525525
in situations where they are not needed, like an `if` condition.
@@ -550,7 +550,7 @@ compiler](#linting-early-in-the-compiler).
550550

551551

552552
[AST nodes]: the-parser.md
553-
[HIR lowering]: lowering.md
553+
[AST lowering]: ast-lowering.md
554554
[HIR nodes]: hir.md
555555
[MIR nodes]: mir/index.md
556556
[macro expansion]: macro-expansion.md

‎src/overview.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ returned from the parser while the standard [`Diag`] API is used
8383
for error handling. Generally Rust's compiler will try to recover from errors
8484
by parsing a superset of Rust's grammar, while also emitting an error type.
8585

86-
### `HIR` lowering
86+
### `AST` lowering
8787

8888
Next the `AST` is converted into [High-Level Intermediate Representation
8989
(`HIR`)][hir], a more compiler-friendly representation of the `AST`. This process
@@ -410,7 +410,7 @@ For more details on bootstrapping, see
410410
- Guide: [The HIR](hir.md)
411411
- Guide: [Identifiers in the HIR](hir.md#identifiers-in-the-hir)
412412
- Guide: [The `HIR` Map](hir.md#the-hir-map)
413-
- Guide: [Lowering `AST` to HIR](lowering.md)
413+
- Guide: [Lowering `AST` to `HIR`](ast-lowering.md)
414414
- How to view `HIR` representation for your code `cargo rustc -- -Z unpretty=hir-tree`
415415
- Rustc `HIR` definition: [`rustc_hir`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/index.html)
416416
- Main entry point: **TODO**

‎src/return-position-impl-trait-in-trait.md

+13-10
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,21 @@ by T-lang.
1313

1414
## How does it work?
1515

16-
This doc is ordered mostly via the compilation pipeline. AST -> HIR ->
17-
astconv -> typeck.
16+
This doc is ordered mostly via the compilation pipeline:
1817

19-
### AST and HIR
18+
1. AST lowering (AST -> HIR)
19+
2. HIR ty lowering (HIR -> rustc_middle::ty data types)
20+
3. typeck
2021

21-
AST -> HIR lowering for RPITITs is almost the same as lowering RPITs. We
22+
### AST lowering
23+
24+
AST lowering for RPITITs is almost the same as lowering RPITs. We
2225
still lower them as
2326
[`hir::ItemKind::OpaqueTy`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/struct.OpaqueTy.html).
2427
The two differences are that:
2528

2629
We record `in_trait` for the opaque. This will signify that the opaque
27-
is an RPITIT for astconv, diagnostics that deal with HIR, etc.
30+
is an RPITIT for HIR ty lowering, diagnostics that deal with HIR, etc.
2831

2932
We record `lifetime_mapping`s for the opaque type, described below.
3033

@@ -49,7 +52,7 @@ bounds that enforce equality between these duplicated lifetimes and
4952
their source lifetimes in order to properly typecheck these GATs, which
5053
will be discussed below.
5154

52-
##### note:
55+
##### Note
5356

5457
It may be better if we were able to lower without duplicates and for
5558
that I think we would need to stop distinguishing between early and late
@@ -59,14 +62,14 @@ late-bound lifetimes in generics
5962
PR similar to [Inherit function lifetimes for impl-trait
6063
#103449](https://github.com/rust-lang/rust/pull/103449).
6164

62-
### Astconv
65+
### HIR ty lowering
6366

64-
The main change to astconv is that we lower `hir::TyKind::OpaqueDef` for
65-
an RPITIT to a projection instead of an opaque, using a newly
67+
The main change to HIR ty lowering is that we lower `hir::TyKind::OpaqueDef`
68+
for an RPITIT to a projection instead of an opaque, using a newly
6669
synthesized def-id for a new associated type in the trait. We'll
6770
describe how exactly we get this def-id in the next section.
6871

69-
This means that any time we call `ast_ty_to_ty` on the RPITIT, we end up
72+
This means that any time we call `lower_ty` on the RPITIT, we end up
7073
getting a projection back instead of an opaque. This projection can then
7174
be normalized to the right value -- either the original opaque if we're
7275
in the trait, or the inferred type of the RPITIT if we're in an impl.

‎src/turbofishing-and-early-late-bound.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ fn main() {
113113
accepts_fn(f);
114114
}
115115
```
116-
Maybe we can just special case astconv for `_`/`'_` arguments for late bound parameters somehow
117-
and have it not mean the same thing as `_` for early bound parameters. Regardless I think we
118-
would need a solution that would allow writing the above code even if it was done by some new
119-
syntax such as havign to write `late::<k#no_argument, 'static>` (naturally `k#no_argument`
120-
would only make sense as an argument to late bound parameters).
116+
Maybe we can just special case HIR ty lowering for `_`/`'_` arguments for late bound
117+
parameters somehow and have it not mean the same thing as `_` for early bound parameters.
118+
Regardless I think we would need a solution that would allow writing the above code even
119+
if it was done by some new syntax such as having to write `late::<k#no_argument, 'static>`
120+
(naturally `k#no_argument` would only make sense as an argument to late bound parameters).

‎src/ty.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ HIR is built directly from the AST, so it happens before any `ty::Ty` is produce
7373
HIR is built, some basic type inference and type checking is done. During the type inference, we
7474
figure out what the `ty::Ty` of everything is and we also check if the type of something is
7575
ambiguous. The `ty::Ty` is then used for type checking while making sure everything has the
76-
expected type. The [`astconv` module][astconv] is where the code responsible for converting a
77-
`rustc_hir::Ty` into a `ty::Ty` is located. The main routine used is `ast_ty_to_ty`. This occurs
78-
during the type-checking phase, but also in other parts of the compiler that want to ask
76+
expected type. The [`hir_ty_lowering` module][hir_ty_lowering] is where the code responsible for
77+
lowering a `rustc_hir::Ty` to a `ty::Ty` is located. The main routine used is `lower_ty`.
78+
This occurs during the type-checking phase, but also in other parts of the compiler that want to ask
7979
questions like "what argument types does this function expect?"
8080

81-
[astconv]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_analysis/astconv/index.html
81+
[hir_ty_lowering]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_analysis/hir_ty_lowering/index.html
8282

8383
**How semantics drive the two instances of `Ty`**
8484

0 commit comments

Comments
 (0)
Please sign in to comment.