Use normal newtype_index macro for MIR dataflows
* Makes the definition of these structs contain `struct IndexName`
* Avoids having an offset by removing high values, rather than 0
* Implements some traits for us.
Use measureme in self profiler
r? @michaelwoerister
~Changes are still very rough.~
~I'm not sure what the right way to add the `measureme` dependency is. Currently it's just added with a relative path which Works On My Machine ™️.~
I'm also not sure what to do with the category data.
Rollup of 8 pull requests
Successful merges:
- #59781 (Remove check_match from const_eval)
- #59820 (proc_macro: stop using LEB128 for RPC.)
- #59846 (clarify what the item is in "not a module" error)
- #59847 (Error when using `catch` after `try`)
- #59859 (Suggest removing `?` to resolve type errors.)
- #59862 (Tweak unstable diagnostic output)
- #59866 (Recover from missing semicolon based on the found token)
- #59892 (Impl RawFd conversion traits for WASI TcpListener, TcpStream and UdpSocket)
Failed merges:
r? @ghost
Recover from missing semicolon based on the found token
When encountering one of a few keywords when a semicolon was
expected, suggest the semicolon and recover:
```
error: expected one of `.`, `;`, `?`, or an operator, found `let`
--> $DIR/recover-missing-semi.rs:4:5
|
LL | let _: usize = ()
| - help: missing semicolon here
LL |
LL | let _ = 3;
| ^^^
error[E0308]: mismatched types
--> $DIR/recover-missing-semi.rs:2:20
|
LL | let _: usize = ()
| ^^ expected usize, found ()
|
= note: expected type `usize`
found type `()`
```
clarify what the item is in "not a module" error
The motivation here was that I was trying to import an associated constant when I thought it was an enum variant, and got confused by this error.
Ideally I would like to add a note saying that associated constants, types, and methods cannot be imported, but I'm not sure that the associated items for a `Def` can be checked at resolve time.
Remove check_match from const_eval
This fixes#59378.
It seems that the `check_match` may be unnecessary, so this removes it per instructions provided in the issue. I re-ran the tests for `librustc_mir` and everything seemed fine!
Add discr_index to multi-variant layouts
We remove the assumption that the discriminant is always field 0, in
preparations for layouts like generators where this is not (always) going to be
the case.
Specifically, upvars are going to go before the discriminant. In theory, it's possible to remove _that_ assumption instead and keep the discriminant at field index 0, but one assumption or the other had to go :)
There is one place I know of in the debuginfo code where we'll still need to remove assumptions that the discriminant is the _only_ field. I was planning on doing this along with the upcoming generator change, which will also include tests that exercise the code changing in this PR.
r? @eddyb
cc @oli-obk
cc @cramertj
save-analysis: Pull associated type definition using `qpath_def`
Closes https://github.com/rust-lang/rls/issues/1390
This (probably?) fixes the case where we run the save-analysis code on the following snippet:
```rust
trait Test<'a> {
type Thing: Test2;
}
trait Test2 {
fn print();
}
#[allow(unused)]
fn example<T>(t: T)
where T: for<'a> Test<'a>
{
T::Thing::print(); //~ ERROR cannot extract an associated type from a higher-ranked trait bound in this context
// ^ only errors in save-analysis mode
}
```
The chain is as follows:
- culprit is `hir_ty_to_ty`
- which calls `ast_ty_to_ty` in the `ItemCtxt`
- which calls `associated_path_to_ty`
- which finally fails on `projected_ty_from_poly_trait_ref`
3de0106789/src/librustc_typeck/collect.rs (L212-L224)
I'm not exactly sure why `hir_ty_to_ty` fails - is it because it needs more setup from typeck to work correctly? I'm guessing the fix is okay since we just pull the already typeck'd data (we run save-analysis after all the analysis passes are complete) from the tables.
With this change we can 'go to def' on all segments in the `T::Thing::print()` path.
Remove strange formatting in `Ordering` docs.
I can't really fathom what the intent of the brackets is. The [original PR](#12956) doesn't give any hints. I think it seems fine without them.
Kill dead code dominator code.
Hi,
Whilst fiddling around in the dominator code, I found some (I think) unused code. This code *was* used at the time it was imported, but over time it seems to have become redundant.
I've tested a build up to stage 1 with no problems. Maybe the tests will turn up something though.
P.S.
There is a FIXME comment in `dominators/mod.rs`:
```
pub fn is_dominated_by(&self, node: Node, dom: Node) -> bool {
// FIXME -- could be optimized by using post-order-rank
self.dominators(node).any(|n| n == dom)
}
```
I'm not sure of the intention of this comment. The `Dominators` struct already operates over post-order rank nodes. Any ideas?
compiletest: Improve no_prefer_dynamic docs
This adds some extra docs for the `no-prefer-dynamic` header.
And also a `s/must_compile_successfully/compile_pass`.
`must_compile_successfully` has been renamed to `compile_pass` at some
point in the past and this comment was still referring to the old name.
Document the -Z flag to the rustc book
# Description
Changes:
- Added new documentation on the `-Z` flag of rustc in the command-line arguments section of the rustc book.
If I need to rephrase anything or if you have any improvements, please let me know! I deliberately did not create an exhaustive list of all options since they are likely to change over time and per toolchain version.
closes#41142
musl: do not compress debug section
This should be beta nominated.
Fixes https://github.com/rust-lang/rust/issues/59411 (this time for real).
Test with `DEPLOY=1 ./src/ci/docker/run.sh dist-x86_64-musl`, without `DEPLOY=1` libs are built without debuginfo.
r? @alexcrichton