Commit graph

235247 commits

Author SHA1 Message Date
Jakub Beránek f6017250f8 Enable new bors try branch to run on CI 2023-10-05 16:13:52 +02:00
bors 65519f5fc0 Auto merge of #116360 - compiler-errors:async-span, r=oli-obk
Point to full `async fn` for future

Semi-follow-up to https://github.com/rust-lang/rust/pull/116296#discussion_r1342007575

cc `@asquared31415`
2023-10-04 09:55:02 +00:00
bors 9fbd593a56 Auto merge of #116353 - Kobzol:new-bors-event, r=Mark-Simulacrum
Add new bors try branches to CI

Workflows for the new bors weren't launching, because its branches weren't whitelisted here.

r? `@Mark-Simulacrum`
2023-10-04 07:46:03 +00:00
bors dd513e1150 Auto merge of #116406 - weihanglo:update-cargo, r=weihanglo
Update cargo

9 commits in 59596f0f31a94fde48b5aa7e945cd0b7ceca9620..794d0a82547f3081044c0aca7b6083733ce51344
2023-09-29 19:29:17 +0000 to 2023-10-03 23:19:33 +0000
- Prep for automating MSRV management (rust-lang/cargo#12767)
- chore(deps): update rust crate itertools to 0.11.0 (rust-lang/cargo#12759)
- fix bug: corruption when cargo killed while writing (rust-lang/cargo#12744)
- Disable custom_target::custom_bin_target on windows-gnu (rust-lang/cargo#12763)
- chore(deps): update compatible (rust-lang/cargo#12757)
- Add more missing `strip` info to docs. (rust-lang/cargo#12754)
- chore(deps): update actions/checkout action to v4 (rust-lang/cargo#12762)
- chore(deps): update rust crate cargo_metadata to 0.18.0 (rust-lang/cargo#12758)
- fix(test): Add back in newlines to diffs (rust-lang/cargo#12753)

r? ghost
2023-10-04 05:29:56 +00:00
bors a7bb2f67bf Auto merge of #116408 - matthiaskrgr:rollup-hmolg4m, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #115961 (Replace 'mutex' with 'lock' in RwLock documentation)
 - #116146 (Clarify `arg` and `args` documentation)
 - #116363 (Adapt `todo!` documentation to mention displaying custom values)
 - #116365 (bootstrap: make copying linker binaries conditional)
 - #116388 (rustdoc: fix & clean up handling of cross-crate higher-ranked parameters)
 - #116393 (Emit feature gate *warning* for `auto` traits pre-expansion)
 - #116395 (Mark myself as vacation or whatever)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-04 03:38:42 +00:00
Matthias Krüger d4940488a6
Rollup merge of #116395 - WaffleLapkin:vacationize-waffle, r=lqd
Mark myself as vacation or whatever

I think I have the capacity to review PRs currently assigned to me, before vacation, but I won't be able to take any more. So, until everything settles down, I don't want to be assigned to new PRs.
2023-10-04 05:02:07 +02:00
Matthias Krüger 4ed2291624
Rollup merge of #116393 - compiler-errors:auto-bad, r=WaffleLapkin
Emit feature gate *warning* for `auto` traits pre-expansion

Auto traits were introduced before we were more careful about not stabilizing new syntax pre-expansion.

This is a more conservative step in the general direction we want to go in https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Removal.20of.20.60auto.20trait.60.20syntax.

Fixes #116121
2023-10-04 05:02:07 +02:00
Matthias Krüger 3e293634e2
Rollup merge of #116388 - fmease:rustdoc-fix-n-clean-up-x-crate-higher-ranked-params, r=notriddle
rustdoc: fix & clean up handling of cross-crate higher-ranked parameters

Preparatory work for the refactoring planned in #113015 (for correctness & maintainability).

---

1. Render the higher-ranked parameters of cross-crate function pointer types **(*)**.
2. Replace occurrences of `collect_referenced_late_bound_regions()` (CRLBR) with `bound_vars()`.
  The former is quite problematic and the use of the latter allows us to yank a lot of hacky code **(†)**
  as you can tell from the diff! :)
3. Add support for cross-crate higher-ranked types (`#![feature(non_lifetime_binders)]`).
  We were previously ICE'ing on them (see `inline_cross/non_lifetime_binders.rs`).

---

**(*)**: Extracted from test `inline_cross/fn-type.rs`:

```diff
- fn(_: &'z fn(_: &'b str), _: &'a ()) -> &'a ()
+ for<'z, 'a, '_unused> fn(_: &'z for<'b> fn(_: &'b str), _: &'a ()) -> &'a ()
```

**(†)**: It returns an `FxHashSet` which isn't *predictable* or *stable* wrt. source code (`.rmeta`) changes. To elaborate, the ordering of late-bound regions doesn't necessarily reflect the ordering found in the source code. It does seem to be stable across compilations but modifying the source code of the to-be-documented crates (like adding or renaming items) may result in a different order:

<details><summary>Example</summary>

Let's assume that we're documenting the cross-crate re-export of `produce` from the code below. On `master`, rustdoc would render the list of binders as `for<'x, 'y, 'z>`. However, once you add back the functions `a`–`l`, it would be rendered as `for<'z, 'y, 'x>` (reverse order)! Results may vary. `bound_vars()` fixes this as it returns them in source order.

```rs
// pub fn a() {}
// pub fn b() {}
// pub fn c() {}
// pub fn d() {}
// pub fn e() {}
// pub fn f() {}
// pub fn g() {}
// pub fn h() {}
// pub fn i() {}
// pub fn j() {}
// pub fn k() {}
// pub fn l() {}

pub fn produce() -> impl for<'x, 'y, 'z> Trait<'z, 'y, 'x> {}

pub trait Trait<'a, 'b, 'c> {}

impl Trait<'_, '_, '_> for () {}
```

</details>

Further, as the name suggests, CRLBR only collects *referenced* regions and thus we drop unused binders. `bound_vars()` contains unused binders on the other hand. Let's stay closer to the source where possible and keep unused binders.

Lastly, using `bound_vars()` allows us to get rid of

* the deduplication and alphabetical sorting hack in `simplify.rs`
* the weird field `bound_params` on `EqPredicate`

both of which were introduced by me in #102707 back when I didn't know better.

To illustrate, let's look at the cross-crate bound `T: for<'a, 'b> Trait<A<'a> = (), B<'b> = ()>`.

* With CRLBR + `EqPredicate.bound_params`, *before* bounds simplification we would have the bounds `T: Trait`, `for<'a> <T as Trait>::A<'a> == ()` and `for<'b> <T as Trait>::B<'b> == ()` which required us to merge `for<>`, `for<'a>` and `for<'b>` into `for<'a, 'b>` in a deterministic manner and without introducing duplicate binders.
* With `bound_vars()`, we now have the bounds `for<'a, b> T: Trait`, `<T as Trait>::A<'a> == ()` and `<T as Trait>::B<'b> == ()` before bound simplification similar to rustc itself. This obviously no longer requires any funny merging of `for<>`s. On top of that `for<'a, 'b>` is guaranteed to be in source order.
2023-10-04 05:02:06 +02:00
Matthias Krüger e6a9bb11fb
Rollup merge of #116365 - P1n3appl3:master, r=onur-ozkan
bootstrap: make copying linker binaries conditional

The change in #116276 breaks bootstrapping if you don't use `lld` for linking with your stage0 compiler. Making this copy conditional should be enough to fix it.
2023-10-04 05:02:06 +02:00
Matthias Krüger 0363cc561d
Rollup merge of #116363 - Colonial-Dev:issue-116130-fix, r=thomcc
Adapt `todo!` documentation to mention displaying custom values

Resolves #116130.

I copied from the [existing documentation](https://doc.rust-lang.org/std/macro.unimplemented.html) for `unimplemented!` more or less directly, down to the example trait used. I also took the liberty of fixing some formatting and typographical errors that I noticed.
2023-10-04 05:02:04 +02:00
Matthias Krüger d5bd019645
Rollup merge of #116146 - Milo123459:milo/clarify-arg-documentation, r=thomcc
Clarify `arg` and `args` documentation

Fixes #95400
2023-10-04 05:02:04 +02:00
Matthias Krüger 36e234a0fa
Rollup merge of #115961 - Kriskras99:master, r=thomcc
Replace 'mutex' with 'lock' in RwLock documentation

When copying the documentation for `clear_poison` from Mutex, not every occurence of 'mutex' was replaced with 'lock'.
2023-10-04 05:02:03 +02:00
Weihang Lo d4370cc00c
Update cargo 2023-10-04 10:33:52 +08:00
bors 4910642aab Auto merge of #116386 - elichai:patch-2, r=thomcc
Add missing inline attributes to Duration trait impls

Currently `Duration::checked_add` is marked `#[inline]` but it's trait relative `Add::add` is not.
Leading to a case where:
```rust
pub fn foo() -> Duration {
    Duration::from_secs(10) + Duration::from_millis(6)
}

pub fn bar() -> Duration {
    Duration::from_secs(10).checked_add(Duration::from_millis(6)).expect("overflow when adding durations")
}
```
compiles to:
```asm

playground::foo:
	movl	$10, %edi
	xorl	%esi, %esi
	xorl	%edx, %edx
	movl	$6000000, %ecx
	jmpq	*<core::time::Duration as core::ops::arith::Add>::add@GOTPCREL(%rip)

playground::bar:
	movl	$10, %eax
	movl	$6000000, %edx
	retq
```
(The same happens for all arithmetic operation)
2023-10-04 01:49:24 +00:00
bors 79f38b7914 Auto merge of #116367 - scottmcm:more-addr-eq, r=workingjubilee
Use `addr_eq` in `{Arc,Rc}::ptr_eq`

Since it's made for stuff like this (see #106447)
2023-10-04 00:03:54 +00:00
bors 187b8131d4 Auto merge of #105394 - Patiga:improve-udpsocket-docs, r=workingjubilee
Improve UdpSocket documentation

I tried working with `UdpSocket` and ran into `EINVAL` errors with no clear indication of what causes the error. Also, it was uncharacteristically hard to figure this module out, compared to other Rust `std` modules.

1. `send` and `send_to` return a `usize` This one is just clarity. Usually, returned `usize`s indicate that the buffer might have only been sent partially. This is not the case with UDP. Since that `usize` must always be `buffer.len()`, I have documented that.

2. `bind` limits `connect` and `send_to` When you bind to a limited address space like localhost, you can only `connect` to addresses in that same address space. Error kind: `AddrNotAvailable`.

3. `connect`ing to localhost locks you to localhost On Linux, if you first `connect` to localhost, subsequent `connect`s to
non-localhost addresses fail. Error kind: `InvalidInput`.

For debugging the third one, it was really hard to find someone else who already had that problem. I only managed to find this thread: https://www.mail-archive.com/netdev@vger.kernel.org/msg159519.html
2023-10-03 20:35:38 +00:00
Waffle Maybe a18729c496
Mark myself as vacation or whatever 2023-10-03 23:19:25 +04:00
Michael Goulet 7815641be0 Gate against auto traits pre-expansion 2023-10-03 19:12:00 +00:00
bors 36aab8df0a Auto merge of #115301 - Zalathar:regions-vec, r=davidtwco
coverage: Allow each coverage statement to have multiple code regions

The original implementation of coverage instrumentation was built around the assumption that a coverage counter/expression would be associated with *up to one* code region. When it was discovered that *multiple* regions would sometimes need to share a counter, a workaround was found: for the remaining regions, the instrumentor would create a fresh expression that adds zero  to the existing counter/expression.

That got the job done, but resulted in some awkward code, and produces unnecessarily complicated coverage maps in the final binary.

---

This PR removes that tension by changing `StatementKind::Coverage`'s code region field from `Option<CodeRegion>` to `Vec<CodeRegion>`.

The changes on the codegen side are fairly straightforward. As long as each `CoverageKind::Counter` only injects one `llvm.instrprof.increment`, the rest of coverage codegen is happy to handle multiple regions mapped to the same counter/expression, with only minor option-to-vec adjustments.

On the instrumentor/mir-transform side, we can get rid of the code that creates extra (x + 0) expressions. Instead we gather all of the code regions associated with a single BCB, and inject them all into one coverage statement.

---

There are several patches here but they can be divided in to three phases:
- Preparatory work
- Actually switching over to multiple regions per coverage statement
- Cleaning up

So viewing the patches individually may be easier.
2023-10-03 18:36:21 +00:00
Joseph Ryan f55c879669 bootstrap: make copying linker binaries conditional 2023-10-03 11:25:07 -07:00
bors 268d625029 Auto merge of #116384 - matthiaskrgr:rollup-se332zs, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #114654 (Suggest `pin!()` instead of `Pin::new()` when appropriate)
 - #116261 (a small wf and clause cleanup)
 - #116282 (Fix broken links)
 - #116328 (Factor out common token generation in `fluent_messages`.)
 - #116379 (non_lifetime_binders: fix ICE in lint opaque-hidden-inferred-bound)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-03 16:15:36 +00:00
León Orell Valerian Liehr ace85f0ae3
rustdoc: add support for cross-crate higher-ranked types 2023-10-03 17:41:25 +02:00
Elichai Turkel 92c9bcdff4
Add missing inline attributes to Duration trait impls 2023-10-03 18:39:56 +03:00
León Orell Valerian Liehr 67de1509f3
rustdoc: fix & clean up handling of cross-crate higher-ranked lifetimes 2023-10-03 17:16:51 +02:00
Matthias Krüger 9143370868
Rollup merge of #116379 - fmease:opaq-hid-inf-bnds-non-lt-bndrs, r=compiler-errors
non_lifetime_binders: fix ICE in lint opaque-hidden-inferred-bound

Opaque types like `impl for<T> Trait<T>` would previously lead to an ICE.

r? `@compiler-errors`
2023-10-03 16:24:17 +02:00
Matthias Krüger 5dd9313d2e
Rollup merge of #116328 - nnethercote:rustc_fluent_macro, r=davidtwco
Factor out common token generation in `fluent_messages`.

The failure and success cases are similar enough that they can share code.

r? `@davidtwco`
2023-10-03 16:24:17 +02:00
Matthias Krüger a4ba529474
Rollup merge of #116282 - rustaceanclub:master, r=davidtwco
Fix broken links

The previous address is no longer available, replace it with the latest available one.
2023-10-03 16:24:16 +02:00
Matthias Krüger 8efbc2cbae
Rollup merge of #116261 - lcnr:wf-only-clause, r=davidtwco
a small wf and clause cleanup

- remove `Clause::from_projection_clause`, instead use `ToPredicate`
- change `predicate_obligations` to directly take a `Clause`
- remove some unnecessary `&`
- use clause in `min_specialization` checks where easily applicable
2023-10-03 16:24:15 +02:00
Matthias Krüger 535cd8d511
Rollup merge of #114654 - estebank:suggest-pin-macro, r=davidtwco
Suggest `pin!()` instead of `Pin::new()` when appropriate

When encountering a type that needs to be pinned but that is `!Unpin`, suggest using the `pin!()` macro.

Fix #57994.
2023-10-03 16:24:15 +02:00
León Orell Valerian Liehr 3f0a327fbb
non_lifetime_binders: fix ICE in lint opaque-hidden-inferred-bound 2023-10-03 13:59:59 +02:00
bors e3c631b3de Auto merge of #116376 - matthiaskrgr:rollup-b3d14gq, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #115863 (Add check_unused_messages in tidy)
 - #116210 (Ensure that `~const` trait bounds on associated functions are in const traits or impls)
 - #116358 (Rename both of the `Match` relations)
 - #116371 (Remove unused features from `rustc_llvm`.)
 - #116374 (Print normalized ty)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-03 11:49:06 +00:00
Matthias Krüger 7ba649806f
Rollup merge of #116374 - ouz-a:correct_message, r=RalfJung
Print normalized ty

Inside `mir_assign_valid_types` we are comparing normalized type of `mir_place` but in debug message we are not printing the normalized value, this changes that.
2023-10-03 12:24:13 +02:00
Matthias Krüger 8e148a17e1
Rollup merge of #116371 - nnethercote:rustc_llvm, r=bjorn3
Remove unused features from `rustc_llvm`.

r? `@bjorn3`
2023-10-03 12:24:12 +02:00
Matthias Krüger 12e4c780ee
Rollup merge of #116358 - compiler-errors:match, r=lcnr
Rename both of the `Match` relations

Both of these names kinda were ambiguous.

r? lcnr
2023-10-03 12:24:12 +02:00
Matthias Krüger fa1cbac1ea
Rollup merge of #116210 - Raekye:master, r=fee1-dead
Ensure that `~const` trait bounds on associated functions are in const traits or impls

Zulip discussion: https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/How.20to.2Fshould.20I.20try.20to.20pinpoint.20ICEs.20related.20to.20effects.3F
2023-10-03 12:24:11 +02:00
Matthias Krüger 144862ede8
Rollup merge of #115863 - chenyukang:yukang-add-message-tidy-check, r=davidtwco
Add check_unused_messages in tidy

From https://github.com/rust-lang/rust/pull/115728#issuecomment-1715490553
The check is not 100% accurate, I guess it's enough for now.
2023-10-03 12:24:11 +02:00
bors eb0f3ed59c Auto merge of #115025 - ouz-a:ouz_testing, r=lcnr
Make subtyping explicit in MIR

This adds new mir-opt that pushes new `ProjectionElem` called `ProjectionElem::Subtype(T)` to `Rvalue` of a subtyped assignment so we can unsoundness issues like https://github.com/rust-lang/rust/issues/107205

Addresses https://github.com/rust-lang/rust/issues/112651

r? `@lcnr`
2023-10-03 10:02:52 +00:00
ouz-a 42c39b343d print normalized ty 2023-10-03 12:17:27 +03:00
bors 9998f4add0 Auto merge of #116372 - matthiaskrgr:rollup-ee9oxxa, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #113053 (add notes about non-compliant FP behavior on 32bit x86 targets)
 - #115726 (For a single impl candidate, try to unify it with error trait ref)
 - #116158 (Don't suggest nonsense suggestions for unconstrained type vars in `note_source_of_type_mismatch_constraint`)
 - #116351 (Add `must_use` on pointer equality functions)
 - #116355 (Clarify float rounding direction for signed zero)
 - #116361 (Bump stdarch submodule)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-03 07:10:07 +00:00
Matthias Krüger c3daf77132
Rollup merge of #116361 - eduardosm:bump-stdarch, r=Amanieu
Bump stdarch submodule

r? `@Amanieu`
2023-10-03 08:58:50 +02:00
Matthias Krüger 043fcc487a
Rollup merge of #116355 - orlp:signed-zero-rounding-mode, r=thomcc
Clarify float rounding direction for signed zero

Closes https://github.com/rust-lang/rust/issues/116339.
2023-10-03 08:58:50 +02:00
Matthias Krüger cebe393a4a
Rollup merge of #116351 - asquared31415:ptr_eq_must_use, r=workingjubilee
Add `must_use` on pointer equality functions

`ptr == ptr` (like all use of `==`) has a similar warning, and these functions are simple convenience wrappers over that.
2023-10-03 08:58:49 +02:00
Matthias Krüger 634e5c9ba2
Rollup merge of #116158 - compiler-errors:unconstrained-type-var-sugg, r=wesleywiser
Don't suggest nonsense suggestions for unconstrained type vars in `note_source_of_type_mismatch_constraint`

The way we do type inference for suggestions in `note_source_of_type_mismatch_constraint` is a bit strange. We compute the "ideal" method signature, which takes the receiver that we *want* and uses it to compute the types of the arguments that would have given us that receiver via type inference, and use *that* to suggest how to change an argument to make sure our receiver type is inferred correctly.

The problem is that sometimes we have totally unconstrained arguments (well, they're constrained by things outside of the type checker per se, like associated types), and therefore type suggestions are happy to coerce anything to that unconstrained argument. This leads to bogus suggestions, like #116155. This is partly due to above, and partly due to the fact that `emit_type_mismatch_suggestions` doesn't double check that its suggestions are actually compatible with the program other than trying to satisfy the type mismatch.

This adds a hack to make sure that at least the types are fully constrained, but I guess I could also rip out this logic altogether. There would be some sad diagnostics regressions though, such as `tests/ui/type/type-check/point-at-inference-4.rs`.

Fixes #116155
2023-10-03 08:58:48 +02:00
Matthias Krüger ff3b15e2bf
Rollup merge of #115726 - compiler-errors:better-error-ref, r=estebank
For a single impl candidate, try to unify it with error trait ref

This allows us to point out an exact type mismatch when there's only one applicable impl.

cc `@asquared31415`
r? `@estebank`
2023-10-03 08:58:48 +02:00
Matthias Krüger 9eb87c39a0
Rollup merge of #113053 - RalfJung:x86_32-float, r=workingjubilee
add notes about non-compliant FP behavior on 32bit x86 targets

Based on ton of prior discussion (see all the issues linked from https://github.com/rust-lang/unsafe-code-guidelines/issues/237), the consensus seems to be that these targets are simply cursed and we cannot implement the desired semantics for them. I hope I properly understood what exactly the extent of the curse is here, let's make sure people with more in-depth FP knowledge take a close look!

In particular for the tier 3 targets I have no clue which target is affected by which particular variant of the x86_32 FP curse. I assumed that `i686` meant SSE is used so the "floating point return value" is the only problem, while everything lower (`i586`, `i386`) meant x87 is used.

I opened https://github.com/rust-lang/rust/issues/114479 to concisely describe and track the issue.

Cc `@workingjubilee` `@thomcc` `@chorman0773`  `@rust-lang/opsem`
Fixes https://github.com/rust-lang/rust/issues/73288
Fixes https://github.com/rust-lang/rust/issues/72327
2023-10-03 08:58:47 +02:00
Ralf Jung df911dfdd6 add notes about non-compliant FP behavior on 32bit x86 targets 2023-10-03 07:52:40 +02:00
Nicholas Nethercote c3127d161a Remove unused features from rustc_llvm. 2023-10-03 15:54:44 +11:00
bors 4f75af9e19 Auto merge of #116083 - cuviper:relnotes-1.73.0, r=Mark-Simulacrum
Add release notes for 1.73.0

r? `@Mark-Simulacrum`
cc `@rust-lang/release`
2023-10-03 04:37:43 +00:00
Mark Rousskov 9501ff00b9
Fix a few typos
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2023-10-02 22:49:16 -04:00
Michael Goulet 2934fe07b7 Point to full async fn for future 2023-10-03 02:25:32 +00:00