Commit Graph

232338 Commits

Author SHA1 Message Date
Matthias Krüger
084c87dfea
Rollup merge of #114876 - compiler-errors:non-lifetime-binders-sized, r=wesleywiser
Don't ICE in `is_trivially_sized` when encountering late-bound self ty

We can see a bound ty var here:
b531630f42/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs (L13-L34)

Fixes #114872
2023-08-17 08:39:21 +02:00
Matthias Krüger
f4cd7a537b
Rollup merge of #114749 - gurry:issue-114722, r=thomcc
Update `mpsc::Sender` doc to reflect that it implements `Sync`

Fixes #114722
2023-08-17 08:39:21 +02:00
Matthias Krüger
da541088ef
Rollup merge of #112751 - ehuss:persist-test-run-directory, r=jsha
rustdoc: Fixes with --test-run-directory and relative paths.

Fixes #112191
Fixes #112210

This fixes some issues with `--test-run-directory` and its interaction with `--runtool` and `--persist-doctests`. Relative directories don't work with `Command::current_dir` very well because it has platform-specific behavior with relative paths. This fixes it by avoiding the use of relative paths.

This is needed because cargo is switching to use `--test-run-directory`, and it uses relative paths when interacting with rustdoc/rustc.
2023-08-17 08:39:20 +02:00
bors
aa864a7622 Auto merge of #114875 - Zalathar:line-numbers, r=ozkanonur
coverage: Anonymize line numbers in `run-coverage` test snapshots

LLVM's coverage reporter always prints line numbers in its coverage reports.

For testing purposes this is slightly inconvenient, because it means that adding or removing a line in a test file causes all subsequent lines in the snapshot to change. That makes it harder to see the actually meaningful changes in the re-blessed snapshot.

---

This change fixes that by adding another normalization pass that replaces all line numbers in the coverage reports with `LL`, which is similar to what UI tests tell the compiler to do when emitting line numbers in error messages.
2023-08-17 05:33:42 +00:00
Folyd
9a3dfd7e92
Remove Folyd from librustdoc static files 2023-08-17 12:24:28 +08:00
bors
c5833f1956 Auto merge of #114892 - Zoxc:sharded-cfg-cleanup, r=cjgillot
Remove conditional use of `Sharded` from query caches

`Sharded` is already a zero cost abstraction, so it shouldn't affect the performance of the single thread compiler if LLVM does its job.

r? `@cjgillot`
2023-08-17 01:04:38 +00:00
Zalathar
bfb16545a3 coverage: Anonymize line numbers in run-coverage test snapshots
This makes the test snapshots less sensitive to lines being added/removed.
2023-08-17 10:03:32 +10:00
bors
f3b4c6746a Auto merge of #111555 - cjgillot:elaborate-drops, r=tmiasko
Only run MaybeInitializedPlaces dataflow once to elaborate drops

This pass allows forward dataflow analyses to modify the CFG depending on the dataflow state. This possibility is used for the `MaybeInitializedPlace` analysis in drop elaboration, to skip the dataflow effect of dead unwinds without having to compute dataflow twice.
2023-08-16 23:21:17 +00:00
Nicholas Nethercote
e46caaf84b Simplify a match.
`may_be_ident` is true for `NtPath` and `NtMeta`, so we don't need to
check for them separately.
2023-08-17 09:06:03 +10:00
Nicholas Nethercote
9a3c907bdb Make some matches exhaustive in nonterminal.rs.
For ones matching more than one or two variants, this is easier to think
about.
2023-08-17 09:05:37 +10:00
Nicholas Nethercote
f8a21a5df0 Use Nonterminal::* in nonterminal.rs.
It makes the code more readable.
2023-08-17 09:05:07 +10:00
Nicholas Nethercote
acd3a5e35f Remove unnecessary braces on PatWithOr patterns. 2023-08-17 09:04:54 +10:00
Nicholas Nethercote
4ab3e9d5b9 Add a failing case to tests/ui/macros/macro-interpolation.
This test currently tests the successful paths for the
`Interpolated`/`NtTy`/`Path` case in `parse_path_inner`, but it doesn't
test the failure path.
2023-08-17 09:03:58 +10:00
Nicholas Nethercote
e8f733370f Add some useful comments to Parser::look_ahead. 2023-08-17 09:03:56 +10:00
Nicholas Nethercote
04cf6b4ac5 Rename parse_no_question_mark_recover.
Adding a `ty_` makes its purpose much clearer, and consistent with other
`parse_ty_*` functions.
2023-08-17 09:01:12 +10:00
Nicholas Nethercote
3bb85b73b5 Add helpful comments to tt_prepend_space. 2023-08-17 09:01:05 +10:00
Nicholas Nethercote
434bfc3162 Remove outdated comment.
All nonterminals collect and store tokens now. (Unless they are very
simple, e.g. single-token, and can precisely recover them without
collecting.)
2023-08-17 08:26:56 +10:00
Nicholas Nethercote
9de696b39f Remove some unnecessary (and badly named) local variables. 2023-08-17 08:26:55 +10:00
bors
07438b0928 Auto merge of #108693 - Zoxc:arena-opt-funcs, r=cjgillot
Optimize DroplessArena arena allocation

