Skip to content

Commit c168284

Browse files
committed
add coercions chapter and split out non hir typeck stuff
1 parent ea28b17 commit c168284

File tree

9 files changed

+302
-17
lines changed

9 files changed

+302
-17
lines changed

src/SUMMARY.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,15 @@
186186
- [Opaque types](./solve/opaque-types.md)
187187
- [Significant changes and quirks](./solve/significant-changes.md)
188188
- [`Unsize` and `CoerceUnsized` traits](./traits/unsize.md)
189-
- [Type checking](./type-checking.md)
190-
- [Method lookup](./method-lookup.md)
191-
- [Variance](./variance.md)
192-
- [Coherence checking](./coherence.md)
193-
- [Opaque types](./opaque-types-type-alias-impl-trait.md)
194-
- [Inference details](./opaque-types-impl-trait-inference.md)
195-
- [Return Position Impl Trait In Trait](./return-position-impl-trait-in-trait.md)
196-
- [Region inference restrictions][opaque-infer]
189+
- [Variance](./variance.md)
190+
- [Coherence checking](./coherence.md)
191+
- [HIR Type checking](./hir-typeck/summary.md)
192+
- [Coercions](./hir-typeck/coercions.md)
193+
- [Method lookup](./hir-typeck/method-lookup.md)
194+
- [Opaque types](./opaque-types-type-alias-impl-trait.md)
195+
- [Inference details](./opaque-types-impl-trait-inference.md)
196+
- [Return Position Impl Trait In Trait](./return-position-impl-trait-in-trait.md)
197+
- [Region inference restrictions][opaque-infer]
197198
- [Const condition checking](./effects.md)
198199
- [Pattern and exhaustiveness checking](./pat-exhaustive-checking.md)
199200
- [Unsafety checking](./unsafety-checking.md)

src/appendix/code-index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Item | Kind | Short description | Chapter |
3333
[Identifiers in the HIR]: ../hir.html#hir-id
3434
[The parser]: ../the-parser.html
3535
[The Rustc Driver and Interface]: ../rustc-driver/intro.html
36-
[Type checking]: ../type-checking.html
36+
[Type checking]: ../hir-typeck/summary.html
3737
[The `ty` modules]: ../ty.html
3838
[Rustdoc]: ../rustdoc.html
3939
[Emitting Diagnostics]: ../diagnostics.html

src/appendix/glossary.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Term | Meaning
8888
<span id="trans">trans</span> | Short for _translation_, the code to translate MIR into LLVM IR. Renamed to [codegen](#codegen).
8989
<span id="ty">`Ty`</span> | The internal representation of a type. ([see more](../ty.md))
9090
<span id="tyctxt">`TyCtxt`</span> | The data structure often referred to as [`tcx`](#tcx) in code which provides access to session data and the query system.
91-
<span id="ufcs">UFCS</span> | Short for _universal function call syntax_, this is an unambiguous syntax for calling a method. **Term no longer in use!** Prefer _fully-qualified path/syntax_. ([see more](../type-checking.md), [see the reference](https://doc.rust-lang.org/reference/expressions/call-expr.html#disambiguating-function-calls))
91+
<span id="ufcs">UFCS</span> | Short for _universal function call syntax_, this is an unambiguous syntax for calling a method. **Term no longer in use!** Prefer _fully-qualified path/syntax_. ([see more](../hir-typeck/summary.md), [see the reference](https://doc.rust-lang.org/reference/expressions/call-expr.html#disambiguating-function-calls))
9292
<span id="ut">uninhabited type</span> | A type which has _no_ values. This is not the same as a ZST, which has exactly 1 value. An example of an uninhabited type is `enum Foo {}`, which has no variants, and so, can never be created. The compiler can treat code that deals with uninhabited types as dead code, since there is no such value to be manipulated. `!` (the never type) is an uninhabited type. Uninhabited types are also called _empty types_.
9393
<span id="upvar">upvar</span> | A variable captured by a closure from outside the closure.
9494
<span id="variance">variance</span> | Determines how changes to a generic parameter affect subtyping; for example, if `T` is a subtype of `U`, then `Vec<T>` is a subtype `Vec<U>` because `Vec` is _covariant_ in its generic parameter. See [the background chapter](./background.md#variance) for a more general explanation. See the [variance chapter](../variance.md) for an explanation of how type checking handles variance.

src/hir-typeck/coercions.md

Lines changed: 284 additions & 0 deletions
Large diffs are not rendered by default.
File renamed without changes.

src/type-checking.md renamed to src/hir-typeck/summary.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Type checking
1+
# HIR Type checking
22

33
The [`hir_analysis`] crate contains the source for "type collection" as well
44
as a bunch of related functionality.
@@ -7,8 +7,8 @@ These crates draw heavily on the [type inference] and [trait solving].
77

88
[`hir_analysis`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_analysis/index.html
99
[`hir_typeck`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_typeck/index.html
10-
[type inference]: ./type-inference.md
11-
[trait solving]: ./traits/resolution.md
10+
[type inference]: ./../type-inference.md
11+
[trait solving]: ./../traits/resolution.md
1212

1313
## Type collection
1414

@@ -40,7 +40,7 @@ type *checking*).
4040

4141
For more details, see the [`collect`][collect] module.
4242

43-
[queries]: ./query.md
43+
[queries]: ../query.md
4444
[collect]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_analysis/collect/index.html
4545

4646
**TODO**: actually talk about type checking... [#1161](https://github.com/rust-lang/rustc-dev-guide/issues/1161)

src/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ with additional low-level types and annotations added (e.g. an ELF object or
130130
the final binary.
131131

132132
[*trait solving*]: traits/resolution.md
133-
[*type checking*]: type-checking.md
133+
[*type checking*]: hir-typeck/summary.md
134134
[*type inference*]: type-inference.md
135135
[`bump`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/parser/struct.Parser.html#method.bump
136136
[`check`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/parser/struct.Parser.html#method.check

src/thir.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The THIR ("Typed High-Level Intermediate Representation"), previously called HAI
55
[type checking]. It is (as of <!-- date-check --> January 2024) used for
66
[MIR construction], [exhaustiveness checking], and [unsafety checking].
77

8-
[type checking]: ./type-checking.md
8+
[type checking]: ./hir-typeck/summary.md
99
[MIR construction]: ./mir/construction.md
1010
[exhaustiveness checking]: ./pat-exhaustive-checking.md
1111
[unsafety checking]: ./unsafety-checking.md

src/traits/canonical-queries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ As a result of this assignment, the type of `u` is forced to be
214214
`Option<Vec<?V>>`, where `?V` represents the element type of the
215215
vector. This in turn implies that `?U` is [unified] to `Vec<?V>`.
216216

217-
[unified]: ../type-checking.html
217+
[unified]: ../hir-typeck/summary.md
218218

219219
Let's suppose that the type checker decides to revisit the
220220
"as-yet-unproven" trait obligation we saw before, `Vec<?T>:

0 commit comments

Comments
 (0)