Commit Graph

227574 Commits

Author SHA1 Message Date
Matthias Krüger
4e96aba8f6
Rollup merge of #112933 - TaKO8Ki:avoid-&format-in-error-message-code, r=oli-obk
Avoid `&format` in error message code

follow-up of #111633
2023-06-23 13:18:14 +02:00
Matthias Krüger
3feee9f1f2
Rollup merge of #112927 - GuillaumeGomez:where-clause-indent, r=notriddle
Fix indentation for where clause in rustdoc pages

Screenshot of the bug:

![image](https://github.com/rust-lang/rust/assets/3050060/090cfeaa-0edc-46c7-9ea0-e26ac865b2c2)

I used this opportunity to clarify the code a bit because some weird things were going on.

r? ````@notriddle````
2023-06-23 13:18:13 +02:00
Matthias Krüger
8168915639
Rollup merge of #112704 - RalfJung:dont-wrap-slices, r=ChrisDenton
slice::from_raw_parts: mention no-wrap-around condition

Cc https://github.com/rust-lang/rust/issues/83996. This probably needs to be mentioned in more places, so I am not closing that issue, but this here should help at least.
2023-06-23 13:18:13 +02:00
Matthias Krüger
01cc9caffe
Rollup merge of #111747 - compiler-errors:structural-probe-side-effects, r=fee1-dead
Don't structurally resolve during method ambiguity in probe

See comment in UI test for reason for the failure. This is all on the error path anyways, not really sure what the assertion is there to achieve anyways...

Fixes #111739
2023-06-23 13:18:12 +02:00
bors
fe37f37e4b Auto merge of #112827 - nnethercote:codegen-cleanups, r=tmiasko
Codegen cleanups

Some cleanups I found while looking closely at this code.

r? `@tmiasko`
2023-06-23 03:51:49 +00:00
Michael Goulet
afe36507e8 Don't structurally resolve during method ambiguity in probe 2023-06-22 23:31:06 +00:00
bors
04075b3202 Auto merge of #112686 - estebank:sealed-traits, r=petrochenkov
Account for sealed traits in privacy and trait bound errors

On trait bound errors caused by super-traits, identify if the super-trait is publicly accessibly and if not, explain "sealed traits".

```
error[E0277]: the trait bound `S: Hidden` is not satisfied
  --> $DIR/sealed-trait-local.rs:17:20
   |
LL | impl a::Sealed for S {}
   |                    ^ the trait `Hidden` is not implemented for `S`
   |
note: required by a bound in `Sealed`
  --> $DIR/sealed-trait-local.rs:3:23
   |
LL |     pub trait Sealed: self:🅱️:Hidden {
   |                       ^^^^^^^^^^^^^^^ required by this bound in `Sealed`
   = note: `Sealed` is a "sealed trait", because to implement it you also need to implelement `a:🅱️:Hidden`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it
```

Deduplicate privacy errors that point to the same path segment even if their deduplication span are different.

When encountering a path that is not reachable due to privacy constraints path segments other than the last, keep metadata for the last path segment's `Res` in order to look for alternative import paths for that item to suggest. If there are none, be explicit that the item is not accessible.

```
error[E0603]: module `b` is private
  --> $DIR/re-exported-trait.rs:11:9
   |
LL | impl a:🅱️:Trait for S {}
   |         ^ private module
   |
note: the module `b` is defined here
  --> $DIR/re-exported-trait.rs:5:5
   |
LL |     mod b {
   |     ^^^^^
help: consider importing this trait through its public re-export instead
   |
LL | impl a::Trait for S {}
   |      ~~~~~~~~
```

```
error[E0603]: module `b` is private
  --> $DIR/private-trait.rs:8:9
   |
LL | impl a:🅱️:Hidden for S {}
   |         ^  ------ trait `b` is not publicly reachable
   |         |
   |         private module
   |
note: the module `b` is defined here
  --> $DIR/private-trait.rs:2:5
   |
LL |     mod b {
   |     ^^^^^
```
2023-06-22 18:23:19 +00:00
Takayuki Maeda
c8960622a2 avoid &format in error message code 2023-06-23 02:17:39 +09:00
Esteban Küber
7dffd24da5 Tweak privacy errors to account for reachable items
Suggest publicly accessible paths for items in private mod:

  When encountering a path in non-import situations that are not reachable
  due to privacy constraints, search for any public re-exports that the
  user could use instead.

Track whether an import suggestion is offering a re-export.

When encountering a path with private segments, mention if the item at
the final path segment is not publicly accessible at all.

Add item visibility metadata to privacy errors from imports:

  On unreachable imports, record the item that was being imported in order
  to suggest publicly available re-exports or to be explicit that the item
  is not available publicly from any path.

  In order to allow this, we add a mode to `resolve_path` that will not
  add new privacy errors, nor return early if it encounters one. This way
  we can get the `Res` corresponding to the final item in the import,
  which is used in the privacy error machinery.
2023-06-22 16:50:31 +00:00
Esteban Küber
717c481739 Account for sealed traits in trait bound errors
When implementing a public trait with a private super-trait, we now emit
a note that the missing bound is not going to be able to be satisfied,
and we explain the concept of a sealed trait.
2023-06-22 16:50:21 +00:00
Guillaume Gomez
b858a4745c Update existing snapshot and add more snapshots of where clause indentation 2023-06-22 17:39:23 +02:00
Guillaume Gomez
9202caaec5 Fix indentation for where clause in rustdoc pages 2023-06-22 17:38:19 +02:00
bors
2efe091705 Auto merge of #112913 - nnethercote:avoid-Lrc-Box-dyn-CodegenBackend, r=compiler-errors
Avoid `Lrc<Box<dyn CodegenBackend>>`.

Because `Lrc<Box<T>>` is silly. (Clippy warns about `Rc<Box<T>>` and `Arc<Box<T>>`, and it would warn here if (a) we used Clippy with rustc, and (b) Clippy knew about `Lrc`.)

r? `@bjorn3`
2023-06-22 15:06:03 +00:00
bors
fa06a371b7 Auto merge of #112695 - nnethercote:inline-before-merging-cgus, r=wesleywiser
Inline before merging cgus

Because CGU merging relies on CGU sizes, but the CGU sizes before inlining aren't accurate.

This change doesn't have much effect on compile perf, but it makes follow-on changes that involve more sophisticated reasoning about CGU sizes much easier.

r? `@wesleywiser`
2023-06-22 08:34:32 +00:00
bors
0928a1f757 Auto merge of #112914 - matthiaskrgr:rollup-f0kdqh9, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #112876 (Don't substitute a GAT that has mismatched generics in `OpaqueTypeCollector`)
 - #112906 (rustdoc: render the body of associated types before the where-clause)
 - #112907 (Update cargo)
 - #112908 (Print def_id on EarlyBoundRegion debug)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-22 05:42:01 +00:00
Matthias Krüger
b13c9417cf
Rollup merge of #112908 - spastorino:add-def-id-to-early-bound-region-debug, r=compiler-errors
Print def_id on EarlyBoundRegion debug

It's not the first time that I can't make sense out of the default debug print on `EarlyBoundRegion`. As I was working on #112682 I needed this.

I was doing some git archeology and found that we used to print everything dfbc9608ce/src/librustc/util/ppaux.rs (L425-L430) but we lost the ability in some refactor midway.
2023-06-22 06:29:34 +02:00
Matthias Krüger
1b57b163d7
Rollup merge of #112907 - weihanglo:update-cargo, r=weihanglo
Update cargo

2 commits in dead4b8740c4b6a8ed5211e37c99cf81d01c3b1c..4cebd130ebca3bc219180a54f3e26cc1b14a91de
2023-06-20 20:07:17 +0000 to 2023-06-21 18:59:29 +0000
- fix: Allow embedded manifests in all commands (rust-lang/cargo#12289)
- feat(cli): Support `cargo Cargo.toml` (rust-lang/cargo#12281)

r? `@ghost`
2023-06-22 06:29:34 +02:00
Matthias Krüger
3ba66df643
Rollup merge of #112906 - fmease:rustdoc-render-assoc-ty-body-before-where-clause, r=notriddle
rustdoc: render the body of associated types before the where-clause

Fixes #112903.
2023-06-22 06:29:33 +02:00
Matthias Krüger
cc93c5fca0
Rollup merge of #112876 - compiler-errors:check-subst-compat-in-OpaqueTypeCollector, r=oli-obk
Don't substitute a GAT that has mismatched generics in `OpaqueTypeCollector`

Fixes #111828

I didn't put up minimized UI tests for #112510 or #112873 because they'd minimize to literally the same code, but with different substs on the trait/impl. I don't think that warrants duplicate tests given the nature of the fix.

r? `@oli-obk`

----

Side-note: I checked, and this isn't fixed by #112652 -- I think we discussed whether or not that PR fixed it either intentionally or by accident. The code here isn't really touched by that PR either as far as I can tell?

Also, sorry, did some other drive-bys. Hope it doesn't make rebasing #112652 too difficult 😅
2023-06-22 06:29:33 +02:00
bors
fba636a387 Auto merge of #112814 - antoyo:sync-cg_gcc-2023-06-19, r=bjorn3
Sync rustc_codegen_gcc 2023/06/19

Hi.
This is a sync of the rustc_codegen_gcc subtree.
Thanks.
2023-06-22 02:11:08 +00:00
Nicholas Nethercote
abde9ba527 Tweak CGU size estimate code.
- Rename `create_size_estimate` as `compute_size_estimate`, because that
  makes more sense for the second and subsequent calls for each CGU.
- Change `CodegenUnit::size_estimate` from `Option<usize>` to `usize`.
  We can still assert that `compute_size_estimate` is called first.
- Move the size estimation for `place_mono_items` inside the function,
  for consistency with `merge_codegen_units`.
2023-06-22 09:33:06 +10:00
Nicholas Nethercote
5dd7550a08 Avoid Lrc<Box<dyn CodegenBackend>>.
Because `Lrc<Box<T>>` is silly. (Clippy warns about `Rc<Box<T>>` and
`Arc<Box<T>>`, and it would warn here if (a) we used Clippy with rustc,
and (b) Clippy knew about `Lrc`.)
2023-06-22 09:18:09 +10:00
Nicholas Nethercote
fae4f45214 Remove unused fields from CodegenContext. 2023-06-22 09:07:19 +10:00
Nicholas Nethercote
3bbf9f0128 Introduce CodegenState.
The codegen main loop has two bools, `codegen_done` and
`codegen_aborted`. There are only three valid combinations: `(false,
false)`, `(true, false)`, `(true, true)`.

This commit replaces them with a single tri-state enum, which makes
things clearer.
2023-06-22 09:07:15 +10:00
bors
f272fc3a86 Auto merge of #103503 - thomcc:tvos-support, r=workingjubilee
Support Apple tvOS in libstd

This target has existed in the compiler for a while, was `no_std`-only previously (even requiring `#![feature(restricted_std)]`). Apple tvOS is essentially the same as iOS, down to using the same version numbering, so there's no reason for this to be a `no_std`-only target the way it is currently.

Not yet tested much (I have an Apple TV, but haven't tested that this can deploy and run programs on it, nor the simulator). Uses the implementation strategy as the watchOS support in https://github.com/rust-lang/rust/pull/98101 and etc. That is, no `std::os::` interfaces aside from those in `std::os::unix`.

Includes an update to libc in order to pull in https://github.com/rust-lang/libc/pull/2958.
2023-06-21 22:45:37 +00:00
Santiago Pastorino
3ef510ca80
Print def_id on EarlyBoundRegion debug 2023-06-21 19:34:21 -03:00
Nicholas Nethercote
105ac1c26d Merge root and inlined item placement.
There's no longer any need for them to be separate, and putting them
together reduces the amount of code.
2023-06-22 08:10:29 +10:00
Nicholas Nethercote
6f228e3420 Inline before merging CGUs.
Because CGU merging relies on CGU sizes, but the CGU sizes before
inlining aren't accurate.

This requires tweaking how the sizes are updated during merging: if CGU
A and B both have an inlined function F, then `size(A + B)` will be a
little less than `size(A) + size(B)`, because `A + B` will only have one
copy of F. Also, the minimum CGU size is increased because it now has to
account for inlined functions.

This change doesn't have much effect on compile perf, but it makes
follow-on changes that involve more sophisticated reasoning about CGU
sizes much easier.
2023-06-22 08:10:29 +10:00
Nicholas Nethercote
f6cadae163 Streamline some comments. 2023-06-22 08:10:29 +10:00
Nicholas Nethercote
a521ba400d Add comments to Message and WorkItem.
This is particularly useful for `Message`.
2023-06-22 08:07:59 +10:00
Nicholas Nethercote
88cd8f9324 Simplify Message.
`Message` is an enum with multiple variants. Four of those variants map
directly onto the four variants of `WorkItemResult`. This commit reduces
those four `Message` variants to a single variant containing a
`WorkItemResult`. This requires increasing `WorkItemResult`'s visibility
to `pub(crate)` visibility, but `WorkItem` and `Message` can also have
their visibility reduced to `pub(crate)`.

This change avoids some boilerplate enum translation code, and makes
`Message` easier to understand.
2023-06-22 08:07:59 +10:00
Nicholas Nethercote
757c290fba Move Message::CodegenItem to a separate type.
`Message` is an enum with multiple variants, for messages sent to the
coordinator thread. *Except* for `Message::CodegenItem`, which is
entirely disjoint, being for messages sent from the coordinator thread
to the main thread.

This commit move `Message::CodegenItem` into a separate type,
`CguMessage`, which makes the code much clearer.
2023-06-22 08:07:59 +10:00
Thom Chiovoloni
af0662f18c
Note that posix_spawnp probably still does not work the way people may want 2023-06-21 15:01:12 -07:00
Thom Chiovoloni
5ef4d1fb2e
Actually save all the files 2023-06-21 14:59:40 -07:00
Thom Chiovoloni
a7ecc71a48
Note the incomplete Command support in the apple-tvos.md document 2023-06-21 14:59:40 -07:00
Thom Chiovoloni
37854aab76
Update tvOS support elsewhere in the stdlib 2023-06-21 14:59:40 -07:00
Thom Chiovoloni
49da0acb71
Avoid fork/exec spawning on tvOS/watchOS, as those functions are marked as prohibited 2023-06-21 14:59:40 -07:00
Thom Chiovoloni
b80e0b7f53
Reorder tvos_* functions in apple_base.rs to avoid breaking sorted order 2023-06-21 14:59:40 -07:00
Thom Chiovoloni
a3f5566858
Apply suggestions from code review
Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2023-06-21 14:59:40 -07:00
Thom Chiovoloni
6e62961474
Fix missing link in SUMMARY.md 2023-06-21 14:59:40 -07:00
Thom Chiovoloni
b18ff59690
Fix rustc_target::spec:🍎:tests 2023-06-21 14:59:40 -07:00
Thom Chiovoloni
df9640211d
Add a tvOS entry to the platform-support documentation 2023-06-21 14:59:39 -07:00
Thom Chiovoloni
abb1911682
Fix the tvOS targets to use the right LLVM target and respect the deployment target environment variables 2023-06-21 14:59:39 -07:00
Thom Chiovoloni
3785a17dd9
Fix busted data_layout (mismatch vs LLVM) in x86_64 tvOS simulator target 2023-06-21 14:59:39 -07:00
Thom Chiovoloni
f978d7ea42
Finish up preliminary tvos support in libstd 2023-06-21 14:59:39 -07:00
Thom Chiovoloni
bdc3db944c
wip: Support Apple tvOS in libstd 2023-06-21 14:59:37 -07:00
Weihang Lo
b610be68e9
Update cargo 2023-06-21 21:36:50 +01:00
León Orell Valerian Liehr
b866113d19
rustdoc: render the assoc ty body before the where-clause 2023-06-21 21:53:55 +02:00
bors
065a1f5df9 Auto merge of #112900 - GuillaumeGomez:rollup-1blf4io, r=GuillaumeGomez
Rollup of 4 pull requests

Successful merges:

 - #112538 (Removed unnecessary &String -> &str, now that &String implements StableOrd as well)
 - #112868 (Liberate bound vars properly when suggesting missing async-fn-in-trait)
 - #112892 (resolve: Minor cleanup to `fn resolve_path_with_ribs`)
 - #112894 (Fix union fields display)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-21 19:48:41 +00:00
Guillaume Gomez
f5470af6a6
Rollup merge of #112894 - GuillaumeGomez:gui-fields-display, r=notriddle
Fix union fields display

![Screenshot from 2023-06-21 16-47-24](https://github.com/rust-lang/rust/assets/3050060/833b0fe6-7fb6-4371-86c3-d82fa0c3fe49)

So two bugs in this screenshot: no whitespace between field name and type name, both fields are on the same line. Both problems come from issues in the templates because all whitespace are removed if a askama "command" follows.

r? `@notriddle`
2023-06-21 20:00:51 +02:00