Matthias Krüger [Thu, 2 Dec 2021 14:52:04 +0000 (15:52 +0100)]
Rollup merge of #91411 - ChrisDenton:valid-paths, r=petrochenkov
Enable svh tests on msvc
These tests were ignored for msvc in #30778 because of additional notes that were being added for some reason. I'm fairly confident this has been fixed in the intervening years so lets try re-enabling these tests.
Matthias Krüger [Thu, 2 Dec 2021 14:52:01 +0000 (15:52 +0100)]
Rollup merge of #91045 - mjptree:issue-90702-fix, r=petrochenkov
Issue 90702 fix: Stop treating some crate loading failures as fatal errors
Surface mulitple `extern crate` resolution errors at a time.
This is achieved by creating a dummy crate, instead of aborting directly after the resolution error. The `ExternCrateError` has been added to allow propagating the resolution error from `rustc_metadata` crate to the `rustc_resolve` with a minimal public surface. The `import_extern_crate` function is a block that was factored out from `build_reduced_graph_for_item` for better organization. The only added functionality made to it where the added error handling in the `process_extern_crate` call. The remaining bits in this function are the same as before.
seems to be unintentionally allowed so we couldn't disallow them now ~~, but we could disallow them if arbitrary enum discriminant is used before 1.56 hits stable~~ (stabilization was reverted).
bors [Thu, 2 Dec 2021 11:48:58 +0000 (11:48 +0000)]
Auto merge of #91354 - fee1-dead:const_env, r=spastorino
Cleanup: Eliminate ConstnessAnd
This is almost a behaviour-free change and purely a refactoring. "almost" because we appear to be using the wrong ParamEnv somewhere already, and this is now exposed by failing a test using the unstable `~const` feature.
We most definitely need to review all `without_const` and at some point should probably get rid of many of them by using `TraitPredicate` instead of `TraitRef`.
This is a continuation of https://github.com/rust-lang/rust/pull/90274.
Yacin Tmimi [Fri, 19 Nov 2021 23:52:52 +0000 (18:52 -0500)]
Determine when new comment lines are needed for itemized blocks
Fixes 5088
Previously, rustfmt would add a new comment line anytime it reformatted
an itemized block within a comment when ``wrap_comments=true``. This
would lead to rustfmt adding empty comments with trailing whitespace.
Now, new comment lines are only added if the original comment spanned
multiple lines, if the comment needs to be wrapped, or if the comment
originally started with an empty comment line.
bors [Wed, 1 Dec 2021 23:22:43 +0000 (23:22 +0000)]
Auto merge of #90446 - cjgillot:late-elided, r=jackh726
Lint elided lifetimes in path during lifetime resolution.
The lifetime elision lint is known to be brittle and can be redundant with later lifetime resolution errors. This PR aims to remove the redundancy by performing the lint after lifetime resolution.
This PR proposes to carry the information that an elision should be linted against by using a special `LifetimeName`. I am not certain this is the best solution, but it is certainly the easiest.
Noah Lev [Thu, 25 Nov 2021 03:35:18 +0000 (19:35 -0800)]
Migrate a test to use `@snapshot`
I'd been thinking about implementing snapshot testing for a while, but
This test is what finally made me do it. It really benefits from using
snapshot testing, so it's a good initial place to use `@snapshot`.
bors [Wed, 1 Dec 2021 20:14:07 +0000 (20:14 +0000)]
Auto merge of #91433 - matthiaskrgr:rollup-118ql06, r=matthiaskrgr
Rollup of 5 pull requests
Successful merges:
- #88502 (Add slice take methods)
- #91313 (expand: Turn `ast::Crate` into a first class expansion target)
- #91424 (Update LLVM with patches for better llvm-cov diagnostics)
- #91425 (Include lint errors in error count for `-Ztreat-err-as-bug`)
- #91430 (Add tests for `normalize-docs` overflow errors)
Gary Guo [Fri, 24 Sep 2021 20:58:25 +0000 (21:58 +0100)]
Disallow non-c-like but "fieldless" ADTs from being casted to integer...
... if they use arbitrary enum discriminant. Code like
```rust
enum Enum {
Foo = 1,
Bar(),
Baz{}
}
```
seems to be unintentionally allowed so we couldn't disallow them now,
but we could disallow them if arbitrary enum discriminant is used before
1.56 hits stable.
Matthias Krüger [Wed, 1 Dec 2021 19:57:48 +0000 (20:57 +0100)]
Rollup merge of #91430 - jyn514:normalize-fallible, r=jackh726
Add tests for `normalize-docs` overflow errors
`@b-naber` do you understand why using `try_normalize_erasing_regions` doesn't silence these cycle errors? Rustdoc isn't emitting them, rustc is aborting before returning an error, even though the function has `try_` in the name.
cc https://github.com/rust-lang/rust/issues/82692, https://github.com/rust-lang/rust/pull/91255
Matthias Krüger [Wed, 1 Dec 2021 19:57:47 +0000 (20:57 +0100)]
Rollup merge of #91425 - jyn514:treat-lint-err-as-bug, r=oli-obk
Include lint errors in error count for `-Ztreat-err-as-bug`
This was a regression from https://github.com/rust-lang/rust/pull/87337;
the `panic_if_treat_err_as_bug` function only checked the number of hard
errors, not the number of lint errors.
These patches to LLVM were added to help debug occasional errors that
cause coverage reporting to fail. Prior to this patch, the only messaging
was that the coverage data was malformed. Hopefully the improved
messaging will help identify the root cause of these errors, when they
arise, so we can make corrections to coverage output from Rust.
Matthias Krüger [Wed, 1 Dec 2021 19:57:43 +0000 (20:57 +0100)]
Rollup merge of #91313 - petrochenkov:cratexp, r=Aaron1011
expand: Turn `ast::Crate` into a first class expansion target
And stop creating a fake `mod` item for the crate root when expanding a crate, thus addressing FIXMEs left in https://github.com/rust-lang/rust/pull/82238, and making a step towards a proper support for crate-level macro attributes (cc #54726).
I haven't added token collection support for the whole crate in this PR, maybe later.
r? `@Aaron1011`
bors [Wed, 1 Dec 2021 16:41:52 +0000 (16:41 +0000)]
Auto merge of #91275 - camelid:deny-test-warnings, r=jyn514
Deny warnings in rustdoc non-UI tests
These warnings were silently ignored since they did not appear in a
`.stderr` file and did not fail the test. With this change, warnings in
tests are denied, causing the tests to fail if they have warnings.
This change has already led me to find a bug in rustdoc (#91274) and a
useless test (`src/test/rustdoc/primitive/primitive-generic-impl.rs`,
though its uselessness is unrelated to its warnings).
Joshua Nelson [Wed, 1 Dec 2021 16:32:55 +0000 (16:32 +0000)]
Include lint errors in error count for `-Ztreat-err-as-bug`
This was a regression from https://github.com/rust-lang/rust/pull/87337;
the `panic_if_treat_err_as_bug` function only checked the number of hard
errors, not the number of lint errors.
These patches to LLVM were added to help debug occasional errors that
cause coverage reporting to fail. Prior to this patch, the only messaging
was that the coverage data was malformed. Hopefully the improved
messaging will help identify the root cause of these errors, when they
arise, so we can make corrections to coverage output from Rust.
Previously we called `normalize_erasing_regions` inside `layout_of`. `normalize_erasing_regions` assumes that the normalization succeeds. Since some `layout_of` calls happen before typecheck has finished, we introduce a new variant that allows for returning an error.
bors [Wed, 1 Dec 2021 09:51:00 +0000 (09:51 +0000)]
Auto merge of #91418 - matthiaskrgr:rollup-vn9f9w3, r=matthiaskrgr
Rollup of 7 pull requests
Successful merges:
- #87160 (When recovering from a `:` in a pattern, use adequate AST pattern)
- #90985 (Use `get_diagnostic_name` more)
- #91087 (Remove all migrate.nll.stderr files)
- #91207 (Add support for LLVM coverage mapping format versions 5 and 6)
- #91298 (Improve error message for `E0659` if the source is not available)
- #91346 (Add `Option::inspect` and `Result::{inspect, inspect_err}`)
- #91404 (Fix bad `NodeId` limit checking.)
Matthias Krüger [Wed, 1 Dec 2021 09:50:23 +0000 (10:50 +0100)]
Rollup merge of #91404 - nnethercote:fix-bad-NodeId-limit-checking, r=dtolnay
Fix bad `NodeId` limit checking.
`Resolver::next_node_id` converts a `u32` to a `usize` (which is
possibly bigger), does a checked add, and then converts the result back
to a `u32`. The `usize` conversion completely subverts the checked add!
This commit removes the conversion to/from `usize`.
Matthias Krüger [Wed, 1 Dec 2021 09:50:21 +0000 (10:50 +0100)]
Rollup merge of #91298 - FabianWolff:issue-91028-source-avail, r=cjgillot
Improve error message for `E0659` if the source is not available
Fixes #91028. The fix is similar to those in #89233 and #87088. With this change, instead of the dangling
```
note: `Option` could also refer to the enum defined here
```
I get
```
note: `Option` could also refer to an enum from prelude
```
If the standard library source code _is_ available, the output does not change.
Matthias Krüger [Wed, 1 Dec 2021 09:50:20 +0000 (10:50 +0100)]
Rollup merge of #91207 - richkadel:rk-bump-coverage-version, r=tmandry
Add support for LLVM coverage mapping format versions 5 and 6
This PR cherry-pick's Swatinem's initial commit in unsubmitted PR #90047.
My additional commit augments Swatinem's great starting point, but adds full support for LLVM
Coverage Mapping Format version 6, conditionally, if compiling with LLVM 13.
Version 6 requires adding the compilation directory when file paths are
relative, and since Rustc coverage maps use relative paths, we should
add the expected compilation directory entry.
Note, however, that with the compilation directory, coverage reports
from `llvm-cov show` can now report file names (when the report includes
more than one file) with the full absolute path to the file.
This would be a problem for test results, but the workaround (for the
rust coverage tests) is to include an additional `llvm-cov show`
parameter: `--compilation-dir=.`
Matthias Krüger [Wed, 1 Dec 2021 09:50:19 +0000 (10:50 +0100)]
Rollup merge of #91087 - rukai:fix_test_nll_revisions, r=jackh726
Remove all migrate.nll.stderr files
There are a few ui tests that setup the revisions like:
```rust
// revisions: migrate nll`
// [nll]compile-flags: -Zborrowck=mir
```
However most of them fail to disable the nll compare mode like this:
```rust
// ignore-compare-mode-nll
```
This ends up generating confusing files ending in `.migrate.nll.stderr` because the nll compare mode is run on top of the migrate revision.
This PR fixes this by adding `ignore-compare-mode-nll` to these tests.
I would have just made these tests use compare modes instead but I assume the reason these tests are messing around with revisions instead of just letting the nll compare mode do its thing is to enforce error annotations for both migrate and nll.
Relying on just compare modes would only have the error annotations for migrate.
`Resolver::next_node_id` converts a `u32` to a `usize` (which is
possibly bigger), does a checked add, and then converts the result back
to a `u32`. The `usize` conversion completely subverts the checked add!
This commit removes the conversion to/from `usize`.
bors [Wed, 1 Dec 2021 02:51:15 +0000 (02:51 +0000)]
Auto merge of #91406 - matthiaskrgr:rollup-a2whn8m, r=matthiaskrgr
Rollup of 4 pull requests
Successful merges:
- #91294 (Visit type in process_projection_elem.)
- #91340 (Bump compiler_builtins to 0.1.55 to bring in fixes for targets lackin…)
- #91366 (Only show notable traits if both types are the same)
- #91397 (Emit a warning on generic parameters with doc comments)
Dylan MacKenzie [Wed, 1 Dec 2021 01:05:40 +0000 (17:05 -0800)]
Move post-elaboration const-checking earlier in the pipeline
Instead we run `RemoveFalseEdges` and `RemoveUninitDrops` at the
appropriate time. The extra `SimplifyCfg` avoids visiting unreachable
blocks during `RemoveUninitDrops`.
Dylan MacKenzie [Tue, 30 Nov 2021 18:14:50 +0000 (10:14 -0800)]
Separate `RemoveFalseEdges` from `SimplifyBranches`
Otherwise dataflow state will propagate along false edges and cause
things to be marked as maybe init unnecessarily. These should be
separate, since `SimplifyBranches` also makes `if true {} else {}` into
a `goto`, which means we wouldn't lint anything in the `else` block.
Matthias Krüger [Tue, 30 Nov 2021 22:43:31 +0000 (23:43 +0100)]
Rollup merge of #91340 - cr1901:no-atomic, r=Mark-Simulacrum
Bump compiler_builtins to 0.1.55 to bring in fixes for targets lackin…
…g atomic support.
This fixes a "Cannot select" LLVM error when compiling `compiler_builtins` for targets lacking atomics, like MSP430. Se https://github.com/rust-lang/compiler-builtins/issues/441 for more info. This PR is a more general version of #91248.
Rich Kadel [Thu, 25 Nov 2021 00:58:49 +0000 (16:58 -0800)]
Add conditional support for coverage map version 6
This commit augments Swatinem's initial commit in uncommitted PR #90047,
which was a great starting point, but did not fully support LLVM
Coverage Mapping Format version 6.
Version 6 requires adding the compilation directory when file paths are
relative, and since Rustc coverage maps use relative paths, we should
add the expected compilation directory entry.
Note, however, that with the compilation directory, coverage reports
from `llvm-cov show` can now report file names (when the report includes
more than one file) with the full absolute path to the file.
This would be a problem for test results, but the workaround (for the
rust coverage tests) is to include an additional `llvm-cov show`
parameter: `--compilation-dir=.`
Yuki Okushi [Tue, 30 Nov 2021 08:29:13 +0000 (17:29 +0900)]
Rollup merge of #91383 - ScriptDevil:drop-while-doc-alias, r=joshtriplett
Add `drop_while` as doc alias to `Iterator::skip_while`
`skip_while` is commonly referred to as `drop_while` in other languages (clojure/c++/haskell). This recently came up in [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/.E2.9C.94.20DropWhile/near/262203352) as well.
This pull request adds 'drop_while' as a doc-alias for 'skip_while'.
Yuki Okushi [Tue, 30 Nov 2021 08:29:09 +0000 (17:29 +0900)]
Rollup merge of #91323 - RalfJung:assert-type, r=oli-obk
CTFE: support assert_zero_valid and assert_uninit_valid
This ensures the implementation of all three type-based assert_ intrinsics remains consistent in Miri.
`assert_inhabited` recently got stabilized in https://github.com/rust-lang/rust/pull/90896 (meaning stable `const fn` can call it), so do the same with these other intrinsics.
Yuki Okushi [Tue, 30 Nov 2021 08:29:07 +0000 (17:29 +0900)]
Rollup merge of #91250 - rukai:remove_trailing_whitespace, r=wesleywiser
Refactor EmitterWriter::emit_suggestion_default
Makes progress towards https://github.com/rust-lang/rust/issues/89979
Split into 2 commits:
* the first commit is purely a refactor and I verified that `./x.py test src/test/ui --stage 1` and `./x.py test src/test/rustdoc-ui --stage 1` continue to pass on this commit.
* ~~the second commit removes the empty trailing line from diff style suggestions.~~ - I discovered an issue with this so its just the refactor now.