Skip to content

Commit

Permalink
Rollup merge of rust-lang#48971 - mark-i-m:fix_readmes, r=nikomatsakis
Browse files Browse the repository at this point in the history
Move librustc_typeck READMEs to rustc guide

cc rust-lang/rustc-dev-guide#2 and rust-lang#48478

Don't merge this before rust-lang/rustc-dev-guide#85

r? @nikomatsakis
  • Loading branch information
kennytm committed Mar 14, 2018
2 parents c144fb7 + 5a073d4 commit ff80cde
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 438 deletions.
51 changes: 4 additions & 47 deletions src/librustc_typeck/README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,5 @@
NB: This crate is part of the Rust compiler. For an overview of the
compiler as a whole, see
[the README.md file found in `librustc`](../librustc/README.md).
For high-level intro to how type checking works in rustc, see the
[type checking] chapter of the [rustc guide].

The `rustc_typeck` crate contains the source for "type collection" and
"type checking", as well as a few other bits of related functionality.
(It draws heavily on the [type inferencing][infer] and
[trait solving][traits] code found in librustc.)

[infer]: ../librustc/infer/README.md
[traits]: ../librustc/traits/README.md

## Type collection

Type "collection" is the process of converting the types found in the
HIR (`hir::Ty`), which represent the syntactic things that the user
wrote, into the **internal representation** used by the compiler
(`Ty<'tcx>`) -- we also do similar conversions for where-clauses and
other bits of the function signature.

To try and get a sense for the difference, consider this function:

```rust
struct Foo { }
fn foo(x: Foo, y: self::Foo) { .. }
// ^^^ ^^^^^^^^^
```

Those two parameters `x` and `y` each have the same type: but they
will have distinct `hir::Ty` nodes. Those nodes will have different
spans, and of course they encode the path somewhat differently. But
once they are "collected" into `Ty<'tcx>` nodes, they will be
represented by the exact same internal type.

Collection is defined as a bundle of queries (e.g., `type_of`) for
computing information about the various functions, traits, and other
items in the crate being compiled. Note that each of these queries is
concerned with *interprocedural* things -- for example, for a function
definition, collection will figure out the type and signature of the
function, but it will not visit the *body* of the function in any way,
nor examine type annotations on local variables (that's the job of
type *checking*).

For more details, see the `collect` module.

## Type checking

TODO
[type checking]: https://rust-lang-nursery.github.io/rustc-guide/type-checking.html
[rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/
111 changes: 0 additions & 111 deletions src/librustc_typeck/check/method/README.md

This file was deleted.

4 changes: 3 additions & 1 deletion src/librustc_typeck/check/method/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Method lookup: the secret sauce of Rust. See `README.md`.
//! Method lookup: the secret sauce of Rust. See the [rustc guide] chapter.
//!
//! [rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/method-lookup.html
use check::FnCtxt;
use hir::def::Def;
Expand Down
Loading

0 comments on commit ff80cde

Please sign in to comment.