Commit Graph

252202 Commits

Author SHA1 Message Date
bors
46961d2407 Auto merge of #120092 - zetanumbers:pin_in_static_allocator, r=Amanieu
Add `A: 'static` bound for `Arc/Rc::pin_in`

Analogous to https://github.com/rust-lang/rust/pull/79327
Needed to preserve pin's [drop guarantee](https://doc.rust-lang.org/std/pin/index.html#drop-guarantee)
2024-04-12 00:03:43 +00:00
bors
a07f3eb43a Auto merge of #123823 - matthiaskrgr:rollup-8zdtggx, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #122882 (Avoid a panic in `set_output_capture` in the default panic handler)
 - #123523 (Account for trait/impl difference when suggesting changing argument from ref to mut ref)
 - #123744 (Silence `unused_imports` for redundant imports)
 - #123784 (Replace `document.write` with `document.head.insertAdjacent`)
 - #123798 (Avoid invalid socket address in length calculation)
 - #123804 (Stop using `HirId` for fn-like parents since closures are not `OwnerNode`s)
 - #123806 (Panic on overflow in `BorrowedCursor::advance`)
 - #123820 (Add my former address to .mailmap)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-11 21:56:11 +00:00
Matthias Krüger
d2e9ec789b
Rollup merge of #123820 - bash:mailmap, r=workingjubilee
Add my former address to .mailmap
2024-04-11 22:38:57 +02:00
Matthias Krüger
d8ae975c02
Rollup merge of #123806 - joboet:advanced_overflow, r=Amanieu
Panic on overflow in `BorrowedCursor::advance`

Passing `usize::MAX` to `advance` clearly isn't correct, but the current assertion fails to detect this when overflow checks are disabled. This isn't unsound, but should probably be fixed regardless.
2024-04-11 22:38:56 +02:00
Matthias Krüger
17a8ee636f
Rollup merge of #123804 - compiler-errors:podcrab-fix, r=jieyouxu
Stop using `HirId` for fn-like parents since closures are not `OwnerNode`s

This is a minimal fix for #123273.

I'm overall pretty disappointed w/ the state of this code; although it's "just diagnostics", it still should be maintainable and understandable and neither of those are true. I believe this code really needs some major overhauling before anything more should be added to it, because there are subtle invariants that are being exercised and subsequently broken all over the place, and I don't think we should just paper over them (e.g.) by delaying bugs or things like that. I wouldn't be surprised if fixing up this code would also yield better diagnostics.
2024-04-11 22:38:56 +02:00
Matthias Krüger
f361026ebd
Rollup merge of #123798 - tniessen:patch-1, r=workingjubilee
Avoid invalid socket address in length calculation

This has no effect on the lengths of these constants, but since the IP address portion of the socket addresses was intentionally chosen to be the largest valid value, it seems appropriate to also use the largest valid value for the other components (as opposed to invalid values exceeding the possible ranges).
2024-04-11 22:38:55 +02:00
Matthias Krüger
0ab8cc1931
Rollup merge of #123784 - GuillaumeGomez:replace-document-write, r=notriddle
Replace `document.write` with `document.head.insertAdjacent`

