Commit Graph

10741 Commits

Author SHA1 Message Date
David Tolnay
47f92a58a4
Accommodate yield points in the format_args expansion 2022-01-30 11:53:11 -08:00
Eric Huss
cee571e606
Rollup merge of #93192 - theidexisted:patch-1, r=wesleywiser
Add VS 2022 into error message
2022-01-30 08:37:50 -08:00
Eric Huss
ba013373d8
Rollup merge of #92908 - dtolnay:rustdoc, r=GuillaumeGomez
Render more readable macro matcher tokens in rustdoc

Follow-up to #92334.

This PR lifts some of the token rendering logic from https://github.com/dtolnay/prettyplease into rustdoc so that even the matchers for which a source code snippet is not available (because they are macro-generated, or any other reason) follow some baseline good assumptions about where the tokens in the macro matcher are appropriate to space.

The below screenshots show an example of the difference using one of the gnarliest macros I could find. Some things to notice:

- In the **before**, notice how a couple places break in between `$(....)`↵`*`, which is just about the worst possible place that it could break.

- In the **before**, the lines that wrapped are weirdly indented by 1 space of indentation relative to column 0. In the **after**, we use the typical way of block indenting in Rust syntax which is put the open/close delimiters on their own line and indent their contents by 4 spaces relative to the previous line (so 8 spaces relative to column 0, because the matcher itself is indented by 4 relative to the `macro_rules` header).

- In the **after**, macro_rules metavariables like `$tokens:tt` are kept together, which is how just about everybody writing Rust today writes them.

## Before