This optimizes `DroplessArena` allocation by always ensuring that it is aligned to `usize` and adding `grow_and_alloc` and `grow_and_alloc_raw`functions which both grow and allocate, reducing code size.

<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">1.6968s</td><td align="right">1.6887s</td><td align="right"> -0.48%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2552s</td><td align="right">0.2551s</td><td align="right"> -0.03%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">0.9613s</td><td align="right">0.9553s</td><td align="right"> -0.62%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.5402s</td><td align="right">1.5374s</td><td align="right"> -0.18%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check</td><td align="right">5.9175s</td><td align="right">5.8813s</td><td align="right"> -0.61%</td></tr><tr><td>Total</td><td align="right">10.3710s</td><td align="right">10.3178s</td><td align="right"> -0.51%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9962s</td><td align="right"> -0.38%</td></tr></table>
2023-08-16 21:37:13 +00:00
Michael Goulet
2cc71ba881 Normalize return type of deduce_future_output_from_obligations 2023-08-16 14:28:19 -07:00
beetrees
072d8c8bbc
Fix suggestion for attempting to define a string with single quotes 2023-08-16 21:51:57 +01:00
bors
27fb598d51 Auto merge of #114905 - matthiaskrgr:rollup-uxhhr7p, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #113115 (we are migrating to askama)
 - #114784 (Improve `invalid_reference_casting` lint)
 - #114822 (Improve code readability by moving fmt args directly into the string)
 - #114878 (rustc book: make more pleasant to search)
 - #114899 (Add missing Clone/Debug impls to SMIR Trait related tys)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-16 19:51:47 +00:00
Camille GILLOT
5b2524eb03 Do not pre-compute reachable blocks. 2023-08-16 19:40:46 +00:00
Camille GILLOT
f5e4eb91b7 Use Terminator::edges for backward analysis too. 2023-08-16 19:40:46 +00:00
Camille GILLOT
94c5ea350f Update doc comment. 2023-08-16 18:15:49 +00:00
Camille GILLOT
b8fed2f21c Make dataflow const-prop handle_switch_int monotonic. 2023-08-16 18:12:18 +00:00
Camille GILLOT
e9990ce89c Only evaluate yield place after resume in liveness. 2023-08-16 18:12:18 +00:00
Camille GILLOT
7ded3409b8 Specify that method only applies statement effects. 2023-08-16 18:12:18 +00:00
Camille GILLOT
aa697f599e Rename YieldResumeEffect. 2023-08-16 18:12:18 +00:00
Camille GILLOT
388f6a6413 Make TerminatorEdge plural. 2023-08-16 18:12:18 +00:00
Camille GILLOT
6cf15d4cb5 Rename MaybeUnreachable. 2023-08-16 18:12:18 +00:00
Camille GILLOT
f19cd3f2e1 Use TerminatorEdge for dataflow-const-prop. 2023-08-16 18:12:18 +00:00
Camille GILLOT
3acfa092db Only run MaybeInitializedPlaces once for drop elaboration. 2023-08-16 18:12:18 +00:00
Camille GILLOT
5173d85043 Allow apply_terminator_effect to customize edges. 2023-08-16 18:12:17 +00:00
Camille GILLOT
32711b2b4e Introduce MaybeUnreachable. 2023-08-16 18:12:17 +00:00
Camille GILLOT
934a99eb65 Move domain_size to GenKillAnalysis. 2023-08-16 18:12:17 +00:00
Camille GILLOT
8726cbc75f Move initialization dataflow impls into their own module. 2023-08-16 18:12:17 +00:00
Camille GILLOT
760881b29d Create bottom on-the-fly instead of cloning it. 2023-08-16 18:12:17 +00:00
Camille GILLOT
9c97abd54c Simplify for_each_mut_borrow. 2023-08-16 18:12:17 +00:00
Matthias Krüger
f6c20ad131
Rollup merge of #114899 - spastorino:add-missing-debug, r=compiler-errors
Add missing Clone/Debug impls to SMIR Trait related tys

r? `@compiler-errors`
2023-08-16 20:10:38 +02:00
Matthias Krüger
82b92ad738
Rollup merge of #114878 - tshepang:tshepang-patch-1-1, r=davidtwco
rustc book: make more pleasant to search
2023-08-16 20:10:38 +02:00
Matthias Krüger
6533929ae0
Rollup merge of #114822 - GuillaumeGomez:code-readability-improvement, r=notriddle
Improve code readability by moving fmt args directly into the string