From [this comment](https://github.com/rust-lang/rust/pull/123706/files#r1559864981), using `document.write` is strongly discouraged (explained on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/write)).

I think in this case it was mostly ok but better be on the safe side.

r? `@notriddle`
2024-04-11 22:38:55 +02:00
Matthias Krüger
da75aaf13d
Rollup merge of #123744 - compiler-errors:redundant-due-to-glob, r=petrochenkov
Silence `unused_imports` for redundant imports

Quick fix for https://github.com/rust-lang/rust/issues/121708#issuecomment-2048105393

r? `@petrochenkov` cc `@joshtriplett`

I think this is right, would like confirmation. I also think it's weird that we're using `=` to assign to `is_redundant` but using `per_ns` for the actual spans. Seems like this could be weirdly order dependent, but that's unrelated to this change.
2024-04-11 22:38:54 +02:00
Matthias Krüger
ec91d71a38
Rollup merge of #123523 - estebank:issue-123414, r=BoxyUwU
Account for trait/impl difference when suggesting changing argument from ref to mut ref

Do not ICE when encountering a lifetime error involving an argument with an immutable reference of a method that differs from the trait definition.

Fix #123414.
2024-04-11 22:38:54 +02:00
Matthias Krüger
1e99af514b
Rollup merge of #122882 - Zoxc:panic-output-panic, r=Amanieu
Avoid a panic in `set_output_capture` in the default panic handler

This avoid a panic in the default panic handler by not using `set_output_capture` as `OUTPUT_CAPTURE.with` may panic once `OUTPUT_CAPTURE` is dropped.

A new non-panicking `try_set_output_capture` variant of `set_output_capture` is added for use in the default panic handler.
2024-04-11 22:38:53 +02:00
bors
616a8f85f1 Auto merge of #123814 - matthiaskrgr:rollup-lxn0t4t, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #123459 (Correctly handle inlining of doc hidden foreign items)
 - #123740 (Reduce Size of `ModifierInfo`)
 - #123770 (Correct broken link in core::pin doc)
 - #123777 (Deduplicate some function implementations between the parser and AST/HIR)
 - #123808 (codegen tests: Tolerate `nuw` `nsw` on `trunc`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-11 19:52:22 +00:00
Tau Gärtli
d5b3600e15
Add my former address to .mailmap 2024-04-11 20:46:55 +02:00
Michael Goulet
0db2a4010a Silence unused_imports lint for redundant imports 2024-04-11 14:38:21 -04:00
Matthias Krüger
a710de9a3d
Rollup merge of #123808 - maurer:nuw-nsw-trunc, r=durin42
codegen tests: Tolerate `nuw` `nsw` on `trunc`

llvm/llvm-project#87910 infers `nuw` and `nsw` on some `trunc` instructions we're doing `FileCheck` on. Tolerate but don't require them to support both release and head LLVM.

`@rustbot` label: +llvm-main

cc `@durin42`
2024-04-11 20:20:51 +02:00
Matthias Krüger
08ebea2d7a
Rollup merge of #123777 - oli-obk:operator_cleanup, r=jieyouxu
Deduplicate some function implementations between the parser and AST/HIR

These functions already existed on parser binops, so just convert back to them back and invoke the equivalent method.
2024-04-11 20:20:51 +02:00
Matthias Krüger
6625b75d84
Rollup merge of #123770 - tomokinat:master, r=joboet
Correct broken link in core::pin doc

This is a minor correction to the doc, which fails to link `Unpin` trait.

Before (rendered):
![before](https://github.com/rust-lang/rust/assets/49511064/c4f2f94d-91ea-4cee-be69-b0053453194a)

After (rendered):
![before](https://github.com/rust-lang/rust/assets/49511064/847068f8-73b2-4acb-ab78-3351ffe5b0a0)
2024-04-11 20:20:50 +02:00
Matthias Krüger
074269f7a1
Rollup merge of #123740 - veera-sivarajan:reduce-size-of-modifierinfo, r=petrochenkov
Reduce Size of `ModifierInfo`

I added `ModifierInfo` in #121940 and had used a `u64` for  the `size` field even though the largest value it holds is `512`.

This PR changes the type of the `size` field to `u16`.
2024-04-11 20:20:50 +02:00
Matthias Krüger
bcdc281e5c
Rollup merge of #123459 - GuillaumeGomez:fix-123435, r=notriddle
Correctly handle inlining of doc hidden foreign items

Fixes #123435.

In case a foreign item has doc(hidden) attribute, we simply merged its attributes with the re-export's, making it being removed once in the `strip_hidden` pass.

The solution was to use the same as for local reexported items: merge attributes, but not some of them (like `doc(hidden)`).

I originally checked if we could simply update `Item::is_doc_hidden` method to use `self.inline_stmt_id.is_some_and(|def_id| tcx.is_doc_hidden(def_id))` but unfortunately, it added (local) items that shouldn't be inlined. At least it unifies local and foreign items inlining, which I think is the best course of action here.

r? `@notriddle`
2024-04-11 20:20:49 +02:00
Guillaume Gomez
510bfc2db9 Replace document.write with document.head.insertAdjacentHTML 2024-04-11 19:54:49 +02:00
bors
aa6a697a1c Auto merge of #123732 - a1phyr:io_error_factor, r=cuviper
Factor some common `io::Error` constants
2024-04-11 17:49:04 +00:00
Matthew Maurer
e70cf014b8 codegen tests: Tolerate nuw nsw on trunc
llvm/llvm-project#87910 infers `nuw` and `nsw` on some `trunc`
instructions we're doing `FileCheck` on. Tolerate but don't require them
to support both release and head LLVM.
2024-04-11 17:20:08 +00:00
joboet
91fe6f9343
core: panic on overflow in BorrowedCursor 2024-04-11 18:33:46 +02:00
Michael Goulet
68d7c837fc Stop using HirId for fn-like parents 2024-04-11 11:56:47 -04:00
bors
df7daa815f Auto merge of #123795 - matthiaskrgr:rollup-deesd9c, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #123660 (Make the computation of `coroutine_captures_by_ref_ty` more sophisticated)
 - #123738 (Call lower_const_param instead of duplicating the code)
 - #123774 (Fix typo MaybeUnit -> MaybeUninit)
 - #123790 (correct the handling of `bootstrap-cache-path` option)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-11 15:46:42 +00:00
Tobias Nießen
e1972c0061
Avoid invalid socket address in length calculation 2024-04-11 17:27:23 +02:00
Matthias Krüger
1620f33679
Rollup merge of #123790 - onur-ozkan:invalid-config-option, r=clubby789
correct the handling of `bootstrap-cache-path` option

This change makes `build.bootstrap-cache-path` option to be configurable with `./configure` script, so it can be used like `./configure --bootstrap-cache-path=demo`.
2024-04-11 16:57:42 +02:00
Matthias Krüger
8c13ff768c
Rollup merge of #123774 - Lee-Janggun:master, r=lqd
Fix typo MaybeUnit -> MaybeUninit
2024-04-11 16:57:41 +02:00
Matthias Krüger
c71a50d1fa
Rollup merge of #123738 - spastorino:reuse-lower-const-param, r=compiler-errors
Call lower_const_param instead of duplicating the code

Follow up of #123689

r? `@oli-obk`

I had this commit in my old branch that I had forgotten about, `@fmease` pointed about this in #123689

I've left the branches that are not `Range` as do nothing as that's what we are currently doing but maybe we want to err or something.
2024-04-11 16:57:40 +02:00
Matthias Krüger
ee73660368
Rollup merge of #123660 - compiler-errors:coroutine-closure-env, r=oli-obk
Make the computation of `coroutine_captures_by_ref_ty` more sophisticated

Currently, we treat all the by-(mut/)ref borrows of a coroutine-closure as having a "closure env" borrowed lifetime.

When we have the given code:
```rust
let x: &'a i32 = ...;
let c = async || {
    let _x = *x;
};
```

Then when we call:
```rust
c()
// which, because `AsyncFn` takes a `&self`, we insert an autoref:
(&c /* &'env {coroutine-closure} */)()
```

We will return a future whose captures contain `&'env i32` instead of `&'a i32`, which is way more restrictive than necessary. We should be able to drop `c` while the future is alive since it's not actually borrowing any data *originating from within* the closure's captures, but since the capture has that `'env` lifetime, this is not possible.

This wouldn't be true, for example, if the closure captured `i32` instead of `&'a i32`, because the `'env` lifetime is actually *necessary* since the data (`i32`) is owned by the closure.

This PR identifies two criteria where we *need* to take the borrow with the closure env lifetime:
1. If the closure borrows data from inside the closure's captures. This is not true if the parent capture is by-ref, OR if the parent capture is by-move and the child capture begins with a deref projection. This is the example described above.
2. If we're dealing with mutable references, since we cannot reborrow `&'env mut &'a mut i32` into `&'a mut i32`, *only* `&'env mut i32`.

See the documentation on `should_reborrow_from_env_of_parent_coroutine_closure` for more info.

**important:** As disclaimer states on that function, luckily, if this heuristic is not correct, then the program is not unsound, since we still borrowck and validate the choices made from this function -- the only side-effect is that the user may receive unnecessary borrowck errors.

Fixes #123241
2024-04-11 16:57:40 +02:00
bors
72fe8a0f00 Auto merge of #123788 - bjorn3:disable_ctrlc_on_wasi, r=Nilstrieb,lcnr
Disable Ctrl-C handling on WASM

WASM fundamentally doesn't support signals. If WASI ever gets support for notifying the guest process of a Ctrl-C that happened, this would have to be done through the guest process polling for the signal, which will require thread support in WASI too to be compatible with the api provided by the ctrlc crate.
2024-04-11 13:43:14 +00:00
Santiago Pastorino
d51fda8bec
Call lower_const_param instead of duplicating the code 2024-04-11 09:49:01 -03:00
bjorn3
8b0b88adb2 Remove wasm dep filter from tidy
It incorrectly filters out non-wasm dependencies too.
2024-04-11 12:35:47 +00:00
bjorn3
37f576c62a Disable Ctrl-C handling on WASM
WASM fundamentally doesn't support signals. If WASI ever gets support
for notifying the guest process of a Ctrl-C that happened, this would
have to be done through the guest process polling for the signal, which
will require thread support in WASI too to be compatible with the api
provided by the ctrlc crate.
2024-04-11 12:35:47 +00:00
onur-ozkan
bd479113d3 correct the handling of bootstrap-cache-path option
This change makes `build.bootstrap-cache-path` option to be configurable with
`./configure` script, so it can be used like `./configure --bootstrap-cache-path=demo`.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-04-11 14:57:10 +03:00
bors
62cffeedcf Auto merge of #123785 - bjorn3:sync_cg_clif-2024-04-11, r=bjorn3
Subtree sync for rustc_codegen_cranelift

This fixes an ICE for unreachable blocks.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2024-04-11 11:21:44 +00:00
bjorn3
2ab4334a96 Merge commit '89f54caacf90e99fc8ba0d60a28bdadea3cfdf1e' into sync_cg_clif-2024-04-11 2024-04-11 10:42:48 +00:00
bjorn3
89f54caacf Reenable fixed rustc tests 2024-04-11 10:16:50 +00:00
bjorn3
d37f6d821d Fix rustc tests 2024-04-11 10:13:17 +00:00
bjorn3
8a5eecc897 Rustup to rustc 1.79.0-nightly (aa067fb98 2024-04-10) 2024-04-11 09:59:43 +00:00
bjorn3
c183c6194e Sync from rust aa067fb984 2024-04-11 09:45:27 +00:00
bors
241fc135fc Auto merge of #123776 - matthiaskrgr:rollup-x8wzvdf, r=matthiaskrgr
Rollup of 2 pull requests

Successful merges:

 - #123704 (Tweak value suggestions in `borrowck` and `hir_analysis`)
 - #123753 (compiletest: error when finding a trailing directive)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-11 09:17:39 +00:00
Benoît du Garreau
9c64068ddb Factor some common io::Error constants 2024-04-11 09:55:15 +02:00
Oli Scherer
0c8aad638e Remove bin_op_to_assoc_op and invoke AssocOp::from_ast_binop directly 2024-04-11 07:36:34 +00:00
Oli Scherer
07a9854b5c Deduplicate is_comparison impl between BinOpKind and AssocOp 2024-04-11 07:36:34 +00:00
Matthias Krüger
a6448d3d3e
Rollup merge of #123753 - Urgau:compiletest-trailing-directive, r=jieyouxu
compiletest: error when finding a trailing directive

This PR introduce a supplementary check that when checking for a compiletest directive, will also check that the next "word" after that directive is not also by itself a directive.

This is done to avoid situations like this `//@ only-linux only-x86_64` where one might think that both directives are being taken into account while in fact the second in a comment, and so was ignored, until now.

Related to #123730
cc ``@scottmcm``
r? ``@jieyouxu``
2024-04-11 09:31:51 +02:00
Matthias Krüger
93645f481d
Rollup merge of #123704 - estebank:diag-changes, r=compiler-errors
Tweak value suggestions in `borrowck` and `hir_analysis`

Unify the output of `suggest_assign_value` and `ty_kind_suggestion`.

Ideally we'd make these a single function, but doing so would likely require modify the crate dependency tree.
2024-04-11 09:31:50 +02:00
bors
05ccc49a44 Auto merge of #123507 - dpaoliello:arm64ecasm, r=Amanieu
Add support for Arm64EC inline assembly (as unstable)

Compiler support for Arm64EC assembly mostly reuses the existing AArch64 support, except that it needs to block registers that are not permitted: <https://learn.microsoft.com/en-us/windows/arm/arm64ec-abi#register-mapping-and-blocked-registers>

For assembly authors there are several caveats and differences that need to be considered, I've provided documentation for this as part of the "Standard Library Support" PR: <https://github.com/rust-lang/rust/pull/123144/files#diff-6b08532480943c8b82f5dbda7ee1521afa74c9f626466aeb308dfa6956397edd>

r? rust-lang/compiler
2024-04-11 07:15:04 +00:00
Janggun Lee
9984c5bbc1
Fix small typo 2024-04-11 15:38:24 +09:00
Tomoki Nakagawa
68914f2095 Correct broken link in core::pin doc 2024-04-11 15:02:49 +09:00
bors
f13f37fd7b Auto merge of #123007 - kadiwa4:suggest_convert_ptr_to_mut_ref, r=estebank
Rework ptr-to-ref conversion suggestion for method calls

If we have a value `z` of type `*const u8` and try to call `z.to_string()`, the upstream compiler will show you a note suggesting to call `<*const u8>::as_ref` first.

This PR extends that:
- The note will only be shown when the method would exist on the corresponding reference type
- It can now suggest any of `<*const u8>::as_ref`, `<*mut u8>::as_ref` and `<*mut u8>::as_mut`, depending on what the method needs.

I didn't introduce a `help` message because that's not a good idea with `unsafe` functions (and you'd also need to unwrap the `Option<&_>` somehow).
People should check the safety requirements.

For the simplest case
```rust
fn main() {
    let x = 8u8;
    let z: *const u8 = &x;
    // issue #21596
    println!("{}", z.to_string()); //~ ERROR E0599
}
```
the output changes like this:
```diff
 error[E0599]: `*const u8` doesn't implement `std::fmt::Display`
   --> $DIR/suggest-convert-ptr-to-ref.rs:5:22
    |
 LL |     println!("{}", z.to_string());
    |                      ^^^^^^^^^ `*const u8` cannot be formatted with the default formatter
    |
-   = note: try using `<*const T>::as_ref()` to get a reference to the type behind the pointer: https://doc.rust-lang.org/std/primitive.pointer.html#method.as_ref
-   = note: using `<*const T>::as_ref()` on a pointer which is unaligned or points to invalid or uninitialized memory is undefined behavior
+note: the method `to_string` exists on the type `&u8`
+  --> $SRC_DIR/alloc/src/string.rs:LL:COL
+   = note: try using the unsafe method `<*const T>::as_ref` to get an optional reference to the value behind the pointer: https://doc.rust-lang.org/std/primitive.pointer.html#method.as_ref
    = note: the following trait bounds were not satisfied:
            `*const u8: std::fmt::Display`
            which is required by `*const u8: ToString`
```

I removed the separate note about the safety requirements because it was incomplete and the linked doc page already has the information you need.

Fixes #83695, but that's more of a side effect. The upstream compiler already suggests the right method name here.
2024-04-11 04:41:39 +00:00