This PR allows the constant evaluation of index operations on constant arrays and repeat expressions. This allows index expressions to appear in the expression path of the length expression of a repeat expression or an array type.
An example is
```rust
const ARR: [usize; 5] = [1, 2, 3, 4, 5];
const ARR2: [usize; ARR[1]] = [42, 99];
```
In most other locations llvm's const evaluator figures it out already. This is not specific to index expressions and could be remedied in the future.
* `const`: Add reference to raw pointers
* Change `expr!(...)` etc. examples to use `ident` instead.
*Technically*, it should be `pat`, but that's not how it works in
practice.
* `|`: add reference to closure syntax.
* Closure syntax entry.
* Indexing and slicing entries.
* Add history of obsolete and deprecated syntax.
r? @steveklabnik
This PR adds some safety checks to interning things in `ty::ctxt`. Accidentally re-interning an `AdtDef` has bitten me in the behind just last week (it messes up things in very subtle way only showing up later as an LLVM assertion).
Initially I had also added a check to `ty::ctxt::node_type_insert()` -- but there it seems to be expected that the same table slot is written to multiple times.
Roll-up candidate.
* `const`: Add reference to raw pointers
* Change `expr!(...)` etc. examples to use `ident` instead.
*Technically*, it should be `pat`, but that's not how it works in
practice.
* `|`: add reference to closure syntax.
* Closure syntax entry.
* Indexing and slicing entries.
I believe that because Windows' unit of resolution is 100ns that this unit of
time will ensure that the assertions will hold true as it's representable in the
native format.
cc #29970
In #29932, I moved the location of TRPL, but I missed making the changes
in mk/tests.mk. This led to #30088 landing with a broken example.
As such, #30113 will need to land before this.
The `f` argument will reference the actual value in the `d` box, not the box in the `bar`'s stack frame.
I am just learning Rust, so I don't know how to explain this well, but just from `f`'s type it is clear that it will be a pointer to an `i32`, not a pointer to a pointer. Some `println!("{:p}", ...)`'s can easily confirm this.
I would actually suggest to remove/simplify this part of the example. This is a subtle issue that can easily confuse people at the early stages of familiarizing with the language. (As I got confused by it. :))
Fixes#30073. The input to `cfg!` is a meta attribute, but not _any_ meta attribute (e.g. `cfg!(allow(dead_code))` doesn't compile). But the macro_rules syntax can't quite express this, so I added a note to the doc.
In #29932, I moved the location of TRPL, but I missed making the changes
in mk/tests.mk. This led to #30088 landing with a broken example.
As such, #30113 will need to land before this.
I believe that because Windows' unit of resolution is 100ns that this unit of
time will ensure that the assertions will hold true as it's representable in the
native format.
cc #29970