Commit graph

158873 commits

Author SHA1 Message Date
Ralf Jung b11d88006c disable tests in Miri that take too long 2021-12-01 22:48:59 -05:00
bors a2b7b7891e Auto merge of #91003 - psumbera:sparc64-abi, r=nagisa
fix sparc64 ABI for aggregates with floating point members

Fixes #86163
2021-12-02 02:59:44 +00:00
Yacin Tmimi ec46ffd981 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.
2021-12-01 18:31:10 -06:00
bors 76938d64a4 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.

Fixes https://github.com/rust-lang/rust/issues/60199
Fixes https://github.com/rust-lang/rust/issues/55768
Fixes https://github.com/rust-lang/rust/issues/63110
Fixes https://github.com/rust-lang/rust/issues/71957
2021-12-01 23:22:43 +00:00
Noah Lev fe88fcfa39 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`.
2021-12-01 15:12:12 -08:00
Noah Lev e2846a779d Implement @snapshot check for htmldocck
This form of check allows performing snapshot tests (à la `src/test/ui`)
on rustdoc HTML output, making it easier to create and update tests.

See this Zulip thread [1] for more information about the motivation for
this change.

[1]: https://zulip-archive.rust-lang.org/stream/266220-rustdoc/topic/HTML.20snapshot.20tests.html#262651142
2021-12-01 15:12:10 -08:00
Michael 2ca9333011 Improve suggestion for extern crate self error message 2021-12-01 21:59:54 +00:00
Fabian Wolff ba7374e517 Improve diagnostic for missing half of binary operator in if condition 2021-12-01 22:36:50 +01:00
Michael 62f4ce993e Stop treating extern crate loading failures as fatal errors 2021-12-01 21:04:13 +00:00
Michael 10b3a571d2 Factor out build reduced graph for extern crate 2021-12-01 21:04:12 +00:00
bors 48a5999fce 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)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-01 20:14:07 +00:00
Gary Guo f7ef1c9f41 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.
2021-12-01 19:59:15 +00:00
Matthias Krüger 4ae75cfa2e
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
2021-12-01 20:57:48 +01:00
Matthias Krüger 4a6e8a9c93
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.

r? `@oli-obk`
2021-12-01 20:57:47 +01:00
Matthias Krüger 5fb1886629
Rollup merge of #91424 - richkadel:llvm-patch-instrproferror, r=tmandry
Update LLVM with patches for better llvm-cov diagnostics

Cherry-picks
ee88b8d63e
and
126e7611c7

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.

r? `@tmandry`
2021-12-01 20:57:46 +01:00
Matthias Krüger 519a842c50
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`
2021-12-01 20:57:43 +01:00
Matthias Krüger 9f1f42897d
Rollup merge of #88502 - ibraheemdev:slice-take, r=dtolnay
Add slice take methods

Revival of #62282

This PR adds the following slice methods:

- `take`
- `take_mut`
- `take_first`
- `take_first_mut`
- `take_last`
- `take_last_mut`

