Commit Graph

267233 Commits

Author SHA1 Message Date
Ralf Jung
c55c4c9f9d tweak Const::identity_unevaluated name and docs 2024-09-28 21:28:08 +02:00
Ralf Jung
921a5ef6d7 try to get rid of mir::Const::normalize 2024-09-28 21:15:18 +02:00
bors
e6eb45143c Auto merge of #130979 - matthiaskrgr:rollup-u7ylca5, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #128778 (atomics: allow atomic and non-atomic reads to race)
 - #130918 (simplify LLVM submodule handling)
 - #130960 (Only add an automatic SONAME for Rust dylibs)
 - #130973 (compiletest: rename "runtest/crash.rs" to "runtest/crashes.rs" to be in line with the test directory)
 - #130976 (remove couple redundant clones)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-28 14:02:09 +00:00
Matthias Krüger
2fca8e5ae7
Rollup merge of #130976 - matthiaskrgr:clonee, r=jieyouxu
remove couple redundant clones
2024-09-28 15:11:23 +02:00
Matthias Krüger
1d29bfc562
Rollup merge of #130973 - matthiaskrgr:crash_rename, r=jieyouxu
compiletest: rename "runtest/crash.rs" to "runtest/crashes.rs" to be in line with the test directory

r? jieyouxu
2024-09-28 15:11:22 +02:00
Matthias Krüger
cfe0cff5b9
Rollup merge of #130960 - cuviper:cdylib-soname, r=petrochenkov
Only add an automatic SONAME for Rust dylibs

#126094 added an automatic relative `SONAME` to all dynamic libraries, but it was really only needed for Rust `--crate-type="dylib"`. In Fedora, it was a surprise to see `SONAME` on `"cdylib"` libraries like Python modules, especially because that generates an undesirable RPM `Provides`. We can instead add a `SONAME` just for Rust dylibs by passing the crate-type argument farther.

Ref: https://bugzilla.redhat.com/show_bug.cgi?id=2314879
2024-09-28 15:11:22 +02:00
Matthias Krüger
f33fa3f57b
Rollup merge of #130918 - onur-ozkan:better-llvm-submodule-handling, r=Kobzol
simplify LLVM submodule handling

Fixes #130906.
2024-09-28 15:11:21 +02:00
Matthias Krüger
5e4eab454a
Rollup merge of #128778 - RalfJung:atomic-read-read-races, r=Mark-Simulacrum
atomics: allow atomic and non-atomic reads to race

We currently define our atomics in terms of C++ `atomic_ref`. That has the unfortunate side-effect of making it UB for an atomic and a non-atomic read to race (concretely, [this code](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d1a743774e60923db33def7fe314d754) has UB). There's really no good reason for this, all the academic models of the C++ memory model I am aware of allow this -- C++ just disallows this because of their insistence on an "object model" with typed memory, where `atomic_ref` temporarily creates an "atomic object" that may not be accesses via regular non-atomic operations.

So instead of tying our operations to `atomic_ref`, let us tie them directly to the underlying C++ memory model. I am not sure what is the best way to phrase this, so here's a first attempt.

We also carve out an exception from the "no mixed-size atomic accesses" rule to permit mixed-size atomic reads -- given that we permit mixed-size non-atomic reads, it seems odd that this would be disallowed for atomic reads. However, when an atomic write races with any other atomic operation, they must use the same size.

With this change, it is finally the case that every non-atomic access can be replaced by an atomic access without introducing UB.

Cc `@rust-lang/opsem` `@chorman0773` `@m-ou-se` `@WaffleLapkin` `@Amanieu`

