Skip to content

Commit 928470c

Browse files
oli-obkmark-i-m
authored andcommitted
Satisfy tidy checks
1 parent f2e7ef1 commit 928470c

File tree

3 files changed

+24
-23
lines changed

3 files changed

+24
-23
lines changed

src/hir.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# The HIR
22

3-
The HIR – "High-Level Intermediate Representation" – is the primary IR used in
4-
most of rustc. It is a compiler-friendly representation of the abstract syntax
5-
tree (AST) that is generated after parsing, macro expansion, and name
3+
The HIR – "High-Level Intermediate Representation" – is the primary IR used
4+
in most of rustc. It is a compiler-friendly representation of the abstract
5+
syntax tree (AST) that is generated after parsing, macro expansion, and name
66
resolution (see [Lowering](./lowering.md) for how the HIR is created).
77
Many parts of HIR resemble Rust surface syntax quite closely, with
8-
the exception that some of Rust's expression forms have been desugared away. For
9-
example, `for` loops are converted into a `loop` and do not appear in the HIR.
10-
This makes HIR more amenable to analysis than a normal AST.
8+
the exception that some of Rust's expression forms have been desugared away.
9+
For example, `for` loops are converted into a `loop` and do not appear in
10+
the HIR. This makes HIR more amenable to analysis than a normal AST.
1111

1212
This chapter covers the main concepts of the HIR.
1313

src/lowering.md

+12-11
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ of such structures include but are not limited to
1212
* `if let`
1313
* Converted to `match`
1414
* Universal `impl Trait`
15-
* Converted to generic arguments (but with some flags, to know that the user didn't write them)
15+
* Converted to generic arguments
16+
(but with some flags, to know that the user didn't write them)
1617
* Existential `impl Trait`
1718
* Converted to a virtual `existential type` declaration
1819

@@ -34,14 +35,14 @@ sanity checks in `src/librustc/hir/map/hir_id_validator.rs`:
3435
which produces both a new `NodeId` as well as automatically lowering it
3536
for you so you also get the `HirId`.
3637

37-
If you are creating new `DefId`s, since each `DefId` needs to have a corresponding
38-
`NodeId`, it is adviseable to add these `NodeId`s to the `AST` so you don't have
39-
to generate new ones during lowering. This has the advantage of creating a
40-
way to find the `DefId` of something via its `NodeId`. If lowering needs this
41-
`DefId` in multiple places, you can't generate a new `NodeId` in all those places
42-
because you'd also get a new `DefId` then. With a `NodeId` from the `AST` this is
43-
not an issue.
38+
If you are creating new `DefId`s, since each `DefId` needs to have a
39+
corresponding `NodeId`, it is adviseable to add these `NodeId`s to the
40+
`AST` so you don't have to generate new ones during lowering. This has
41+
the advantage of creating a way to find the `DefId` of something via its
42+
`NodeId`. If lowering needs this `DefId` in multiple places, you can't
43+
generate a new `NodeId` in all those places because you'd also get a new
44+
`DefId` then. With a `NodeId` from the `AST` this is not an issue.
4445

45-
Having the `NodeId` also allows the `DefCollector` to generate the `DefId`s instead
46-
of lowering having to do it on the fly. Centralizing the `DefId` generation in one
47-
place makes it easier to refactor and reason about.
46+
Having the `NodeId` also allows the `DefCollector` to generate the `DefId`s
47+
instead of lowering having to do it on the fly. Centralizing the `DefId`
48+
generation in one place makes it easier to refactor and reason about.

src/name-resolution.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ hierarchy, it's types vs. values vs. macros.
3636
## Scopes and ribs
3737

3838
A name is visible only in certain area in the source code. This forms a
39-
hierarchical structure, but not necessarily a simple one ‒ if one scope is part
40-
of another, it doesn't mean the name visible in the outer one is also visible in
41-
the inner one, or that it refers to the same thing.
39+
hierarchical structure, but not necessarily a simple one ‒ if one scope is
40+
part of another, it doesn't mean the name visible in the outer one is also
41+
visible in the inner one, or that it refers to the same thing.
4242

4343
To cope with that, the compiler introduces the concept of Ribs. This is
4444
abstraction of a scope. Every time the set of visible names potentially changes,
@@ -54,9 +54,9 @@ example:
5454
When searching for a name, the stack of ribs is traversed from the innermost
5555
outwards. This helps to find the closest meaning of the name (the one not
5656
shadowed by anything else). The transition to outer rib may also change the
57-
rules what names are usable ‒ if there are nested functions (not closures), the
58-
inner one can't access parameters and local bindings of the outer one, even
59-
though they should be visible by ordinary scoping rules. An example:
57+
rules what names are usable ‒ if there are nested functions (not closures),
58+
the inner one can't access parameters and local bindings of the outer one,
59+
even though they should be visible by ordinary scoping rules. An example:
6060

6161
```rust
6262
fn do_something<T: Default>(val: T) { // <- New rib in both types and values (1)

0 commit comments

Comments
 (0)