Commit Graph

28855 Commits

Author SHA1 Message Date
Esteban Küber
890e92feed Unify suggestion wording 2023-10-17 17:33:55 +00:00
Esteban Küber
6cf01fcf1e review comments + more tests 2023-10-17 17:33:08 +00:00
Esteban Küber
5cc9216ff3 Properly account for self ty in method disambiguation suggestion
Fix #116703.
2023-10-17 17:33:08 +00:00
bors
616e37919c Auto merge of #116756 - fee1-dead-contrib:dupe-those-bounds, r=oli-obk
Duplicate `~const` bounds with a non-const one in effects desugaring

This should unblock #116058.

r? `@oli-obk`
2023-10-17 12:16:54 +00:00
bors
631a116cd3 Auto merge of #116822 - notriddle:notriddle/rust-logo, r=fmease
docs: add Rust logo to more compiler crates

c6e6ecb1af added it to some of the compiler's crates, but avoided adding it to all of them to reduce bit-rot. This commit adds to more.

r? `@GuillaumeGomez`
2023-10-17 04:41:20 +00:00
bors
c07693c160 Auto merge of #116477 - nnethercote:tidy-alpha-deps, r=wesleywiser
Use tidy to enforce alphabetical dependency ordering

I get annoyed when dependencies in `Cargo.toml` files are not in alphabetical order. The [style guide](https://github.com/rust-lang/rust/blob/master/src/doc/style-guide/src/cargo.md) agrees with me.

There are ongoing efforts to provide linting/formatting of `Cargo.toml` files, e.g. https://github.com/rust-lang/rustfmt/pull/5240, https://crates.io/crates/cargo-toml-lint, and https://github.com/TimonPost/cargo-toml-format. But it's far from clear what's the right approach.

So this PR does something very simple: it uses the order checking already present in tidy. This allows incremental application of ordering, starting right now, and avoiding the need for any kind of all-at-once conversion.

If we do end up using some more comprehensive `Cargo.toml` linting/formatting solution in the future, the `tidy-alphabetical` lines will be easy to remove.

r? `@wesleywiser`
2023-10-17 02:48:03 +00:00
bors
39164b84e0 Auto merge of #116826 - nnethercote:fix-116780-116797, r=compiler-errors
Fix a performance regression in obligation deduplication.

Commit 8378487 from #114611 changed the location of an obligation deduplication step in `opt_normalize_projection_type`. This meant that deduplication stopped happening on one path where it was still necessary, causing a couple of drastic performance regressions.

This commit moves the deduplication back to the old location. The good news is that #114611 had four commits and 8378487 was of minimal importance, so the perf benefits from that PR remain.

Fixes #116780, #116797.

r? `@compiler-errors`
2023-10-17 00:53:53 +00:00
Nicholas Nethercote
91f2fbc867 Fix a performance regression in obligation deduplication.
Commit 8378487 from #114611 changed the location of an obligation
deduplication step in `opt_normalize_projection_type`. This meant that
deduplication stopped happening on one path where it was still
necessary, causing a couple of drastic performance regressions.

This commit moves the deduplication back to the old location. The good
news is that #114611 had four commits and 8378487 was of minimal
importance, so the perf benefits from that PR remain.

Fixes #116780, #116797.
2023-10-17 11:02:59 +11:00
Michael Howell
2ff2624722 docs: add Rust logo to more compiler crates
c6e6ecb1af added it to some of the
compiler's crates, but avoided adding it to all of them to reduce
bit-rot. This commit adds to more.
2023-10-16 15:38:08 -07:00
Guillaume Gomez
05e2056746
Rollup merge of #116811 - narpfel:unpretty-unicode-escape-in-format-string-literal, r=Nilstrieb
Preserve unicode escapes in format string literals when pretty-printing AST

Fixes #116799

Thanks to `@Nilstrieb` for the pointer to the correct location, that was really helpful for someone unfamiliar with the codebase.
2023-10-16 23:58:06 +02:00
Guillaume Gomez
347f7f3bf4
Rollup merge of #116805 - Nilstrieb:onunimplemented-std-core-alloc-whatever-who-cares, r=compiler-errors
Make `rustc_onunimplemented` export path agnostic

This makes it so that all the matchers that match against paths use the definition path instead of the export path. This removes all duplication around `std`/`alloc`/`core`.

This is not necessarily optimal because we now depend on internal implementation details like `core::ops::control_flow::ControlFlow`, which is not very nice and probably not acceptable for a stable `on_unimplemented`.

An alternative would be to just string-replace normalize away `alloc`/`core` to `std` as a special case, keeping the export paths but making it so that we're still fully standard library flavor agnostic.

Looking at the diff, I'm starting to think that some simple string replacement would go a long way towards fixing the problem of duplication while keeping export paths...

What do you prefer?

Also `@weiznich` for your thoughts about the stable version.

r? compiler-errors
2023-10-16 23:58:05 +02:00
Guillaume Gomez
d0ade3f1ba
Rollup merge of #116800 - compiler-errors:rpitit-gat-outlives, r=jackh726
Fix implied outlives check for GAT in RPITIT

We enforce certain `Self: 'lt` bounds for GATs to save space for more sophisticated implied bounds, but those currently operate on the HIR. Code was easily reworked to operate on def-ids so that we can properly let these suggestions propagate through synthetic associated types like RPITITs and AFITs.

r? `@jackh726` or `@aliemjay`

Fixes #116789
2023-10-16 23:58:04 +02:00
Guillaume Gomez
581f88deda
Rollup merge of #116754 - Zalathar:spans, r=oli-obk
coverage: Several small cleanups in `spans`

While investigating the details of coverage span processing, I noticed several opportunities to make the code simpler and clearer.

---

`@rustbot` label +A-code-coverage
2023-10-16 23:58:03 +02:00
Paul Gey
587899e9ca Preserve unicode escapes in format string literals when pretty-printing AST 2023-10-16 21:20:21 +02:00
bors
a76ec181fb Auto merge of #116804 - matthiaskrgr:rollup-m2qm8ul, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #114157 (Enable triagebot no-merges check)
 - #116257 (Suggest trait bounds for used associated type on type param)
 - #116430 (vendoring in tarball sources)
 - #116709 (Update minifier version to 0.2.3)
 - #116786 (Update my mailmap entry)
 - #116790 (opt-dist: disable unused features for tabled crate)
 - #116802 (Remove `DefiningAnchor::Bubble` from opaque wf check)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-16 18:57:44 +00:00
Nilstrieb
414135d522 Make rustc_onunimplemented export path agnostic
This makes it so that all the matchers that match against paths use the
definition path instead of the export path. This removes all duplication
around `std`/`alloc`/`core`.

This is not necessarily optimal because we now depend on internal
implementation details like `core::ops::control_flow::ControlFlow`,
which is not very nice and probably not acceptable for a stable
`on_unimplemented`.

An alternative would be to just string-replace normalize away
`alloc`/`core` to `std` as a special case, keeping the export paths but
making it so that we're still fully standard library flavor agnostic.
2023-10-16 19:37:12 +02:00
Matthias Krüger
b0572f1a12
Rollup merge of #116802 - compiler-errors:anchor-opaque-wf, r=oli-obk
Remove `DefiningAnchor::Bubble` from opaque wf check

Set the defining anchor to `DefiningAnchor::Bind(parent_def_id)` where `parent_def_id` is the first parent def-id that isn't an opaque.

This "fixes" some of the nested-return-type wf tests. If we *do* want these to be hard-errors for TAITs, we should probably make those error separately from this check (i.e. via some check like the code in the `OPAQUE_HIDDEN_INFERRED_BOUND` lint). The fact that some of these tests fail but not all of them seems kinda coincidental.

r? oli-obk
2023-10-16 19:10:51 +02:00
Matthias Krüger
14663e09b7
Rollup merge of #116257 - estebank:issue-101351, r=b-naber
Suggest trait bounds for used associated type on type param

Fix #101351.

When an associated type on a type parameter is used, and the type parameter isn't constrained by the correct trait, suggest the appropriate trait bound:

```
error[E0220]: associated type `Associated` not found for `T`
 --> file.rs:6:15
  |
6 |     field: T::Associated,
  |               ^^^^^^^^^^ there is a similarly named associated type `Associated` in the trait `Foo`
  |
help: consider restricting type parameter `T`
  |
5 | struct Generic<T: Foo> {
  |                 +++++
  ```

When an associated type on a type parameter has a typo, suggest fixing
it:

```
error[E0220]: associated type `Baa` not found for `T`
  --> $DIR/issue-55673.rs:9:8
   |
LL |     T::Baa: std::fmt::Debug,
   |        ^^^ there is a similarly named associated type `Bar` in the trait `Foo`
   |
help: change the associated type name to use `Bar` from `Foo`
   |
LL |     T::Bar: std::fmt::Debug,
   |        ~~~
```
2023-10-16 19:10:49 +02:00
bors
4af886f8ab Auto merge of #116731 - Alexendoo:hash-untracked-state, r=oli-obk
Add `Config::hash_untracked_state` callback

For context, I'm looking to use [late module passes](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/context/struct.LintStore.html#structfield.late_module_passes) in Clippy which unlike regular late passes run incrementally per module

However we have a config file which can change between runs, we need changes to that to invalidate the `lint_mod` query. This PR adds a side channel for us to hash some extra state into `Options` in order to do that

This does not make any changes to Clippy, I plan to do that in a PR to the Clippy repo along with some other required changes

An alternative implementation would be to add a new query to track this state and override the `lint_mod` query in Clippy to first call that

cc `@rust-lang/clippy`
2023-10-16 16:33:42 +00:00
Michael Goulet
743e6d1601 Remove DefiningAnchor::Bubble from opaque wf check 2023-10-16 15:50:31 +00:00
Michael Goulet
17ec3cd5bf Fix outlives suggestion for GAT in RPITIT 2023-10-16 15:42:26 +00:00
bors
98c1e3d95b Auto merge of #116550 - nnethercote:rustc-features-more, r=Nilstrieb
Cleanup `rustc_features` some more

The sequel to #116437.

r? `@Nilstrieb`
2023-10-16 14:34:53 +00:00
bors
e7bdc5f9f8 Auto merge of #114330 - RalfJung:dagling-ptr-deref, r=oli-obk
don't UB on dangling ptr deref, instead check inbounds on projections

This implements https://github.com/rust-lang/reference/pull/1387 in Miri. See that PR for what the change is about.

Detecting dangling references in `let x = &...;` is now done by validity checking only, so some tests need to have validity checking enabled. There is no longer inherently a "nodangle" check in evaluating the expression `&*ptr` (aside from the aliasing model).

r? `@oli-obk`

Based on:
- https://github.com/rust-lang/reference/pull/1387
- https://github.com/rust-lang/rust/pull/115524
2023-10-16 12:40:16 +00:00
bors
a00c09e9d8 Auto merge of #116724 - RalfJung:alloc-bytes, r=oli-obk
interpret: clean up AllocBytes

Fixes https://github.com/rust-lang/miri/issues/2836
Nothing has moved here in half a year, so let's just remove these unused stubs -- they need a proper re-design anyway.

r? `@oli-obk`
2023-10-16 10:45:00 +00:00
Zalathar
7aa1b8390b coverage: Explain why we temporarily steal pending_dups 2023-10-16 21:05:46 +11:00
Zalathar
5e5a8e7769 coverage: Inline span_bcb_dominates
Interacting with `basic_coverage_blocks` directly makes it easier to satisfy
the borrow checker when mutating `pending_dups` while reading other fields.
2023-10-16 21:05:46 +11:00
Zalathar
4ab4273d64 coverage: Inline prev_starts_after_next 2023-10-16 21:05:46 +11:00
Zalathar
25e6303202 coverage: Move take_curr and note what its callers are doing 2023-10-16 21:05:46 +11:00
Zalathar
41038dbe4a coverage: Call prev/curr less in other places
This reduces clutter, and makes it easier to notice regions where mutations
definitely don't occur.
2023-10-16 21:05:46 +11:00
Zalathar
b1c44f4a25 coverage: Call prev/curr less in to_refined_spans
This makes it easier to see that the non-initial cases assume that `prev` and
`curr` are set, and all operate on the same prev/curr references.
2023-10-16 21:05:46 +11:00
Zalathar
9bb27f3adf coverage: Remove redundant field prev_expn_span
This span can always be retrieved from `prev`, so there is no need to store it
separately.
2023-10-16 21:05:45 +11:00
Zalathar
7bbe4be568 coverage: Flatten guard logic in maybe_flush_pending_dups 2023-10-16 21:05:45 +11:00
Zalathar
97d1a9120e coverage: Flatten guard logic in maybe_push_macro_name_span 2023-10-16 21:05:33 +11:00
Zalathar
5f1e8f9950 coverage: Simplify push_refined_span
It turns out that all of the `len` manipulation here was just reimplementing
`last_mut`.
2023-10-16 20:54:36 +11:00
Zalathar
fa2e26285c coverage: Use DUMMY_SP instead of creating a dummy span manually
This patch also sorts the constructor fields into declaration order.
2023-10-16 20:54:36 +11:00
Zalathar
d928d3e5d8 coverage: Rename hold_pending_dups_unless_dominated to update_pending_dups 2023-10-16 20:54:16 +11:00
Zalathar
9b6ce4fb3c coverage: Rename check_pending_dups to maybe_flush_pending_dups
This method's main responsibility is to flush the pending dups into refined
spans, if appropriate.
2023-10-16 20:53:41 +11:00
Zalathar
46c545c1ba coverage: Rename check_invoked_macro_name_span to maybe_push_macro_name_span 2023-10-16 20:52:20 +11:00
Matthias Krüger
1de910fc0d
Rollup merge of #115196 - chenyukang:yukang-fix-86094, r=estebank
Suggest adding `return` if the for semi which can coerce to the fn return type

Fixes #86094
r? `@estebank`
2023-10-16 06:26:20 +02:00
Nicholas Nethercote
d284c8a2d7 Rename ACTIVE_FEATURES as UNSTABLE_FEATURES.
It's a better name, and lets "active features" refer to the features
that are active in a particular program, due to being declared or
enabled by the edition.

The commit also renames `Features::enabled` as `Features::active` to
match this; I changed my mind and have decided that "active" is a little
better thatn "enabled" for this, particularly because a number of
pre-existing comments use "active" in this way.

Finally, the commit renames `Status::Stable` as `Status::Accepted`, to
match `ACCEPTED_FEATURES`.
2023-10-16 08:17:23 +11:00
Nicholas Nethercote
41b6899487 Remove rustc_feature::State.
`State` is used to distinguish active vs accepted vs removed features.
However, these can also be distinguished by their location, in
`ACTIVE_FEATURES`, `ACCEPTED_FEATURES`, and `REMOVED_FEATURES`.

So this commit removes `State` and moves the internals of its variants
next to the `Feature` in each element of `*_FEATURES`, introducing new
types `ActiveFeature` and `RemovedFeature`. (There is no need for
`AcceptedFeature` because `State::Accepted` had no fields.)

This is a tighter type representation, avoids the need for some runtime
checks, and makes the code a bit shorter.
2023-10-16 08:15:30 +11:00
Matthias Krüger
51be0df011
Rollup merge of #116522 - bvanjoi:fix-115599, r=oli-obk
use `PatKind::Error` when an ADT const value has violation

Fixes #115599

Since the [to_pat](https://github.com/rust-lang/rust/pull/111913/files#diff-6d8d99538aca600d633270051580c7a9e40b35824ea2863d9dda2c85a733b5d9R126-R155) behavior has been changed in the #111913 update, the kind of `inlined_const_ast_pat` has transformed from `PatKind::Leaf { pattern: Pat { kind: Wild, ..} } ` to `PatKind::Constant`. This caused a scenario where there are no matched candidates, leading to a testing of the candidates. This process ultimately attempts to test the string const, triggering the `bug!` invocation finally.

r? ``@oli-obk``
2023-10-15 21:29:07 +02:00
Ralf Jung
28b0c87ad6 update MIR place semantics UB comment 2023-10-15 18:13:33 +02:00
Ralf Jung
b131fc10ae separate bounds-check from alignment check 2023-10-15 18:13:33 +02:00
Ralf Jung
e24835c6e0 more precise error for 'based on misaligned pointer' case 2023-10-15 18:13:33 +02:00
Ralf Jung
cbf47a17d2 avoid computing misalignment if we won't act on it 2023-10-15 18:13:33 +02:00
Ralf Jung
f3f9b795bd place evaluation: require the original pointer to be aligned if an access happens 2023-10-15 18:13:31 +02:00
Ralf Jung
ea9a24e32e avoid re-checking the offset while iterating an array/slice 2023-10-15 18:12:46 +02:00
Ralf Jung
b1ebf002c3 don't UB on dangling ptr deref, instead check inbounds on projections 2023-10-15 18:12:46 +02:00
yukang
25d38c48c3 Suggest adding return if the type of unused semi return value can coerce to the fn return type 2023-10-15 22:57:03 +08:00