Fixes https://github.com/rust-lang/unsafe-code-guidelines/issues/483
2024-09-28 15:11:21 +02:00
Matthias Krüger
e174b92cb4 remove couple redundant clones 2024-09-28 13:42:37 +02:00
bors
612796c420 Auto merge of #130964 - matthiaskrgr:rollup-suriuub, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #125404 (Fix `read_buf` uses in `std`)
 - #130866 (Allow instantiating object trait binder when upcasting)
 - #130922 (Reference UNSPECIFIED instead of INADDR_ANY in join_multicast_v4)
 - #130924 (Make clashing_extern_declarations considering generic args for ADT field)
 - #130939 (rustdoc: update `ProcMacro` docs section on helper attributes)
 - #130940 (Revert space-saving operations)
 - #130944 (Allow instantiating trait object binder in ptr-to-ptr casts)
 - #130953 (Rename a few tests to make tidy happier)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-28 10:46:56 +00:00
Matthias Krüger
84c944c6ff compiletest: rename "runtest/crash.rs" to "runtest/crashes.rs" to be in line with the test directory
r? jieyouxu
2024-09-28 12:45:54 +02:00
Ralf Jung
96be76bf53 Further clarificarion for atomic and UnsafeCell docs:
- UnsafeCell: mention the term "data race", and reference the data race definition
- atomic: failing RMWs are just reads, reorder and reword docs
2024-09-28 12:14:59 +02:00
Ralf Jung
6ca5e29e49 allow mixed-size atomic reads 2024-09-28 12:14:56 +02:00
Ralf Jung
ed417f44f8 miri: no longer complain about read-read races 2024-09-28 12:05:29 +02:00
Ralf Jung
76bce58b7a atomics: allow atomic and non-atomic reads to race 2024-09-28 11:57:04 +02:00
bors
150247c338 Auto merge of #130897 - workingjubilee:dump-hexes-with-class, r=thomcc
library: Compute `RUST_EXCEPTION_CLASS` from native-endian bytes

This makes it appear correctly in hexdumps on both LE and BE platforms.
2024-09-28 07:47:26 +00:00
Matthias Krüger
5d7db93600
Rollup merge of #130953 - workingjubilee:rename-a-few-ctypes-tests, r=fee1-dead
Rename a few tests to make tidy happier

A somewhat random smattering of tests that I have recently looked at, and thus had cause to research and write down the reason for their existence.
2024-09-28 09:35:12 +02:00
Matthias Krüger
58d0730fb8
Rollup merge of #130944 - lukas-code:ptr-ptr-sub, r=compiler-errors
Allow instantiating trait object binder in ptr-to-ptr casts

For unsizing coercions between trait objects with the same principal, we already allow instantiating the for binder. For example, coercing `Box<dyn for<'a> Trait<'a>` to `Box<dyn Trait<'static>>` is allowed.

Since ptr-to-ptr casts will insert an unsizing coercion before the cast if possible, this has the consequence that the following compiles already:

```rust
// This compiles today.
fn cast<'b>(x: *mut dyn for<'a> Trait<'a>) -> *mut dyn Trait<'b> {
    // lowered as (roughly)
    // tmp: *mut dyn Trait<'?0> = Unsize(x)     // requires dyn for<'a> Trait<'a> <: dyn Trait<'?0>
    // ret: *mut dyn Trait<'b> = PtrToPtr(tmp)  // requires dyn Trait<'?0> == dyn Trait<'b>
    x as _
}
```

However, if no unsizing coercion is inserted then this currently fails to compile as one type is more general than the other. This PR will allow this code to compile, too, by changing ptr-to-ptr casts of pointers with vtable metadata to use sutyping instead of type equality.

```rust
// This will compile after this PR.
fn cast<'b>(x: *mut dyn for<'a> Trait<'a>) -> *mut Wrapper<dyn Trait<'b>> {
    // lowered as (roughly)
    // no Unsize here!
    // ret: *mut Wrapper<dyn Trait<'b>> = PtrToPtr(x)  // requires dyn for<'a> Trait<'a> == dyn Trait<'b>
    x as _
}
```

Note that it is already possible to work around the current restrictions and make the code compile before this PR by splitting the cast in two, so this shouldn't allow a new class of programs to compile:

