Commit Graph

28658 Commits

Author SHA1 Message Date
Gurinder Singh
66e643d0f8 Fix duplicate note on internal feature gate
The BuiltinInternalFeatures gate already has a struct level #[note]
attribute. The additional note field in it caused a duplicate to be
displayed when it was set to Some(...) which happened when the
feature had an associated issue
2023-10-12 07:22:41 +05:30
bors
36cbf944b3 Auto merge of #116621 - aliemjay:rollup-0e2of3c, r=aliemjay
Rollup of 4 pull requests

Successful merges:

 - #95967 (Add explicit-endian String::from_utf16 variants)
 - #116530 (delay a bug when encountering an ambiguity in MIR typeck)
 - #116611 (Document `diagnostic_namespace` feature)
 - #116612 (Remove unused dominator iterator)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-11 01:49:27 +00:00
Ali MJ Al-Nasrawy
88a929ba32
Rollup merge of #116612 - tmiasko:rm-dom-iter, r=cjgillot
Remove unused dominator iterator
2023-10-11 03:53:18 +03:00
Ali MJ Al-Nasrawy
a7042a94a3
Rollup merge of #116530 - aliemjay:ice-on-ambiguity, r=compiler-errors
delay a bug when encountering an ambiguity in MIR typeck

We shouldn't have any trait selection ambiguities in MIR typeck.

See https://github.com/rust-lang/rust/pull/114586#issuecomment-1751967321

r? `@oli-obk` `@compiler-errors` `@lcnr`
2023-10-11 03:53:17 +03:00
bors
dcf89f43a5 Auto merge of #116578 - antoyo:subtree-update_cg_gcc_2023-10-09, r=bjorn3
subtree update cg_gcc 2023/10/09
2023-10-11 00:04:04 +00:00
bors
d627cf07ce Auto merge of #113915 - cjgillot:ssa-call, r=tmiasko
Also consider call and yield as MIR SSA.

The SSA analysis on MIR only considered `Assign` statements as defining a SSA local.
This PR adds assignments as part of a `Call` or `Yield` terminator in that category.

This mainly allows to perform CopyProp on a call return place.

The only subtlety is in the dominance property: the assignment is only complete at the beginning of the target block.
2023-10-10 20:37:55 +00:00
Tomasz Miąsko
b61a6d59e4 Remove unused dominator iterator 2023-10-10 21:39:59 +02:00
Guillaume Gomez
100713ef08
Rollup merge of #116560 - ouz-a:efficient_ids, r=oli-obk
In smir use `FxIndexMap` to store indexed ids

Previously we used `vec` for storing indexed types, which is fine for small cases but will lead to huge performance issues when we use `smir` for real world cases.

Addresses https://github.com/rust-lang/project-stable-mir/issues/35

r? ``@oli-obk``
2023-10-10 18:44:46 +02:00
Guillaume Gomez
0e5e04b89a
Rollup merge of #116250 - estebank:closure-arg-inference-span, r=petrochenkov
On type error of closure call argument, point at earlier calls that affected inference

Mitigate part of  https://github.com/rust-lang/rust/issues/71209.

When we encounter a type error on a specific argument of a closure call argument, where the closure's definition doesn't have a type specified, look for other calls of the closure to try and find the specific call that cased that argument to be inferred of the expected type.

```
error[E0308]: mismatched types
  --> $DIR/unboxed-closures-type-mismatch.rs:30:18
   |
LL |         identity(1u16);
   |         -------- ^^^^ expected `u8`, found `u16`
   |         |
   |         arguments to this function are incorrect
   |
note: expected because the closure was earlier called with an argument of type `u8`
  --> $DIR/unboxed-closures-type-mismatch.rs:29:18
   |
LL |         identity(1u8);
   |         -------- ^^^ expected because this argument is of type `u8`
   |         |
   |         in this closure call
note: closure parameter defined here
  --> $DIR/unboxed-closures-type-mismatch.rs:28:25
   |
LL |         let identity = |x| x;
   |                         ^
help: change the type of the numeric literal from `u16` to `u8`
   |
LL |         identity(1u8);
   |                   ~~
```
2023-10-10 18:44:44 +02:00
bors
5b88d659f8 Auto merge of #116598 - matthiaskrgr:rollup-6xra4jx, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #116586 (use env variable to control thread ids in rustc_log)
 - #116589 (coverage: Unbox and simplify `bcb_filtered_successors`)
 - #116595 (-Zmir-enable-passes: document that this may enable unsound passes)
 - #116596 (reorder files in solve)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-10 13:29:09 +00:00
