Avoid spurious "previous iteration of loop" errors
Only follow backwards edges during `get_moved_indexes` if the move path is definitely initialized at loop entry. Otherwise, the error occurred prior to the loop, so we ignore the backwards edges to avoid generating misleading "value moved here, in previous iteration of loop" errors.
This patch also slightly improves the analysis of inits, including `NonPanicPathOnly` initializations (which are ignored by `drop_flag_effects::for_location_inits`). This is required for the definite initialization analysis, but may also help find certain skipped reinits in rare cases.
Patch passes all non-ignored src/test/ui testcases.
Fixes#72649.
Constify ?-operator for Result and Option
Try to make `?`-operator usable in `const fn` with `Result` and `Option`, see #74935 . Note that the try-operator itself was constified in #87237.
TODO
* [x] Add tests for const T -> T conversions
* [x] cleanup commits
* [x] Remove `#![allow(incomplete_features)]`
* [?] Await decision in #86808 - I'm not sure
* [x] Await support for parsing `~const` in bootstrapping compiler
* [x] Tracking issue(s)? - #88674
Don't anonymize bound region names during typeck
Once this anonymization has performed, we have no
way of recovering the original names during NLL
borrow checking. Keeping the original names allows
error messages in full NLL mode to contain the original
bound region names.
As a result, the typeck results may contain types that
differ only in the names used for their bound regions. However,
anonimization of bound regions does not guarantee that
all distinct types are unqual (e.g. not subtypes of each other).
For example, `for<'a> fn(&'a u32, &'a u32)` and
`for<'b, 'c> fn(&'b u32, &'c u32)` are subtypes of each other,
as explained here:
63cc2bb3d0/compiler/rustc_infer/src/infer/nll_relate/mod.rs (L682-L690)
Therefore, any code handling types with higher-ranked regions already
needs to handle the case where two distinct `Ty`s are 'actually'
equal.
Update cargo
5 commits in 0121d66aa2ef5ffa9735f86c2b56f5fdc5a837a6..d56b42c549dbb7e7d0f712c51b39400260d114d4
2021-09-22 16:08:27 +0000 to 2021-09-27 13:44:18 +0000
- Allow `cargo update --precise` with metadata. (rust-lang/cargo#9945)
- Support path_in_vcs as part of cargo_vcs_metadata (rust-lang/cargo#9866)
- Doc about InstallTracker files and `install.root` (rust-lang/cargo#9948)
- Add some clarity on the license/license-file warning. (rust-lang/cargo#9941)
- Fix the problem that help cannot be displayed properly (rust-lang/cargo#9933)
rustdoc: Remove lazy_static dependency
The macro was used in only one place and there are equivalents in the std, so it seemed weird to keep it around...
I think running a perf check would be a good idea though, just in case.
r? ``@jyn514``
PassWrapper: handle function rename from upstream D36850
thinLTOResolvePrevailingInModule became thinLTOFinalizeInModule and
gained the ability to propagate noRecurse and noUnwind function
attributes. I ran codegen tests with it both on and off, as the upstream
patch uses it in both modes, and the tests pass both ways. Given that,
it seemed reasonable to go ahead and let the propagation be enabled in
rustc, and see what happens. See https://reviews.llvm.org/D36850 for
more examples of how the new version of the function gets used.
r? ``@nikic`` cc ``@nagisa``
Improve help for recursion limit errors
- Tweak help message and suggested limit (handle `0` case).
- Add test for #75602 (it was already fixed, maybe can be resolved too).
Fixes#76424
Fix generics where bounds order
Fixes#88809.
Like said on the above issue, the issue is that we were expecting `Symbol` comparisons to be string-based but they are integer-based (because `Symbol` is an integer), messing up the bounds order. To fix it, I simply stored into a `FxIndexMap` instead.
r? ``@jyn514``
Remove ignore-tidy-undocumented-unsafe from core::slice::sort
Write down the missing safety arguments to be able to remove `ignore-tidy-undocumented-unsafe` from `core::slice::sort`.
Helps with #66219
``@rustbot`` label C-cleanup T-libs
Fix union keyword highlighting in rustdoc HTML sources
I followed this logic: if I find an ident "union", I check if it followed by another ident or not. If it's the case, then I consider this is a keyword because it's declaring a union type.
To do so I created a new Iterator which allows to peek the next items without moving the current iterator position.
This is part of https://github.com/rust-lang/rust/issues/85016. If the fix makes sense, I'll extend it to other weak keywords (the issue only mentions they exist but https://doc.rust-lang.org/nightly/reference/keywords.html#weak-keywords only talks about `dyn` and `'static` so not sure if there is anything else to be done?).
cc `@notriddle` (you're one of the last ones who worked on this part of rustdoc so here you go 😉 )
r? `@jyn514`
Use larger span for adjustment THIR expressions
Currently, we use a relatively 'small' span for THIR
expressions generated by an 'adjustment' (e.g. an autoderef,
autoborrow, unsizing). As a result, if a borrow generated
by an adustment ends up causing a borrowcheck error, for example:
```rust
let mut my_var = String::new();
let my_ref = &my_var
my_var.push('a');
my_ref;
```
then the span for the mutable borrow may end up referring
to only the base expression (e.g. `my_var`), rather than
the method call which triggered the mutable borrow
(e.g. `my_var.push('a')`)
Due to a quirk of the MIR borrowck implementation,
this doesn't always get exposed in migration mode,
but it does in many cases.
This commit makes THIR building consistently use 'larger'
spans for adjustment expressions. These spans are recoded
when we first create the adjustment during typecheck. For
example, an autoref adjustment triggered by a method call
will record the span of the entire method call.
The intent of this change it make it clearer to users
when it's the specific way in which a variable is
used (for example, in a method call) that produdes
a borrowcheck error. For example, an error message
claiming that a 'mutable borrow occurs here' might
be confusing if it just points at a usage of a variable
(e.g. `my_var`), when no `&mut` is in sight. Pointing
at the entire expression should help to emphasize
that the method call itself is responsible for
the mutable borrow.
In several cases, this makes the `#![feature(nll)]` diagnostic
output match up exactly with the default (migration mode) output.
As a result, several `.nll.stderr` files end up getting removed
entirely.
Fix Windows LLVM issue.
GitHub image 20210928.2 added LLVM 12.0.1 to the stock image. However, the `lldb` executable doesn't work, it fails with:
> C:/Program Files/LLVM/bin/lldb.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory
We probably don't want to start testing LLDB on windows anyways (at least not without intent).
The hacky solution for now is to just delete the system LLVM.
Restructure std::rt
These changes should reduce binary size slightly while at the same slightly improving performance of startup, thread spawning and `std:🧵:current()`. I haven't verified if the compiler is able to optimize some of these cases already, but at least for some others the compiler is unable to do these optimizations as they slightly change behavior in cases where program startup would crash anyway by omitting a backtrace and panic location.
I can remove 6f6bb16 if preferred.
Rollup of 8 pull requests
Successful merges:
- #87260 (Libgccjit codegen)
- #89212 (x.py: run `rustup toolchain link` in setup)
- #89233 (Hide `<...> defined here` note if the source is not available)
- #89235 (make junit output more consistent with default format)
- #89255 (Fix incorrect disambiguation suggestion for associated items)
- #89276 (Fix the population of the `union.impls` field)
- #89283 (Add regression test for issue #83564)
- #89318 (rustc_session: Remove lint store from `Session`)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Add an intermediate representation to exhaustiveness checking
The exhaustiveness checking algorithm keeps deconstructing patterns into a `Constructor` and some `Fields`, but does so a bit all over the place. This PR introduces a new representation for patterns that already has that information, so we only compute it once at the start.
I find this makes code easier to follow. In particular `DeconstructedPat::specialize` is a lot simpler than what happened before, and more closely matches the description of the algorithm. I'm also hoping this could help for the project of librarifying exhaustiveness for rust_analyzer since it decouples the algorithm from `rustc_middle::Pat`.
The `Step` trait guarantees that `Range<impl Step>` yields items in
sorted order. We can override the `Iterator::is_sorted` method based on
this guarantee, as we already do for `Iterator::min` and `max`.
Fix the population of the `union.impls` field
This pull-request fix the population of the `union.impls` field that was forgot when the `Union` type was introduce as a split from the `Struct` type https://github.com/rust-lang/rust/pull/81500.
``@rustbot`` label +T-rustdoc +A-rustdoc-json
Fix incorrect disambiguation suggestion for associated items
Fixes#88806. I have not added a new test case, because the erroneous behavior is already present in existing test cases.
make junit output more consistent with default format
The default format of libtest includes new-lines between each section to ensure the label output from cargo is on it's own line
<pre><font color="#A1B56C"><b>❯</b></font> <font color="#A1B56C">cargo</font><font color="#D8D8D8"> </font><font color="#A1B56C">test</font>
<font color="#A1B56C"><b> Compiling</b></font> test-test v0.1.0 (/home/jlusby/tmp/test-test)
<font color="#A1B56C"><b> Finished</b></font> test [unoptimized + debuginfo] target(s) in 0.59s
<font color="#A1B56C"><b> Running</b></font> unittests (target/debug/deps/test_test-639f369234319c09)
running 1 test
test tests::it_works ... <font color="#A1B56C">ok</font>
test result: <font color="#A1B56C">ok</font>. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
<font color="#A1B56C"><b> Doc-tests</b></font> test-test
running 0 tests
test result: <font color="#A1B56C">ok</font>. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
</pre>
But when the junit outputter was added to libtest these newlines were omitted, resulting in some "fun" output when run via cargo.
Note the `Doc-tests` text at the end of the first line of xml.
<pre><font color="#A1B56C"><b>❯</b></font> <font color="#A1B56C">cargo</font><font color="#D8D8D8"> </font><font color="#A1B56C">test</font><font color="#D8D8D8"> </font><font color="#A1B56C">--</font><font color="#D8D8D8"> </font><font color="#A1B56C">-Zunstable-options</font><font color="#D8D8D8"> </font><font color="#A1B56C">--format</font><font color="#D8D8D8"> </font><font color="#A1B56C">junit</font>
<font color="#A1B56C"><b> Finished</b></font> test [unoptimized + debuginfo] target(s) in 0.00s
<font color="#A1B56C"><b> Running</b></font> unittests (target/debug/deps/test_test-639f369234319c09)
<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="0" tests="1" skipped="0" ><testcase classname="tests" name="it_works" time="0"/><system-out/><system-err/></testsuite></testsuites><font color="#A1B56C"><b> Doc-tests</b></font> test-test
<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="0" tests="0" skipped="0" ><system-out/><system-err/></testsuite></testsuites>
</pre>
After this PR the junit output includes the same style of newlines as the pretty format
<pre><font color="#A1B56C"><b>❯</b></font> <font color="#A1B56C">cargo</font><font color="#D8D8D8"> </font><font color="#A1B56C">test</font><font color="#D8D8D8"> </font><font color="#A1B56C">--</font><font color="#D8D8D8"> </font><font color="#A1B56C">-Zunstable-options</font><font color="#D8D8D8"> </font><font color="#A1B56C">--format</font><font color="#D8D8D8"> </font><font color="#A1B56C">junit</font>
<font color="#A1B56C"><b> Compiling</b></font> test-test v0.1.0 (/home/jlusby/tmp/test-test)
<font color="#A1B56C"><b> Finished</b></font> test [unoptimized + debuginfo] target(s) in 0.39s
<font color="#A1B56C"><b> Running</b></font> unittests (target/debug/deps/test_test-42c2320bb9450c69)
<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="0" tests="1" skipped="0" ><testcase classname="tests" name="it_works" time="0"/><system-out/><system-err/></testsuite></testsuites>
<font color="#A1B56C"><b> Doc-tests</b></font> test-test
<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="0" tests="0" skipped="0" ><system-out/><system-err/></testsuite></testsuites>
</pre>
Libgccjit codegen
This PR introduces a subtree for a gcc-based codegen backend to the repository, per decision in https://github.com/rust-lang/compiler-team/issues/442. We do not yet expect to ship this backend on nightly or run tests in CI, but we do verify that the backend checks (i.e., `cargo check`) successfully.
Work is expected to progress primarily in https://github.com/rust-lang/rustc_codegen_gcc, with semi-regular upstreaming, like with other subtrees.
Rustup
This needs a review this time. Especially 521bf8f0fa cc `@camsteffen` I think this is necessary now, because `itertools` is no longer a dependency of `clippy_utils` and therefore this path can't be found 🤔
( I forgot about the sync last week. I should get to document this process better, so other people can do it when I'm not around )
changelog: none