```rust
// Workaround that compiles today.
fn cast<'b>(x: *mut dyn for<'a> Trait<'a>) -> *mut Wrapper<dyn Trait<'b>> {
    x as *mut dyn Trait<'_> as _
}
```

r? `@compiler-errors`
cc `@WaffleLapkin`
2024-09-28 09:35:12 +02:00
Matthias Krüger
6b5cd4e84e
Rollup merge of #130940 - workingjubilee:remove-space-saving-operations, r=Kobzol
Revert space-saving operations

The "all of our artifacts" `mv` seems like it may save enough space to matter sometimes, since it can range up to a gigabyte of difference, if memory serves. For the rest, I think we're good.

try-job: dist-aarch64-apple
2024-09-28 09:35:11 +02:00
Matthias Krüger
7e32221aee
Rollup merge of #130939 - obi1kenobi:patch-2, r=aDotInTheVoid
rustdoc: update `ProcMacro` docs section on helper attributes

I believe the mention of attribute macros in the section on proc macro helper attributes is erroneous. As far as I can tell, attribute macros cannot define helper attributes.

The following attribute macro is not valid (fails to build), no matter how I try to define (or skip defining) the helpers:
```rust
#[proc_macro_attribute(attributes(helper))]
pub fn attribute_helpers(_attr: TokenStream, item: TokenStream) -> TokenStream {
    item
}
```