r? `@LukasKalbertodt`
2021-12-01 20:57:42 +01:00
Joshua Nelson 18ddf8d636 Use try_normalize_erasing_regions instead of a custom infer context
This unfortunately is still giving an unsilenceable overflow error :(
2021-12-01 19:22:24 +00:00
Julian Wollersberger 1f147a2ed7 Replace nth_char(0) with next() in cursor.first()
and optimize the iterator returned by `tokenize().

This improves lexer performance by 35%
2021-12-01 19:14:10 +01:00
Dylan MacKenzie 37fa925525 Add regression test for #90770 2021-12-01 10:04:21 -08:00
bors 3c51718ae7 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).

r? `@jyn514`
2021-12-01 16:41:52 +00:00
Joshua Nelson 9de8a4a6fa 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.
2021-12-01 16:39:55 +00:00
Rich Kadel 0a27393290 Update LLVM with patches for better llvm-cov diagnostics
Cherry-picks
ee88b8d63e
and
126e7611c7

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.
2021-12-01 07:34:53 -08:00
Deadbeef 5ebc99e5b2
Format 2021-12-01 23:33:37 +08:00
Deadbeef b64c40bc6f
TODO => FIXME 2021-12-01 23:32:36 +08:00
Deadbeef 6b07cec05c
Cache with consistent env and bound 2021-12-01 23:22:42 +08:00
bors f04a2f4b8e Auto merge of #91255 - b-naber:normalization-ice, r=jackh276
Implement version of normalize_erasing_regions that allows for normalization failure

Fixes https://github.com/rust-lang/rust/issues/59324
Fixes https://github.com/rust-lang/rust/issues/67684
Fixes https://github.com/rust-lang/rust/issues/69398
Fixes https://github.com/rust-lang/rust/issues/71113
Fixes https://github.com/rust-lang/rust/issues/82079
Fixes #85103
Fixes https://github.com/rust-lang/rust/issues/88856
Fixes #91231
Fixes https://github.com/rust-lang/rust/issues/91234

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.
2021-12-01 13:33:33 +00:00
b-naber 6952470095 rebase 2021-12-01 13:15:59 +01:00
b-naber 4d9a0bf21b address review 2021-12-01 12:12:40 +01:00
b-naber 84bcd40927 fix query description 2021-12-01 12:12:40 +01:00
b-naber 0b32cf3a8d remove static_assert_size on InterpError 2021-12-01 12:12:39 +01:00
b-naber a040b4189d more fixed issues 2021-12-01 12:12:39 +01:00
b-naber e0c98e2a33 add tests and bless existing ones 2021-12-01 12:12:39 +01:00
b-naber ff448cfcee implement version of normalize_erasing_regions that doesn't assume value is normalizable 2021-12-01 12:12:38 +01:00
bors 26b45573be 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.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-01 09:51:00 +00:00
Matthias Krüger 4f252f1a91
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`.
2021-12-01 10:50:23 +01:00
Matthias Krüger ce197e2bce
Rollup merge of #91346 - ibraheemdev:result-inspect, r=dtolnay
Add `Option::inspect` and `Result::{inspect, inspect_err}`

```rust
// core::result

impl Result<T, E> {
    pub fn inspect<F: FnOnce(&T)>(self, f: F) -> Self;
    pub fn inspect_err<F: FnOnce(&E)>(self, f: F) -> Self;
}

// core::option

impl Option<T> {
    pub fn inspect<F: FnOnce(&T)>(self, f: F) -> Self;
}
```
2021-12-01 10:50:22 +01:00
Matthias Krüger c09c16c0df
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.
2021-12-01 10:50:21 +01:00
Matthias Krüger d93df5775c
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=.`
2021-12-01 10:50:20 +01:00
Matthias Krüger 2695e85c09
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.
2021-12-01 10:50:19 +01:00
Matthias Krüger a4f46742c2
Rollup merge of #90985 - camsteffen:diag-name-usage, r=jackh726
Use `get_diagnostic_name` more
2021-12-01 10:50:18 +01:00
Matthias Krüger e68e5d2391
Rollup merge of #87160 - estebank:colon-recovery, r=nagisa
When recovering from a `:` in a pattern, use adequate AST pattern

If the suggestion to use `::` instead of `:` in the pattern isn't correct, a second resolution error will be emitted.
2021-12-01 10:50:18 +01:00
Petr Sumbera 128ceec92d fix sparc64 ABI for aggregates with floating point members 2021-12-01 10:03:45 +01:00
bors 2446a21595 Auto merge of #91324 - eggyal:avoid-uneccesary-clone-of-annotatable, r=Aaron1011
Avoid uneccessary clone of Annotatable

Addresses FIXME comment created in #82608

r? `@Aaron1011`
2021-12-01 06:18:39 +00:00
Nicholas Nethercote e7ee8230ce 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`.
2021-12-01 15:08:37 +11:00
Dylan MacKenzie 9aaca1d38e Update MIR opt tests with new name 2021-11-30 18:54:37 -08:00
bors d384ff7930 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)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-01 02:51:15 +00:00
Chris Denton a8e1ac9594
Enable svh tests on msvc 2021-12-01 02:05:17 +00:00
Dylan MacKenzie 58c996c3a7 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`.
2021-11-30 17:25:30 -08:00
Dylan MacKenzie 3e0e8be037 Handle DropAndReplace in const-checking
It runs before the real drop elaboration pass.
2021-11-30 17:25:30 -08:00