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
This is result of squashing two revert commits:
Revert "compile all crates under test w/ -Zemit-stack-sizes"
This reverts commit 7d365cf27f.
Revert "bootstrap: build compiler-builtins with -Z emit-stack-sizes"
This reverts commit 8b8488ce8f.
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
This uplifts `get_def_path` from Clippy. This is a follow up on the
implementation of internal lints: #59316
The internal lint implementation also copied the implementation of the
`AbsolutePathPrinter`. To get rid of this code duplication this also
uplifts the `get_def_path` function from Clippy.
This also renames `match_path` to `match_def_path`, as it was originally
named in Clippy.
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