![Screenshot from 2022-01-14 13-05-53](https://user-images.githubusercontent.com/1940490/149585105-1f182b78-751f-421f-a234-9dbc04fa3bbd.png)

## After

![Screenshot from 2022-01-14 13-06-04](https://user-images.githubusercontent.com/1940490/149585118-d4b52ea7-3e67-4b6e-a12b-31dfb8172f86.png)

r? `@camelid`
2022-01-30 08:37:47 -08:00
Eric Huss
0610d4fa66
Rollup merge of #92887 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrum
Bootstrap compiler update

r? ``@Mark-Simulacrum``
2022-01-30 08:37:46 -08:00
Matthias Krüger
9f6d0cb052
Rollup merge of #93463 - dtolnay:_args, r=cjgillot
Rename _args -> args in format_args expansion

As observed in https://github.com/rust-lang/rust/pull/91359#discussion_r786058960, prior to that PR this variable was sometimes never used, such as in the case of:

```rust
println!("");

// used to expand to:
::std::io::_print(
    ::core::fmt::Arguments::new_v1(
        &["\n"],
        &match () {
            _args => [],
        },
    ),
);
```

so the leading underscore in `_args` was used to suppress an unused variable lint. However after #91359 the variable is always used when present, as the unused case would instead expand to:

```rust
::std::io::_print(::core::fmt::Arguments::new_v1(&["\n"], &[]));
```
2022-01-30 00:04:17 +01:00
Matthias Krüger
4484165cbd
Rollup merge of #93362 - compiler-errors:ice-gat-in-rpit, r=oli-obk
Do not register infer var for GAT projection in RPIT

Fixes #93340
Fixes #91603

r? ```@oli-obk```
2022-01-30 00:04:12 +01:00
Matthias Krüger
103c3a38a6
Rollup merge of #93358 - compiler-errors:is-not-const, r=fee1-dead
Add note suggesting that predicate may be satisfied, but is not `const`

Not sure if we should be printing this in addition to, or perhaps _instead_ of the help message:
```
help: the trait `~const Add` is not implemented for `NonConstAdd`
```

Also added `ParamEnv::is_const` and `PolyTraitPredicate::is_const_if_const` and, in a separate commit, used those in other places instead of `== hir::Constness::Const`, etc.

r? ````@fee1-dead````
2022-01-30 00:04:11 +01:00
Tomasz Miąsko
35b5daaaf8 Check the number of arguments first in is_recursive_call 2022-01-29 23:00:54 +01:00
David Tolnay
6667d785d8
Rename _args -> args in format_args expansion 2022-01-29 12:44:41 -08:00
Gary Guo
a832f5f7bc Create core::fmt::ArgumentV1 with generics instead of fn pointer 2022-01-29 13:52:19 +00:00
Matthias Krüger
c866ae5e93
Rollup merge of #93431 - lqd:remove-jemallocator, r=Mark-Simulacrum
remove unused `jemallocator` crate

When it was noticed that the rustc binary wasn't actually using jemalloc via `#[global_allocator]` and that was removed, the dependency remained.

Tests pass locally with a `jemalloc = true` build, but I'll trigger a try build to ensure I haven't missed an edge-case somewhere.

r? ```@ghost``` until that completes
2022-01-29 14:46:34 +01:00
Matthias Krüger
6621ff4a7c
Rollup merge of #93424 - lcnr:nit, r=spastorino
fix nit
2022-01-29 14:46:33 +01:00
Matthias Krüger
9e86a434a7
Rollup merge of #92274 - woppopo:const_deallocate, r=oli-obk
Add `intrinsics::const_deallocate`

Tracking issue: #79597
Related: #91884

This allows deallocation of a memory allocated by `intrinsics::const_allocate`. At the moment, this can be only used to reduce memory usage, but in the future this may be useful to detect memory leaks (If an allocated memory remains after evaluation, raise an error...?).
2022-01-29 14:46:30 +01:00
Matthias Krüger
11898a56c2
Rollup merge of #88205 - danii:e0772, r=GuillaumeGomez
Add Explanation For Error E0772

I've added an error explanation for the error code E0772.

Assists with #61137
2022-01-29 14:46:29 +01:00
Santiago Pastorino
bf1ca2e4b0
Make local_def_id_to_hir_id query directly returh HirId 2022-01-29 08:40:23 -03:00
bors
6250d5a08c Auto merge of #93427 - matthiaskrgr:rollup-esd3ixl, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #92611 (Add links to the reference and rust by example for asm! docs and lints)
 - #93158 (wasi: implement `sock_accept` and enable networking)
 - #93239 (Add os::unix::net::SocketAddr::from_path)
 - #93261 (Some unwinding related cg_ssa cleanups)
 - #93295 (Avoid double panics when using `TempDir` in tests)
 - #93353 (Unimpl {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}<$t> for Saturating<$t>)
 - #93356 (Edit docs introduction for `std::cmp::PartialOrd`)
 - #93375 (fix typo `documenation`)
 - #93399 (rustbuild: Fix compiletest warning when building outside of root.)
 - #93404 (Fix a typo from #92899)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-28 23:20:38 +00:00
Santiago Pastorino
5a299a9903
Make local_def_id_to_hir_id return MaybeOwner<()> 2022-01-28 15:13:01 -03:00
Santiago Pastorino
d17eb78cf8
Separate hir_owner query into two queries to avoid using extensive data on incr comp most of the time 2022-01-28 14:58:27 -03:00
Daniel Conley
4f8b9a4126
Add Explanation For Error E0772 2022-01-28 11:00:56 -05:00
Rémy Rakic
f9e0eb3b94 remove unused jemallocator crate 2022-01-28 16:56:05 +01:00
Matthias Krüger
ada77e94ab
Rollup merge of #93261 - bjorn3:cg_ssa_refactor6, r=cjgillot
Some unwinding related cg_ssa cleanups

These should make it a bit easier for alternative codegen backends to implement unwinding.
2022-01-28 15:20:24 +01:00
Matthias Krüger
db6ca25325
Rollup merge of #92611 - Amanieu:asm-reference, r=m-ou-se
Add links to the reference and rust by example for asm! docs and lints

These were previously removed in #91728 due to broken links.

cc ``@ehuss`` since this updates the rust-by-example submodule
2022-01-28 15:20:21 +01:00
lcnr
9d65342591 fix nit 2022-01-28 15:02:47 +01:00
Pietro Albini
5b3462c556
update cfg(bootstrap)s 2022-01-28 15:01:07 +01:00
bors
427eba2f0b Auto merge of #93006 - michaelwoerister:fix-unsized-ptr-debuginfo, r=davidtwco,oli-obk
Fix debuginfo for pointers/references to unsized types

This PR makes the compiler emit fat pointer debuginfo in all cases. Before, we sometimes got thin-pointer debuginfo, making it impossible to fully interpret the pointed to memory in debuggers. The code is actually cleaner now, especially around generation of trait object pointer debuginfo.

Fixes https://github.com/rust-lang/rust/issues/92718

~~Blocked on https://github.com/rust-lang/rust/pull/92729.~~
2022-01-28 12:46:13 +00:00
bors
e0e70c0c2c Auto merge of #90677 - bobrippling:suggest-tuple-parens, r=camelid
Suggest tuple-parentheses for enum variants

This follows on from #86493 / #86481, making the parentheses suggestion. To summarise, given the following code:

```rust
fn f() -> Option<(i32, i8)> {
    Some(1, 2)
}
```

The current output is:

```
error[E0061]: this enum variant takes 1 argument but 2 arguments were supplied
 --> b.rs:2:5
  |
2 |     Some(1, 2)
  |     ^^^^ -  - supplied 2 arguments
  |     |
  |     expected 1 argument

error: aborting due to previous error

For more information about this error, try `rustc --explain E0061`.
```

With this change, `rustc` will now suggest parentheses when:
- The callee is expecting a single tuple argument
- The number of arguments passed matches the element count in the above tuple
- The arguments' types match the tuple's fields

```
error[E0061]: this enum variant takes 1 argument but 2 arguments were supplied
 --> b.rs:2:5
  |
2 |     Some(1, 2)
  |     ^^^^ -  - supplied 2 arguments
  |
help: use parentheses to construct a tuple
  |
2 |     Some((1, 2))
  |          +    +
```
2022-01-28 09:46:22 +00:00
Michael Woerister
c10f9e7d1d [debuginfo] Fix and unify handling of fat pointers in debuginfo: Don't mark fat pointer fields as artificial.
LLDB does not seem to see fields if they are marked with DW_AT_artificial
which breaks pretty printers that use these fields for decoding fat pointers.
2022-01-28 10:41:36 +01:00
bors
312a7995e7 Auto merge of #93343 - lqd:attrs, r=spastorino
Only traverse attrs once while checking for coherence override attributes

In coherence, while checking for negative impls override attributes: only traverse the `DefId`s' attributes once.

This PR is an easy way to get back some of the small perf loss in #93175
2022-01-28 06:28:08 +00:00
kadmin
bd03d8167f Remove generalization over projection
Instead, just use a term everywhere.
2022-01-28 00:25:36 +00:00
Noah Lev
c8198a608e Improve suggestion for escaping reserved keywords 2022-01-27 14:53:39 -08:00
Matthias Krüger
0eb6753fc5
Rollup merge of #93365 - nnethercote:more-arena-cleanups, r=oli-obk
More arena cleanups

A sequel to #90990.

r? `@oli-obk`
2022-01-27 22:32:30 +01:00
Matthias Krüger
8347f7851a
Rollup merge of #93363 - lcnr:pass-by-value, r=petrochenkov
`#[rustc_pass_by_value]` cleanup
2022-01-27 22:32:29 +01:00
Matthias Krüger
5d79874e79
Rollup merge of #93357 - nnethercote:clarify-usage-of-qualified-ty, r=lcnr
Clarify the `usage-of-qualified-ty` error message.

I found this message confusing when I encountered it. This commit makes
it clearer that you have to import the unqualified type yourself.

r? `@lcnr`
2022-01-27 22:32:28 +01:00
Matthias Krüger
6caa533dc7
Rollup merge of #93325 - tmiasko:lev, r=davidtwco
Introduce a limit to Levenshtein distance computation

Incorporate distance limit from `find_best_match_for_name` directly into
Levenshtein distance computation.

Use the string size difference as a lower bound on the distance and exit
early when it exceeds the specified limit.

After finding a candidate within a limit, lower the limit further to
restrict the search space.
2022-01-27 22:32:26 +01:00
Matthias Krüger
bc26f97394
Rollup merge of #93193 - Kobzol:stable-hash-permutation-test, r=the8472
Add test for stable hash uniqueness of adjacent field values

This PR adds a simple test to check that stable hash will produce a different hash if the order of two values that have the same combined bit pattern changes.

r? `@the8472`
2022-01-27 22:32:24 +01:00
5225225
7f24778102 Suggest making base prefix lowercase if parsing fails 2022-01-27 21:31:28 +00:00
Nicholas Nethercote
6035487715 Clarify ArenaAllocatable's second parameter.
It's simply a binary thing to allow different behaviour for `Copy` vs
`!Copy` types. The new code makes this much clearer; I was scratching my
head over the old code for some time.
2022-01-28 07:37:10 +11:00
Nicholas Nethercote
9065c7ced6 Add some comments. 2022-01-28 07:37:07 +11:00
Maybe Waffle
4ca56d2888 Check that #[rustc_must_implement_one_of] is applied to a trait 2022-01-27 22:07:16 +03:00
Michael Woerister
d33e317a72 [debuginfo] Fix and unify handling of fat pointers in debuginfo: Change doc comment so it is not interpreted as doc-test. 2022-01-27 16:55:48 +01:00
kadmin
1c4fe64bdc Continue work on assoc const eq 2022-01-27 14:40:55 +00:00
Camille GILLOT
a0bcce4884
Store def_id_to_hir_id as variant in hir_owner.
If hir_owner is Owner(_), the LocalDefId is pointing to an owner, so the ItemLocalId is 0.
If the HIR node does not exist, we store Phantom.
Otherwise, we store the HirId associated to the LocalDefId.
2022-01-27 10:46:40 -03:00
lcnr
2684dfe583 try apply rustc_pass_by_value to Span 2022-01-27 11:29:41 +01:00
lcnr
e6808381e5 update pass_by_value 2022-01-27 07:58:33 +01:00
Michael Goulet
c6f6e3e0e9 do not register infer var for GAT projection in opaque 2022-01-26 22:45:12 -08:00
Nicholas Nethercote
696d5034b2 Clarify the usage-of-qualified-ty error message.
I found this message confusing when I encountered it. This commit makes
it clearer that you have to import the unqualified type yourself.
2022-01-27 17:42:35 +11:00
bors
21b4a9cfdc Auto merge of #92889 - tmiasko:unbounded-recursion, r=ecstatic-morse
Ignore unwinding edges when checking for unconditional recursion

The unconditional recursion lint determines if all execution paths
eventually lead to a self-recursive call.

The implementation always follows unwinding edges which limits its
practical utility. For example, it would not lint function `f` because a
call to `g` might unwind. It also wouldn't lint function `h` because an
overflow check preceding the self-recursive call might unwind:

```rust
pub fn f() {
    g();
    f();
}

pub fn g() { /* ... */ }

pub fn h(a: usize) {
  h(a + 1);
}
```

To avoid the issue, assume that terminators that might continue
execution along non-unwinding edges do so.

Fixes #78474.
2022-01-27 06:21:53 +00:00
Michael Goulet
c6de4d55aa drive-by: use is_const and is_const_if_const 2022-01-26 19:24:01 -08:00
Michael Goulet
1ab97dbc52 add note suggesting that predicate is satisfied but is not const 2022-01-26 19:09:44 -08:00
bors
009c1d0248 Auto merge of #93352 - matthiaskrgr:rollup-5peret4, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #90247 (Improve Duration::try_from_secs_f32/64 accuracy by directly processing exponent and mantissa)
 - #91861 (Replace iterator-based construction of collections by `Into<T>`)
 - #92098 (add OpenBSD platform-support page)
 - #92134 (Add x86_64-pc-windows-msvc linker-plugin-lto instructions)
 - #92256 (Improve selection errors for `~const` trait bounds)
 - #92778 (fs: Use readdir() instead of readdir_r() on Linux and Android)
 - #93338 (Update minifier crate version to 0.0.42)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-26 22:54:26 +00:00
Matthias Krüger
e2b2bfe10c
Rollup merge of #92256 - fee1-dead:improve-selection-err, r=oli-obk
Improve selection errors for `~const` trait bounds
2022-01-26 23:45:22 +01:00
bors
6abb6385b2 Auto merge of #93301 - spastorino:perf-test-1, r=oli-obk
Store hir_id_to_def_id in OwnerInfo.

This is for perf test purposes only. Related to #89278
2022-01-26 19:45:09 +00:00
Rémy Rakic
644c22d3ad Only traverse attrs once while checking for coherence override 2022-01-26 18:32:02 +01:00
Santiago Pastorino
384189c3d9
Filter out local_id == 0, those are already considered on the call site 2022-01-26 12:25:31 -03:00
Tomasz Miąsko
10b722cc79 Ignore unwinding edges when checking for unconditional recursion
The unconditional recursion lint determines if all execution paths
eventually lead to a self-recursive call.

The implementation always follows unwinding edges which limits its
practical utility. For example, it would not lint function `f` because a
call to `g` might unwind. It also wouldn't lint function `h` because an
overflow check preceding the self-recursive call might unwind:

```rust
pub fn f() {
    g();
    f();
}

pub fn g() { /* ... */ }

pub fn h(a: usize) {
  h(a + 1);
}
```

To avoid the issue, assume that terminators that might continue
execution along non-unwinding edges do so.
2022-01-26 13:46:01 +01:00
bors
a7f375789b Auto merge of #91840 - JakobDegen:fix_early_otherwise, r=oli-obk
Fix the unsoundness in the `early_otherwise_branch` mir opt pass

Closes #78496 .

This change is a significant rewrite of much of the pass. Exactly what it does is documented in the source file (with ascii art!), and all the changes that are made to the MIR that are not trivially sound are carefully documented. That being said, this is my first time touching MIR, so there are probably some invariants I did not know about that I broke.

This version of the optimization is also somewhat more flexible than the original; for example, we do not care how or where the value on which the parent is switching is computed. There is no requirement that any types be the same. This could be made even more flexible in the future by allowing a wider range of statements in the bodies of `BBC, BBD` (as long as they are all the same of course). This should be a good first step though.

Probably needs a perf run.

r? `@oli-obk` who reviewed things the last time this was touched
2022-01-26 12:10:54 +00:00
Tomasz Miąsko
6236882127 Introduce a limit to Levenshtein distance computation
Incorporate distance limit from `find_best_match_for_name` directly into
Levenshtein distance computation.

Use the string size difference as a lower bound on the distance and exit
early when it exceeds the specified limit.

After finding a candidate within a limit, lower the limit further to
restrict the search space.
2022-01-26 12:38:22 +01:00
Tomasz Miąsko
380d53fb2c Check namespace before computing the Levenshtein distance 2022-01-26 10:43:14 +01:00
Tomasz Miąsko
f93bd000a3 Hoist to_uppercase out of the loop 2022-01-26 10:43:01 +01:00
bors
788b1fe5b7 Auto merge of #88679 - petrochenkov:doctrscope, r=GuillaumeGomez
rustdoc: Pre-calculate traits that are in scope for doc links

This eliminates one more late use of resolver (part of #83761).
At early doc link resolution time we go through parent modules of items from the current crate, reexports of items from other crates, trait items, and impl items collected by `collect-intra-doc-links` pass, determine traits that are in scope in each such module, and put those traits into a map used by later rustdoc passes.
r? `@jyn514`
2022-01-26 09:10:27 +00:00
threadexception
ecd06e1e6a Don't suggest inaccessible fields 2022-01-26 09:47:52 +01:00
woppopo
29932db09b const_deallocate: Don't deallocate memory allocated in an another const. Does nothing at runtime.
`const_allocate`:  Returns a null pointer at runtime.
2022-01-26 13:06:09 +09:00
Rob Pilling
a8bac9879a Remove 1-tuple unreachable case 2022-01-25 22:55:22 +00:00
Rob Pilling
a129a85144 Handle generics with ParamEnv 2022-01-25 22:51:19 +00:00
Rob Pilling
54d2d30662 Compare tuple element & arg types before suggesting a tuple 2022-01-25 22:51:19 +00:00
Rob Pilling
94c300a452 Suggest tuple-parentheses when passing N arguments to an N-tuple argument 2022-01-25 22:51:14 +00:00
Matthias Krüger
086be2b6c4
Rollup merge of #93303 - compiler-errors:issue-93282, r=wesleywiser
Fix ICE when parsing bad turbofish with lifetime argument

Generalize conditions where we suggest adding the turbofish operator, so we don't ICE during code like

```rust
fn foo() {
  A<'a,>
}
```

but instead suggest adding a turbofish.

Fixes #93282
2022-01-25 23:06:04 +01:00
Matthias Krüger
83cc776d7c
Rollup merge of #93250 - Aaron1011:remove-early-dedup, r=oli-obk
Remove deduplication of early lints

We already have a general mechanism for deduplicating reported
lints, so there's no need to have an additional one for early lints
specifically. This allows us to remove some `PartialEq` impls.
2022-01-25 23:06:00 +01:00
Michael Goulet
37bed05986 delay the bug once again, generalize turbofish suggestion 2022-01-25 11:11:13 -08:00
bors
8cdb3cd94e Auto merge of #93095 - Aaron1011:remove-assoc-ident, r=cjgillot
Store a `Symbol` instead of an `Ident` in `AssocItem`

This is the same idea as #92533, but for `AssocItem` instead
of `VariantDef`/`FieldDef`.

With this change, we no longer have any uses of
`#[stable_hasher(project(...))]`
2022-01-25 18:53:45 +00:00
Michael Goulet
a090bb1dea Remove delayed bug when encountering label in bad turbofish 2022-01-25 10:47:10 -08:00
Camille GILLOT
80132c3ce4
Store hir_id_to_def_id in OwnerInfo. 2022-01-25 15:05:19 -03:00
Nicholas Nethercote
0c17893d49 Rename TypedArenaChunk as ArenaChunk.
Because it's used within both `TypedArena` and `DroplessArena`.

The commit also makes `<u8>` the default parameter.
2022-01-26 01:35:52 +11:00
Deadbeef
8b76cad0a7
Add a minimal working append_const_msg argument 2022-01-26 00:48:08 +11:00
Deadbeef
fdf7d01088
Improve selection errors for ~const trait bounds 2022-01-26 00:48:01 +11:00
Vadim Petrochenkov
00ba815a58 rustdoc: Pre-calculate traits that are in scope for doc links
This eliminates one more late use of resolver
2022-01-25 21:45:21 +08:00
bors
17dfae79bb Auto merge of #93089 - pierwill:rm-outlivesconstraint-ord, r=michaelwoerister
Remove ordering traits from `OutlivesConstraint`

In two cases where this ordering was used, I've replaced the sorting to use a key that does not rely on `DefId` being `Ord`. This is part of #90317. If I understand correctly, whether this is correct depends on whether the `RegionVid`s are tracked during incremental compilation. But I might be mistaken in this approach. cc `@cjgillot`
2022-01-25 08:18:25 +00:00
Matthias Krüger
13b87d8cc7
Rollup merge of #93269 - jacobbramley:dev/pauth-option-1, r=petrochenkov
Use error-on-mismatch policy for PAuth module flags.

This agrees with Clang, and avoids an error when using LTO with mixed
C/Rust. LLVM considers different behaviour flags to be a mismatch,
even when the flag value itself is the same.

This also makes the flag setting explicit for all uses of
LLVMRustAddModuleFlag.

----

I believe that this fixes #92885, but have only reproduced it locally on Linux hosts so cannot confirm that it fixes the issue as reported.

I have not included a test for this because it is covered by an existing test (`src/test/run-make-fulldeps/cross-lang-lto-clang`). It is not without its problems, though:
* The test requires Clang and `--run-clang-based-tests-with=...` to run, and this is not the case on the CI.
   * Any test I add would have a similar requirement.
* With this patch applied, the test gets further, but it still fails (for other reasons). I don't think that affects #92885.
2022-01-25 05:51:14 +01:00
Matthias Krüger
3d6f276ca7
Rollup merge of #93175 - spastorino:negative-traits-coherence-new, r=nikomatsakis
Implement stable overlap check considering negative traits

This PR implement the new disjointness rules for overlap check described in https://rust-lang.github.io/negative-impls-initiative/explainer/coherence-check.html#new-disjointness-rules

r? ``@nikomatsakis``
2022-01-25 05:51:12 +01:00
Matthias Krüger
8dddc86477
Rollup merge of #93144 - wesleywiser:uninhabited_type_code_cov2, r=tmandry
Work around missing code coverage data causing llvm-cov failures

If we do not add code coverage instrumentation to the `Body` of a
function, then when we go to generate the function record for it, we
won't write any data and this later causes llvm-cov to fail when
processing data for the entire coverage report.

I've identified two main cases where we do not currently add code
coverage instrumentation to the `Body` of a function:

  1. If the function has a single `BasicBlock` and it ends with a
     `TerminatorKind::Unreachable`.

  2. If the function is created using a proc macro of some kind.

For case 1, this is typically not important as this most often occurs as
a result of function definitions that take or return uninhabited
types. These kinds of functions, by definition, cannot even be called so
they logically should not be counted in code coverage statistics.

For case 2, I haven't looked into this very much but I've noticed while
testing this patch that (other than functions which are covered by case
1) the skipped function coverage debug message is occasionally triggered
in large crate graphs by functions generated from a proc macro. This may
have something to do with weird spans being generated by the proc macro
but this is just a guess.

I think it's reasonable to land this change since currently, we fail to
generate *any* results from llvm-cov when a function has no coverage
instrumentation applied to it. With this change, we get coverage data
for all functions other than the two cases discussed above.

Fixes #93054 which occurs because of uncallable functions which shouldn't
have code coverage anyway.

I will open an issue for missing code coverage of proc macro generated
functions and leave a link here once I have a more minimal repro.

r? ``@tmandry``
cc ``@richkadel``
2022-01-25 05:51:11 +01:00
Matthias Krüger
c8ede152a5
Rollup merge of #93118 - jackh726:param-heuristics-3, r=estebank
Move param count error emission to end of `check_argument_types`

The error emission here isn't exactly what is done in #92364, but replicating that is hard . The general move should make for a smaller diff.

Also included the `(usize, Ty, Ty)` to -> `Option<(Ty, Ty)>` commit.

r? ``@estebank``
2022-01-25 05:51:10 +01:00
Matthias Krüger
cf7041186c
Rollup merge of #93064 - Aaron1011:provisional-dep-node, r=michaelwoerister
Properly track `DepNode`s in trait evaluation provisional cache

Fixes #92987

During evaluation of an auto trait predicate, we may encounter a cycle.
This causes us to store the evaluation result in a special 'provisional
cache;. If we later end up determining that the type can legitimately
implement the auto trait despite the cycle, we remove the entry from
the provisional cache, and insert it into the evaluation cache.

Additionally, trait evaluation creates a special anonymous `DepNode`.
All queries invoked during the predicate evaluation are added as
outoging dependency edges from the `DepNode`. This `DepNode` is then
store in the evaluation cache - if a different query ends up reading
from the cache entry, it will also perform a read of the stored
`DepNode`. As a result, the cached evaluation will still end up
(transitively) incurring all of the same dependencies that it would
if it actually performed the uncached evaluation (e.g. a call to
`type_of` to determine constituent types).

Previously, we did not correctly handle the interaction between the
provisional cache and the created `DepNode`. Storing an evaluation
result in the provisional cache would cause us to lose the `DepNode`
created during the evaluation. If we later moved the entry from the
provisional cache to the evaluation cache, we would use the `DepNode`
associated with the evaluation that caused us to 'complete' the cycle,
not the evaluatoon where we first discovered the cycle. As a result,
future reads from the evaluation cache would miss some incremental
compilation dependencies that would have otherwise been added if the
evaluation was *not* cached.

Under the right circumstances, this could lead to us trying to force
a query with a no-longer-existing `DefPathHash`, since we were missing
the (red) dependency edge that would have caused us to bail out before
attempting forcing.

This commit makes the provisional cache store the `DepNode` create
during the provisional evaluation. When we move an entry from the
provisional cache to the evaluation cache, we create a *new* `DepNode`
that has dependencies going to *both* of the evaluation `DepNodes` we
have available. This ensures that cached reads will incur all of
the necessary dependency edges.
2022-01-25 05:51:10 +01:00
Eric Holk
f4d7d09902 Disable drop range analysis
The previous PR, #93165, still performed the drop range analysis
despite ignoring the results. Unfortunately, there were ICEs in
the analysis as well, so some packages failed to build (see the
issue #93197 for an example). This change further disables the
analysis and just provides dummy results in that case.
2022-01-24 16:11:33 -08:00
bors
e7825f2b69 Auto merge of #90842 - pierwill:localdefid-indexmap, r=wesleywiser
Use `indexmap` to avoid sorting `LocalDefId`s

See discussion in https://github.com/rust-lang/rust/pull/90408#discussion_r745935459.

Related to work on https://github.com/rust-lang/rust/issues/90317.
2022-01-24 22:04:55 +00:00
Jacob Bramley
e02e9582d2 Use error-on-mismatch policy for PAuth module flags.
This agrees with Clang, and avoids an error when using LTO with mixed
C/Rust. LLVM considers different behaviour flags to be a mismatch,
even when the flag value itself is the same.

This also makes the flag setting explicit for all uses of
LLVMRustAddModuleFlag.
2022-01-24 16:50:10 +00:00
Eduard-Mihai Burtescu
f5a32711dc rustc_errors: add a new assert for the size of PResult<()>. 2022-01-24 15:14:40 +00:00
Jakub Beránek
1ffd043caf
Add test stable hash uniqueness of adjacent field values 2022-01-24 15:35:52 +01:00
bjorn3
f6ce771172 Merge landing_pad and set_cleanup into cleanup_landing_pad 2022-01-24 14:10:05 +01:00
bjorn3
7a164509d3 Merge add_handler into catch_switch
Some codegen backends may require all handlers to be immediately known
2022-01-24 14:10:05 +01:00
bjorn3
e9646fa76b Remove unused return values from resume and cleanup_ret
Given that these instructions are diverging, not every codegen backend
may be able to produce a return value for them.
2022-01-24 13:48:09 +01:00
bjorn3
19dd2ecc2d Reorder unwinding related builder methods to differentiate between dwarf and msvc instructions 2022-01-24 13:45:34 +01:00
Michael Woerister
5e577f71a0 [debuginfo] Fix and unify handling of fat pointers in debuginfo: address review comments. 2022-01-24 13:42:41 +01:00
Michael Woerister
d253e6e473 [debuginfo] Fix and unify handling of fat pointers in debuginfo. 2022-01-24 13:41:32 +01:00
Daniel Henry-Mantilla
b734abcbae Handle unstability as well, including "field typo suggestions" 2022-01-24 13:16:05 +01:00
Eduard-Mihai Burtescu
a8dfa3757c rustc_errors: only box the diagnostic field in DiagnosticBuilder. 2022-01-24 11:23:14 +00:00
bors
d2dc425721 Auto merge of #93014 - Kobzol:revert-92103-stable-hash-skip-zero-bytes, r=the8472
Revert "Do not hash leading zero bytes of i64 numbers in Sip128 hasher"

Reverts rust-lang/rust#92103. It had a (in retrospect, obvious) correctness problem where changing the order of two adjacent values would produce identical hashes, which is problematic in stable hashing (see [this comment](https://github.com/rust-lang/rust/pull/92103#issuecomment-1014625442)).

I'll try to send the PR again with a fix for this issue.

r? `@the8472`
2022-01-24 11:20:01 +00:00
Eduard-Mihai Burtescu
68fa81baa3 rustc_errors: remove allow_suggestions from DiagnosticBuilder. 2022-01-24 10:49:10 +00:00
Jakub Beránek
50f8062316
Revert "Do not hash leading zero bytes of i64 numbers in Sip128 hasher" 2022-01-24 09:07:47 +01:00
bors
ef119d704d Auto merge of #93028 - compiler-errors:const_drop_bounds, r=fee1-dead
Check `const Drop` impls considering `~const` Bounds

 This PR adds logic to trait selection to account for `~const` bounds in custom `impl const Drop` for types, elaborates the `const Drop` check in `rustc_const_eval` to check those bounds, and steals some drop linting fixes from #92922, thanks `@DrMeepster.`

r? `@fee1-dead` `@oli-obk` <sup>(edit: guess I can't request review from two people, lol)</sup>
since each of you wrote and reviewed #88558, respectively.

Since the logic here is more complicated than what existed, it's possible that this is a perf regression. But it works correctly with tests, and that makes me happy.

Fixes #92881
2022-01-24 08:05:37 +00:00
Aaron Hill
58d676b0cc
Remove deduplication of early lints
We already have a general mechanism for deduplicating reported
lints, so there's no need to have an additional one for early lints
specifically. This allows us to remove some `PartialEq` impls.
2022-01-23 17:05:48 -05:00