There are some of occurrences where I also transformed `write!(f, "{}", x)` into `f.write_str(x.as_str())`.

r? `@notriddle`
2023-08-16 20:10:38 +02:00
Matthias Krüger
2667d853a6
Rollup merge of #114784 - Urgau:many-improve-invalid_reference_casting-lint, r=est31
Improve `invalid_reference_casting` lint

This PR improves the `invalid_reference_casting` lint:
 - by considering an unlimited number of casts instead only const to mut ptr
 - by also considering ptr-to-integer and integer-to-ptr casts
 - by also taking into account [`ptr::cast`](https://doc.rust-lang.org/std/primitive.pointer.html#method.cast), [`ptr::cast`](https://doc.rust-lang.org/std/primitive.pointer.html#method.cast-1) and [`ptr::cast_const`](https://doc.rust-lang.org/std/primitive.pointer.html#method.cast_const)

Most of this improvements comes from skimming Github Code Search result for [`&mut \*.*as \*const`](https://github.com/search?q=lang%3Arust+%2F%26mut+%5C*.*as+%5C*const%2F&type=code)

r? ``@est31`` (maybe)
2023-08-16 20:10:37 +02:00
Matthias Krüger
52d69476a6
Rollup merge of #113115 - tshepang:patch-5, r=est31
we are migrating to askama

see https://github.com/rust-lang/rust/issues/108868
2023-08-16 20:10:37 +02:00
bors
ce01f4d2e0 Auto merge of #114617 - petrochenkov:docspacing, r=Mark-Simulacrum
proc_macro: Update docs for `Spacing`

Brings the docs more in line with reality
2023-08-16 17:56:14 +00:00
bors
6249c70dbb Auto merge of #3027 - ttsugriy:range-map, r=RalfJung
Avoid unnecessary Vec resize.

If `size > 0` current implementation will first create an empty vec and then push an element into it, which will cause a resize that can be easily avoided.

It's obviously not a big deal, but this also gets rid of `mut` local variable.
2023-08-16 17:13:42 +00:00
Taras Tsugrii
ac0a8ca40d Avoid unnecessary Vec resize.
If `size > 0` current implementation will first create an empty
vec and then push an element into it, which will cause a resize
that can be easily avoided.

It's obviously not a big deal, but this also gets rid of `mut`
local variable.
2023-08-16 10:05:14 -07:00
Santiago Pastorino
66573b5781
Add missing Clone/Debug impls to SMIR Trait related tys 2023-08-16 13:10:52 -03:00
Josh Triplett
5210f482d7 Partially revert #107200
`Ok(0)` is indeed something the caller may interpret as an error, but
that's the *correct* thing to return if the writer can't accept any more
bytes.
2023-08-16 09:00:16 -07:00
bors
c94cb834d0 Auto merge of #112500 - lukas-code:span-ctxt, r=petrochenkov
Fix argument removal suggestion around macros

Fixes #112437.
Fixes #113866.
Helps with #114255.

The issue was that `span.find_ancestor_inside(outer)` could previously return a span with a different expansion context from `outer`.

This happens for example for the built-in macro `panic!`, which expands to another macro call of `panic_2021!` or `panic_2015!`. Because the call site of `panic_20xx!` has not associated source code, its span currently points to the call site of `panic!` instead.

Something similar also happens items that get desugared in AST->HIR lowering. For example, `for` loops get two spans: One "inner" span that has the `.desugaring_kind()` kind set to `DesugaringKind::ForLoop` and one "outer" span that does not. Similar to the macro situation, both of these spans point to the same source code, but have different expansion contexts.

This causes problems, because joining two spans with different expansion contexts will usually[^1] not actually join them together to avoid creating "spaghetti" spans that go from the macro definition to the macro call. For example, in the following snippet `full_span` might not actually contain the `adjusted_start` and `adjusted_end`. This caused the broken suggestion / debug ICE in the linked issues.
```rust
let adjusted_start = start.find_ancestor_inside(shared_ancestor);
let adjusted_end = end.find_ancestor_inside(shared_ancestor);
let full_span = adjusted_start.to(adjusted_end)
```

To fix the issue, this PR introduces a new method, `find_ancestor_inside_same_ctxt`, which combines the functionality of `find_ancestor_inside` and `find_ancestor_in_same_ctxt`: It finds an ancestor span that is contained within the parent *and* has the same syntax context, and is therefore safe to extend. This new method should probably be used everywhere, where the returned span is extended, but for now it is just used for the argument removal suggestion.

Additionally, this PR fixes a second issue where the function call itself is inside a macro but the arguments come from outside the macro. The test is added in the first commit to include stderr diff, so this is best reviewed commit by commit.

[^1]: If one expansion context is the root context and the other is not.
2023-08-16 14:47:01 +00:00