Matthias Krüger
da42858b14
Rollup merge of #116596 - lcnr:normalize-subdir, r=compiler-errors
reorder files in solve

r? `@compiler-errors`
2023-10-10 14:07:48 +02:00
Matthias Krüger
de4980cf44
Rollup merge of #116595 - RalfJung:mir-enable-passes, r=oli-obk
-Zmir-enable-passes: document that this may enable unsound passes

also add some comments explaining why MIR opts are marked as unsound
2023-10-10 14:07:48 +02:00
Matthias Krüger
f4de82c2b3
Rollup merge of #116589 - Zalathar:successors, r=oli-obk
coverage: Unbox and simplify `bcb_filtered_successors`

This is a small cleanup in the coverage instrumentor's graph-building code.

---
This function already has access to the MIR body, so instead of taking a reference to a terminator, it's simpler and easier to pass in a basic block index.

There is no need to box the returned iterator if we instead add appropriate lifetime captures, and make `short_circuit_preorder` generic over the type of iterator it expects.

We can also greatly simplify the function's implementation by observing that the only difference between its two cases is whether we take all of a BB's successors, or just the first one.

---

`@rustbot` label +A-code-coverage
2023-10-10 14:07:47 +02:00
Matthias Krüger
0bc5696dd9
Rollup merge of #116586 - SparrowLii:parallel_log, r=oli-obk
use env variable to control thread ids in rustc_log

Currently, when parallel rustc is enabled, even if the number of threads is 1, the thread ID will be included before all the logs.
E.g.
`WARN rustc_mir_build::thir::pattern::const_to_pat ...`
=>
`2:rustcWARN rustc_mir_build::thir::pattern::const_to_pat ...`
This makes the logs confusing and results in inconsistent UI test results for serial and parallel rustc. Therefore I think we should let users decide whether thread id information is needed through explicit control.
2023-10-10 14:07:47 +02:00
bors
061c33051a Auto merge of #116551 - RalfJung:nondet-nan, r=oli-obk
miri: make NaN generation non-deterministic