The [language reference](https://doc.rust-lang.org/reference/procedural-macros.html#attribute-macros) also doesn't seem to mention attribute macro helpers. The helpers subsection is inside the section on derive macros.
2024-09-28 09:35:11 +02:00
Matthias Krüger
2df6b0773e
Rollup merge of #130924 - surechen:fix_130851, r=compiler-errors
Make clashing_extern_declarations considering generic args for ADT field

In following example, G<u16> should be recognized as different from G<u32> :

```rust
#[repr(C)] pub struct G<T> { g: [T; 4] }

pub mod x { extern "C" { pub fn g(_: super::G<u16>); } }
pub mod y { extern "C" { pub fn g(_: super::G<u32>); } }
```

fixes #130851
2024-09-28 09:35:10 +02:00
Matthias Krüger
9c4b81c238
Rollup merge of #130922 - tyilo:udp-unspecified, r=ibraheemdev
Reference UNSPECIFIED instead of INADDR_ANY in join_multicast_v4
2024-09-28 09:35:09 +02:00
Matthias Krüger
4e510daed7
Rollup merge of #130866 - compiler-errors:dyn-instantiate-binder, r=lcnr
Allow instantiating object trait binder when upcasting

This PR fixes two bugs (that probably need an FCP).

### We use equality rather than subtyping for upcasting dyn conversions

This code should be valid:

```rust
#![feature(trait_upcasting)]

trait Foo: for<'h> Bar<'h> {}
trait Bar<'a> {}

fn foo(x: &dyn Foo) {
    let y: &dyn Bar<'static> = x;
}
```
But instead:

```
error[E0308]: mismatched types
 --> src/lib.rs:7:32
  |
7 |     let y: &dyn Bar<'static> = x;
  |                                ^ one type is more general than the other
  |
  = note: expected existential trait ref `for<'h> Bar<'h>`
             found existential trait ref `Bar<'_>`
```

And so should this:

```rust
#![feature(trait_upcasting)]

fn foo(x: &dyn for<'h> Fn(&'h ())) {
    let y: &dyn FnOnce(&'static ()) = x;
}
```

But instead:

```
error[E0308]: mismatched types
 --> src/lib.rs:4:39
  |
4 |     let y: &dyn FnOnce(&'static ()) = x;
  |                                       ^ one type is more general than the other
  |
  = note: expected existential trait ref `for<'h> FnOnce<(&'h (),)>`
             found existential trait ref `FnOnce<(&(),)>`
```

Specifically, both of these fail because we use *equality* when comparing the supertrait to the *target* of the unsize goal. For the first example, since our supertrait is `for<'h> Bar<'h>` but our target is `Bar<'static>`, there's a higher-ranked type mismatch even though we *should* be able to instantiate that supertrait binder when upcasting. Similarly for the second example.

### New solver uses equality rather than subtyping for no-op (i.e. non-upcasting) dyn conversions

This code should be valid in the new solver, like it is with the old solver:

```rust
// -Znext-solver

fn foo<'a>(x: &mut for<'h> dyn Fn(&'h ())) {
   let _: &mut dyn Fn(&'a ()) = x;
}
```

But instead:

```
error: lifetime may not live long enough
 --> <source>:2:11
  |
1 | fn foo<'a>(x: &mut dyn for<'h> Fn(&'h ())) {
  |        -- lifetime `'a` defined here
2 |    let _: &mut dyn Fn(&'a ()) = x;
  |           ^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
  |
  = note: requirement occurs because of a mutable reference to `dyn Fn(&())`
```

Specifically, this fails because we try to coerce `&mut dyn for<'h> Fn(&'h ())` to `&mut dyn Fn(&'a ())`, which registers an `dyn for<'h> Fn(&'h ()): dyn Fn(&'a ())` goal. This fails because the new solver uses *equating* rather than *subtyping* in `Unsize` goals.

This is *mostly* not a problem... You may wonder why the same code passes on the new solver for immutable references:

```
// -Znext-solver

fn foo<'a>(x: &dyn Fn(&())) {
   let _: &dyn Fn(&'a ()) = x; // works
}
```

That's because in this case, we first try to coerce via `Unsize`, but due to the leak check the goal fails. Then, later in coercion, we fall back to a simple subtyping operation, which *does* work.

Since `&T` is covariant over `T`, but `&mut T` is invariant, that's where the discrepancy between these two examples crops up.

---

r? lcnr or reassign :D
2024-09-28 09:35:09 +02:00
Matthias Krüger
6e9db86787
Rollup merge of #125404 - a1phyr:fix-read_buf-uses, r=workingjubilee
Fix `read_buf` uses in `std`

Following lib-team decision here: https://github.com/rust-lang/rust/issues/78485#issuecomment-2122992314

Guard against the pathological behavior of both returning an error and performing a read.
2024-09-28 09:35:08 +02:00
bors
851f698682 Auto merge of #130874 - klensy:bumpme, r=jieyouxu
bump few deps

Bumps cargo_metadata, thorin-dwp, windows.

Should dedupe some crates around.
2024-09-28 05:15:29 +00:00
bors
b6576e3f63 Auto merge of #130948 - GuillaumeGomez:subtree-update, r=GuillaumeGomez
GCC backend subtree update

We just finished the [last sync](https://github.com/rust-lang/rustc_codegen_gcc/pull/556) so time to sync back.

cc `@antoyo`
2024-09-28 02:48:40 +00:00
bors
1b6d674773 Auto merge of #130929 - weihanglo:update-cargo, r=weihanglo
Update cargo

19 commits in eaee77dc1584be45949b75e4c4c9a841605e3a4b..80d82ca22abbee5fb7b51fa1abeb1ae34e99e88a
2024-09-19 21:10:23 +0000 to 2024-09-27 17:56:01 +0000
- Update cc to 1.1.22 (rust-lang/cargo#14607)
- feat: lockfile path implies --locked on cargo install (rust-lang/cargo#14556)
- feat(toml): Add `autolib` (rust-lang/cargo#14591)
- fix: correct error count for `cargo check --message-format json` (rust-lang/cargo#14598)
- test: relax panic output assertion (rust-lang/cargo#14602)
- feat(timings): support dark color scheme in HTML output (rust-lang/cargo#14588)
- feat: add CARGO_MANIFEST_PATH env variable (rust-lang/cargo#14404)
- fix(config): Don't double-warn about `$CARGO_HOME/config` (rust-lang/cargo#14579)
- fix(cargo-rustc): give trailing flags higher precedence on nightly (rust-lang/cargo#14587)
- feat: make lockfile v4 the default (rust-lang/cargo#14595)
- perf: Improve quality of completion performance traces (rust-lang/cargo#14592)
- test: Remove completion tests (rust-lang/cargo#14590)
- feat: Add support for completing `cargo update &lt;TAB&gt;` (rust-lang/cargo#14552)
- test: Migrate remaining with_stdout/with_stderr calls (rust-lang/cargo#14577)
- fix(resolve): Improve multi-MSRV workspaces (rust-lang/cargo#14569)
- chore: Bump MSRV to 1.81 (rust-lang/cargo#14585)
- Add a `--dry-run` flag to the `install` command (rust-lang/cargo#14280)
- fix(resolve): Don't list transitive, incompatible dependencies as available (rust-lang/cargo#14568)
- feat(complete): Upgrade clap_complete (rust-lang/cargo#14573)
2024-09-28 00:18:59 +00:00
Josh Stone
f46057bf1c Only add an automatic SONAME for Rust dylibs 2024-09-27 15:53:26 -07:00
Jubilee Young
19d5568ad3 tests: issue-34798.rs => allow-phantomdata-in-ffi.rs 2024-09-27 14:29:34 -07:00
bors
83e4e18896 Auto merge of #130946 - matthiaskrgr:rollup-ia4mf0y, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #130718 (Cleanup some known-bug issues)
 - #130730 (Reorganize Test Headers)
 - #130826 (Compiler: Rename "object safe" to "dyn compatible")
 - #130915 (fix typo in triagebot.toml)
 - #130926 (Update cc to 1.1.22 in library/)
 - #130932 (etc: Add sample rust-analyzer configs for eglot & helix)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-27 21:23:29 +00:00
Jubilee Young
a1fbf251b8 tests: issue-14309.* => repr-rust-is-undefined.* 2024-09-27 14:20:31 -07:00
Jubilee Young
bcf8cf2943 tests: issue-69488.rs => load-preserves-partial-init-issue-69488.rs 2024-09-27 14:18:11 -07:00
Guillaume Gomez
d0102fdd0f Update libgccjit version used in CI 2024-09-27 23:05:29 +02:00
Guillaume Gomez
7cde7db1fc Fmt 2024-09-27 22:09:18 +02:00
Guillaume Gomez
325b70890a Merge commit '3187d32079b817522cc17413ec9185b130daf693' into subtree-update 2024-09-27 22:00:17 +02:00
Weihang Lo
f0677e7d39
Update cargo 2024-09-27 15:45:11 -04:00
Michael Goulet
d753aba3b3 Get rid of a_is_expected from ToTrace 2024-09-27 15:43:18 -04:00
Michael Goulet
4fb097a5de Instantiate binders when checking supertrait upcasting 2024-09-27 15:43:18 -04:00
Matthias Krüger
243c6d67ff
Rollup merge of #130932 - mrkajetanp:editors, r=jieyouxu
etc: Add sample rust-analyzer configs for eglot & helix

LSP configuration in editors like Emacs (eglot) and helix does not
use the same JSON format as vscode and vim do. It is not obvious
how to set up LSP for rustc in those editors and the dev guide currently
does not cover them. Adding sample configuration files for those editors
alongside the currently existing JSON one would be helpful.

I figured having those included in the repo like the JSON one might save
someone some time and frustration otherwise spent on trying to get the
more niche editors' LSP to work properly. I'll add a section in the dev
guide too.
2024-09-27 21:35:10 +02:00
Matthias Krüger
22c1009e7f
Rollup merge of #130926 - ChrisDenton:cc-1-1-22, r=tgross35
Update cc to 1.1.22 in library/

r? `@ghost`

try-job: x86_64-msvc
2024-09-27 21:35:09 +02:00
Matthias Krüger
6c362bf8f6
Rollup merge of #130915 - naskya:fix/typo, r=jieyouxu
fix typo in triagebot.toml

This pull request fixes a minor typo in the triagebot config file.
2024-09-27 21:35:09 +02:00
Matthias Krüger
a935064fae
Rollup merge of #130826 - fmease:compiler-mv-obj-safe-dyn-compat, r=compiler-errors
Compiler: Rename "object safe" to "dyn compatible"

Completed T-lang FCP: https://github.com/rust-lang/lang-team/issues/286#issuecomment-2338905118.
Tracking issue: https://github.com/rust-lang/rust/issues/130852

Excludes `compiler/rustc_codegen_cranelift` (to be filed separately).
Includes Stable MIR.

Regarding https://github.com/rust-lang/rust/labels/relnotes, I guess I will manually open a https://github.com/rust-lang/rust/labels/relnotes-tracking-issue since this change affects everything (compiler, library, tools, docs, books, everyday language).

r? ghost
2024-09-27 21:35:08 +02:00
Matthias Krüger
ae43f27f83
Rollup merge of #130730 - veera-sivarajan:clean-test-headers, r=compiler-errors
Reorganize Test Headers

This PR moves the test headers to the top in a couple of test files to maintain consistent style.

Based on this comment: https://github.com/rust-lang/rust/pull/130665#discussion_r1770506261
2024-09-27 21:35:08 +02:00
Matthias Krüger
65196ca4a9
Rollup merge of #130718 - jackh726:known-bug-cleanup, r=compiler-errors
Cleanup some known-bug issues

I went through most of the known-bug tests (except those under `tests/crashes`) and made sure the issue had the `S-bug-has-test` label and checked that the linked issue was open. This is a bunch of cleanups, mainly issues that have been closed and the tests should have been updated.

Importantly, there are many known-bug tests linking to #110395. This *probably* isn't right - that is a tracking issue. But I don't really know what the "right" thing to do here. Probably, most that are actually *supposed* to be tests for const trait need to be linked to *that* tracking issue. And any other tests that were mislabeled need to be handled accordingly e.g. #130482. cc `@fee1-dead`
2024-09-27 21:35:07 +02:00
Guillaume Gomez
3187d32079
Merge pull request #556 from GuillaumeGomez/sync_2024-08-12
Sync 2024-08-12
2024-09-27 21:17:21 +02:00
Lukas Markeffsky
53f45c4332 borrowck: use subtyping instead of equality for ptr-to-ptr casts 2024-09-27 21:04:32 +02:00
Lukas Markeffsky
8302f2e35f add even more tests for ptr-to-ptr casts on trait objects 2024-09-27 21:04:32 +02:00
Jubilee Young
a2a4ea0850 Partially revert "ci: Use mv instead of cp in upload step"
This partially reverts commit fe7c97c2e7.

I kept a mv, not a cp, for the one that shuffles major artifacts around,
because the size of those artifacts are big enough to matter, sometimes.
I don't think the diagnostic info will be that heavy, by comparison.
2024-09-27 12:02:02 -07:00
Jubilee Young
282d04489a Revert "ci: Try to remove unused Xcode dirs"
This reverts commit 06f49f6d53.
2024-09-27 11:45:59 -07:00
Predrag Gruevski
3b9db47f07
rustdoc: update ProcMacro docs section on helper attributes
I believe the mention of attribute macros in the section on proc macro helper attributes is erroneous. As far as I can tell, attribute macros cannot define helper attributes.

The following attribute macro is not valid (fails to build), no matter how I try to define (or skip defining) the helpers:
```rust
#[proc_macro_attribute(attributes(helper))]
pub fn attribute_helpers(_attr: TokenStream, item: TokenStream) -> TokenStream {
    item
}
```

The [language reference](https://doc.rust-lang.org/reference/procedural-macros.html#attribute-macros) also doesn't seem to mention attribute macro helpers. The helpers subsection is inside the section on derive macros.
2024-09-27 14:34:48 -04:00