This implements the [LLVM semantics for NaN generation](https://llvm.org/docs/LangRef.html#behavior-of-floating-point-nan-values). I will soon submit an RFC to make this also officially the Rust semantics, but it has been our de-facto semantics for a long time so there's no reason Miri has to wait for that RFC. This PR just better aligns Miri with codegen.

This PR does that just for the operations that have MIR primitives; a future PR will adjust the intrinsics.
2023-10-10 11:42:27 +00:00
Oğuz Ağcayazı
0bcb058fb1 add new wrapper for FxIndexMap 2023-10-10 13:18:31 +03:00
lcnr
c70ef36f2c reorder files in solve 2023-10-10 09:55:22 +00:00
bors
5c37696f60 Auto merge of #116409 - Zalathar:span-extraction, r=oli-obk
coverage: Separate initial span extraction from span processing

One of the main subtasks of coverage instrumentation is looking through MIR to determine a list of source code spans that require coverage counters.

That task is in turn subdivided into a few main steps:
- Getting the initial spans from MIR statements/terminators
- Processing the list of spans to merge or truncate nearby spans as necessary
- Grouping the processed spans by their corresponding coverage graph node

---

This PR enforces a firmer separation between the first two steps (span extraction and span processing), which ends up slightly simplifying both steps, since they don't need to deal with state that is only meaningful for the other step.

---

`@rustbot` label +A-code-coverage
2023-10-10 09:55:15 +00:00
Ralf Jung
d805b265db add some comments explaining why MIR opts are marked as unsound 2023-10-10 11:17:27 +02:00
Ralf Jung
2de454637f -Zmir-enable-passes: document that this may enable unsound passes 2023-10-10 11:08:47 +02:00
bors
091bb74e7e Auto merge of #116548 - nnethercote:assert-long-condition, r=matthewjasper
Improve handling of assertion failures with very long conditions

It's not perfectly clear what the best behaviour is here, but I think this is an improvement.

r? `@matthewjasper`
cc `@m-ou-se`
2023-10-10 08:02:20 +00:00
Zalathar
5d629457fd coverage: Unbox and simplify bcb_filtered_successors
This function already has access to the MIR body, so instead of taking a
reference to a terminator, it's simpler and easier to pass in a basic block
index.

There is no need to box the returned iterator if we instead add appropriate
lifetime captures, since `short_circuit_preorder` is now generic over the type
of iterator it expects.

We can also greatly simplify the function's implementation by observing that
the only difference between its two cases is whether we take all of a BB's
successors, or just the first one.
2023-10-10 18:45:29 +11:00
Zalathar
f214497d22 coverage: Replace ShortCircuitPreorder with a single function
Instead of defining a named struct, we can use `std::iter::from_fn` and store
intermediate state in a closure.
2023-10-10 18:44:16 +11:00
bors
84d44dd1d8 Auto merge of #116366 - estebank:issue-103982, r=oli-obk
Suggest labeling block if `break` is in bare block

Fix #103982.
2023-10-10 06:04:08 +00:00
Zalathar
6c44425e98 coverage: Remove enum CoverageStatement
This enum was mainly needed to track the precise origin of a span in MIR, for
debug printing purposes. Since the old debug code was removed in #115962, we
can replace it with just the span itself.
2023-10-10 13:39:23 +11:00
Zalathar
4b471df25d coverage: Disconnect span extraction from CoverageSpansGenerator
By performal initial span extraction in a separate free function, we can remove
some accidental complexity from the main generator code.
2023-10-10 13:39:23 +11:00
Zalathar
972ab8863d coverage: Move initial MIR span extraction into a submodule 2023-10-10 13:39:23 +11:00
SparrowLii
2dcc828863 use env variable to control thread ids in rustc_log 2023-10-10 09:39:47 +08:00
Esteban Küber
d23dc2093c Account for macros 2023-10-09 22:48:10 +00:00
Nicholas Nethercote
7528fdc4c4 Don't escape_debug the condition of assert!.
The assertion in `assert-long-condition.rs` used to be fail like this, all on
one line:
```
thread 'main' panicked at 'assertion failed: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18\n                                + 19 + 20 + 21 + 22 + 23 + 24 + 25 == 0', tests/ui/macros/assert-long-condition.rs:7:5
```
The `\n` and subsequent indent is because the condition is pretty-printed, and
the pretty-printer inserts a newline. Printing the newline in this way is
arguably reasonable given that the message appears within single quotes, which
is very similar to a string literal.

However, after the assertion printing improvements that were released in 1.73,
the assertion now fails like this:
```
thread 'main' panicked at tests/ui/macros/assert-long-condition.rs:7:5:
assertion failed: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18\n                                + 19 + 20 + 21 + 22 + 23 + 24 + 25 == 0
```
Now that there are no single quotes around the pretty-printed condition, the
`\n` is quite strange.

This commit gets rid of the `\n`, by removing the `escape_debug` done on the
pretty-printed message. This results in the following:
```
thread 'main' panicked at tests/ui/macros/assert-long-condition.rs:7:5:
assertion failed: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18
                                + 19 + 20 + 21 + 22 + 23 + 24 + 25 == 0
```
The overly-large indent is still strange, but that's a separate pretty-printing issue.

This change helps with #108341.
2023-10-10 09:08:11 +11:00
Antoni Boucher
06c5ac4761 Use IntoDynSyncSend 2023-10-09 17:13:35 -04:00
bors
59edd67056 Auto merge of #116497 - compiler-errors:impl-span, r=cjgillot
Extend `impl`'s `def_span` to include its where clauses

Typically, we highlight the def-span of an impl in a diagnostic due to either:
1. coherence error
2. trait evaluation cycle
3. invalid implementation of built-in trait

I find that an impl's where clauses are very often required to understanding why these errors come about, which is unfortunate since where clauses may be located on different lines and don't show up in the error. This PR expands the def-span of impls to include these where clauses.

r? cjgillot since you've touched this code a while back to make some spans shorter, but you can also reassign to wg-diagnostics or compiler if you're busy or have no strong opinions.
2023-10-09 21:03:41 +00:00
Antoni Boucher
2cbac9c636 Fix checks 2023-10-09 16:03:05 -04:00
Antoni Boucher
30290c8b41 Merge commit '11a0cceab966e5ff1058ddbcab5977e8a1d6d290' into subtree-update_cg_gcc_2023-10-09 2023-10-09 15:53:34 -04:00
Esteban Küber
daac011459 Suggest labeling block if break is in bare block
Fix #103982.
2023-10-09 19:24:05 +00:00
Matthias Krüger
ea5cac02e8
Rollup merge of #116556 - bjorn3:sync_cg_clif-2023-10-09, r=bjorn3
Sync rustc_codegen_cranelift

The highlights this time are improved simd and inline asm support, `is_x86_feature_detected!()` returning the actual cpu features when inline asm support is enabled and a couple of bug fixes.

r? ```@ghost```

```@rustbot``` label +A-codegen +A-cranelift +T-compiler +subtree-sync
2023-10-09 16:26:02 +02:00
Matthias Krüger
148f5c1bdf
Rollup merge of #116549 - DaniPopes:miropts-let-chains, r=oli-obk
Simplify some mir passes by using let chains
2023-10-09 16:26:02 +02:00
Matthias Krüger
2266e79421
Rollup merge of #116543 - ouz-a:crate_return_vec, r=oli-obk
In smir `find_crates` returns `Vec<Crate>` instead of `Option<Crate>`

Addresses https://github.com/rust-lang/project-stable-mir/issues/40

r? `@oli-obk`
2023-10-09 16:26:01 +02:00
Matthias Krüger
374c885f4a
Rollup merge of #116537 - gurry:116473-ice-sugg-overlap, r=compiler-errors
Fix suggestion span involving wrongly placed generic arg on variant

Fixes #116473

The span computation was wrong. It went from the end of the variant to the end of the (wrongly placed) args. However, the variant lived in a different expansion and this resulted in a nonsensical span that overlaps with another and thereby leads to the ICE.

In the fix I've changed span computation to not be based on the location of the variant, but purely on the location of the args. I simply extend the start of the args span 2 positions to the left and that includes the `::` and that's all we need apparently.

This approach produces a correct span regardless of which macro/expansion the args reside in and where the variant is.
2023-10-09 16:26:01 +02:00
Matthias Krüger
389747c41d
Rollup merge of #115882 - aliemjay:diag-name-region-1, r=compiler-errors
improve the suggestion of `generic_bound_failure`

- Fixes #115375
- suggest the bound in the correct scope: trait or impl header vs assoc item. See `tests/ui/suggestions/lifetimes/type-param-bound-scope.rs`
- don't suggest a lifetime name that conflicts with the other late-bound regions of the function:
```rust
type Inv<'a> = *mut &'a ();
fn check_bound<'a, T: 'a>(_: T, _: Inv<'a>) {}
fn test<'a, T>(_: &'a str, t: T, lt: Inv<'_>) { // suggests a new name `'a`
    check_bound(t, lt); //~ ERROR
}
```
2023-10-09 16:26:00 +02:00
Michael Goulet
592163fb71 Extend impl's def_span to include where clauses 2023-10-09 11:47:02 +00:00
Oğuz Ağcayazı
77df2cd9a5 spans are now indexmapped 2023-10-09 13:03:58 +03:00
Oğuz Ağcayazı
5f079dd2ff alloc id is indexmapped 2023-10-09 12:58:41 +03:00
Oğuz Ağcayazı
0f27c1b5b5 defids are indexmapped 2023-10-09 12:56:14 +03:00
bjorn3
169055f2ff Merge commit '81dc066758ec150b43822d4a0c84aae20fe10f40' into sync_cg_clif-2023-10-09 2023-10-09 08:52:46 +00:00
Oğuz Ağcayazı
4ff6e87a8c return crates instead of a crate 2023-10-09 10:33:23 +03:00
Ralf Jung
08deb0daed float-to-float casts also have non-deterministic NaN results 2023-10-09 08:30:34 +02:00
bors
093b9d5b29 Auto merge of #116533 - cjgillot:skip-trivial-mir, r=oli-obk
Do not run optimizations on trivial MIR.

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

The bug was introduced in https://github.com/rust-lang/rust/pull/110728, which put the check too early in the query chain.

cc `@oli-obk` `@ouz-a`
2023-10-09 06:00:23 +00:00
Ralf Jung
615d738abe ensure unary minus propagates NaN payloads exactly 2023-10-09 07:37:24 +02:00
DaniPopes
47ebffabb8
Simplify some mir passes by using let chains 2023-10-09 05:22:31 +02:00