Commit Graph

250758 Commits

Author SHA1 Message Date
Matthias Krüger
6464e5b78c
Rollup merge of #123075 - rcvalle:rust-cfi-fix-drop-drop-in-place, r=compiler-errors
CFI: Fix drop and drop_in_place

Fix drop and drop_in_place by transforming self of drop and drop_in_place methods into a Drop trait objects.

This was split off from https://github.com/rust-lang/rust/pull/116404.

cc `@compiler-errors` `@workingjubilee`
2024-03-27 23:27:22 +01:00
Matthias Krüger
a9ed9fb943
Rollup merge of #121943 - joshlf:patch-11, r=scottmcm
Clarify atomic bit validity

The previous definition used the phrase "representation", which is ambiguous given the current state of memory model nomenclature in Rust. For integer types and for `AtomicPtr<T>`, the new wording clarifies that size and bit validity are guaranteed to match the corresponding native integer type/`*mut T`. For `AtomicBool`, the new wording clarifies that size, alignment, and bit validity are guaranteed to match `bool`.

Note that we use the phrase "size and alignment" rather than "layout" since the latter term also implies that the field types are the same. This isn't true - `AtomicXxx` doesn't store an `xxx`, but rather an `UnsafeCell<xxx>`. This distinction is important for some `unsafe` code, which needs to reason about the presence or absence of interior mutability in order to ensure that their code is sound (see e.g. https://github.com/google/zerocopy/issues/251).
2024-03-27 23:27:22 +01:00
bors
c9f8f3438a Auto merge of #122396 - kornelski:vec-err-debloat, r=joboet
Less generic code for Vec allocations

Follow up to https://github.com/rust-lang/rust/pull/120504#issuecomment-1989826191 which hopefully makes compilation faster.
2024-03-27 19:58:44 +00:00
Ramon de C Valle
0b860818e6 CFI: Fix drop and drop_in_place
Fix drop and drop_in_place by transforming self of drop and
drop_in_place methods into Drop trait objects.
2024-03-27 12:52:14 -07:00
bors
0157da41ee Auto merge of #122460 - jieyouxu:rmake-example-refactor, r=Nilstrieb
Rework rmake support library API

### Take 1: Strongly-typed API

Context: https://github.com/rust-lang/rust/pull/122448#discussion_r1523774427

> My 2 cents: from my experience with writing similar "test DSLs", I would suggest to create these helpers as soon as possible in the process (basically the first time someone needs them, not only after N similar usages), and basically treat any imperative code in these high-level tests as a maintenance burden, basically making them as declarative as possible. Otherwise it might be a bit annoying to keep refactoring the tests later once such helpers are available.
>
> I would even discourage the arg method and create explicit methods for setting things like unpretty, the output file etc., but this might be more controversial, as it will make the invoked command-line arguments more opaque.

cc `@Kobzol` for the testing DSL suggestion.

Example:

```rs
let output = Rustc::new()
    .input_file("main.rs")
    .emit(&[EmitKind::Metadata])
    .extern_("stable", &stable_path)
    .output();
```

### Take 2: xshell-based macro API

Example:

```rs
let sh = Shell::new()?;
let stable_path = stable_path.to_string_lossy();
let output = cmd!(sh, "rustc main.rs --emit=metadata --extern stable={stable_path}").output()?;
```

### Take 3: Weakly-typed API with a few helper methods

```rs
let output = Rustc::new()
    .input("main.rs")
    .emit("metadata")
    .extern_("stable", &stable_path)
    .output();
```
2024-03-27 17:43:20 +00:00
bors
d5db7fb537 Auto merge of #123006 - compiler-errors:defer-suggestion-work, r=fee1-dead
Stop doing expensive work in `opt_suggest_box_span` eagerly

This PR defers the `can_coerce` and `predicate_must_hold_modulo_regions` calls in `opt_suggest_box_span`, and instead defers it until error reporting. This requires pulling the logic out of `note_obligation_cause_code` and into coercion, where we have access to the trait solver.

This also allows us to remove `TypeVariableOriginKind::OpaqueTypeInference`.
2024-03-27 15:29:00 +00:00
Kornel
443e29cd97 Less generic code for Vec allocations 2024-03-27 15:27:47 +00:00
Michael Goulet
864e1fbc81 Remove TypeVariableOriginKind::OpaqueInference 2024-03-27 10:08:14 -04:00
Michael Goulet
2fe936f17d Stop doing expensive work in opt_suggest_box_span eagerly 2024-03-27 10:08:14 -04:00
bors
10a7aa14fe Auto merge of #123128 - GuillaumeGomez:rollup-3l3zu6s, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #121843 (Implement `-L KIND=`@RUSTC_BUILTIN/...`)`
 - #122860 (coverage: Re-enable `UnreachablePropagation` for coverage builds)
 - #123021 (Make `TyCtxt::coroutine_layout` take coroutine's kind parameter)
 - #123024 (CFI: Enable KCFI testing of run-pass tests)
 - #123083 (lib: fix some unnecessary_cast clippy lint)
 - #123116 (rustdoc: Swap fields and variant documentations)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-27 09:32:38 +00:00
Guillaume Gomez
c0945f0c9e
Rollup merge of #123116 - chloekek:rustdoc-variant-swap-fields-doc, r=GuillaumeGomez
rustdoc: Swap fields and variant documentations

Previously, the documentation for a variant appeared after the documentation for each of its fields. This was inconsistent with structs and unions, and made little sense on its own; fields are subordinate to variants and should therefore appear later in the documentation.

Before:

![Screenshot of rendered documentation before this patch.](https://github.com/rust-lang/rust/assets/50083900/4c98258e-bdf7-4507-9cf1-fe601407ff11)

After:

![Screenshot of rendered documentation after this patch.](https://github.com/rust-lang/rust/assets/50083900/bd223f92-9b06-4b5a-820e-7a8501bdc0e2)
2024-03-27 10:13:44 +01:00
Guillaume Gomez
64a9360d3f
Rollup merge of #123083 - klensy:clippy-me, r=workingjubilee
lib: fix some unnecessary_cast clippy lint

Fixes few instances of `unnecessary_cast` clippy lint
2024-03-27 10:13:44 +01:00
Guillaume Gomez
dc4236d43b
Rollup merge of #123024 - maurer:kcfi-testing, r=workingjubilee
CFI: Enable KCFI testing of run-pass tests

This enables KCFI-based testing for all the CFI run-pass tests in the suite today. We can add the test header on top of in-flight CFI tests once they land. This is becoming more important as we get closer to leveraging CFI's multiple type attachment feature, as that is where the implementations will have a divergence.

It also enables KCFI as a sanitizer for x86_64 and aarch64 Linux to make this possible. The sanitizer should likely be available for all aarch64, x86_64, and riscv targets, but that isn't critical for initial testing.
2024-03-27 10:13:43 +01:00
Guillaume Gomez
bffeb052d1
Rollup merge of #123021 - compiler-errors:coroutine-layout-lol, r=oli-obk
Make `TyCtxt::coroutine_layout` take coroutine's kind parameter

For coroutines that come from coroutine-closures (i.e. async closures), we may have two kinds of bodies stored in the coroutine; one that takes the closure's captures by reference, and one that takes the captures by move.

These currently have identical layouts, but if we do any optimization for these layouts that are related to the upvars, then they will diverge -- e.g. https://github.com/rust-lang/rust/pull/120168#discussion_r1536943728.

This PR relaxes the assertion I added in #121122, and instead make the `TyCtxt::coroutine_layout` method take the `coroutine_kind_ty` argument from the coroutine, which will allow us to differentiate these by-move and by-ref bodies.
2024-03-27 10:13:43 +01:00
Guillaume Gomez
8a7f285cbc
Rollup merge of #122860 - Zalathar:unused, r=cjgillot
coverage: Re-enable `UnreachablePropagation` for coverage builds

This is a sequence of 3 related changes:
- Clean up the existing code that scans for unused functions
- Detect functions that were instrumented for coverage, but have had all their coverage statements removed by later MIR transforms (e.g. `UnreachablePropagation`)
- Re-enable `UnreachablePropagation` in coverage builds

Because we now detect functions that have lost their coverage statements, and treat them as unused, we don't need to worry about `UnreachablePropagation` removing all of those statements. This is demonstrated by `tests/coverage/unreachable.rs`.

Fixes #116171.
2024-03-27 10:13:42 +01:00
Guillaume Gomez
2973f04076
Rollup merge of #121843 - ferrocene:builtin-path, r=petrochenkov
Implement `-L KIND=@RUSTC_BUILTIN/...`

Implements https://github.com/rust-lang/compiler-team/issues/659
2024-03-27 10:13:42 +01:00
bors
0dcc1309d0 Auto merge of #116016 - jhpratt:kill-rustc-serialize, r=ehuss
Soft-destabilize `RustcEncodable` & `RustcDecodable`, remove from prelude in next edition

cc rust-lang/libs-team#272

Any use of `RustcEncodable` and `RustcDecodable` now triggers a deny-by-default lint. The derives have been removed from the 2024 prelude. I specifically chose **not** to document this in the module-level documentation, as the presence in existing preludes is not documented (which I presume is intentional).

This does not implement the proposed change for `rustfix`, which I will be looking into shortly.

With regard to the items in the preludes being stable, this should not be an issue because #15702 has been resolved.

r? libs-api
2024-03-27 07:30:36 +00:00
bors
37f97982ca Auto merge of #123121 - matthiaskrgr:rollup-e4glcv3, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #122439 (match lowering: build the `Place` instead of keeping a `PlaceBuilder` around)
 - #122880 (Unix: Support more platforms with `preadv` and `pwritev`)
 - #123038 (std library thread.rs: fix NetBSD code for ILP32 CPUs.)
 - #123084 (`UnixStream`: override `read_buf`)
 - #123102 (RustWrapper: update call for llvm/llvm-project@44d037cc258dcf179d2c48…)
 - #123107 (Implement `Vec::pop_if`)
 - #123118 (Update `RwLock` deadlock example to not use shadowing)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-27 05:22:51 +00:00
Matthias Krüger
bce525323d
Rollup merge of #123118 - tgross35:rwlock-docs, r=workingjubilee
Update `RwLock` deadlock example to not use shadowing

Tweak variable names in the deadlock example to remove any potential confusion that the behavior is somehow shadowing-related.
2024-03-27 05:21:18 +01:00
Matthias Krüger
19a40ec5bf
Rollup merge of #123107 - avandesa:vec_pop_if, r=joboet
Implement `Vec::pop_if`

This PR adds `Vec::pop_if` to the public API, behind the `vec_pop_if` feature.

```rust
impl<T> Vec<T> {
    pub fn pop_if<F>(&mut self, f: F) -> Option<T>
        where F: FnOnce(&mut T) -> bool;
}
```

Tracking issue: #122741

## Open questions

- [ ] Should the first unit test be split up?
- [ ] I don't see any guidance on ordering of methods in impl blocks, should I move the method elsewhere?
2024-03-27 05:21:18 +01:00
Matthias Krüger
fc51dbd379
Rollup merge of #123102 - durin42:llvm-19-pass-ptr, r=workingjubilee
RustWrapper: update call for llvm/llvm-project@44d037cc258dcf179d2c48…

…c93996bb406ecd0fae

Easy change.

`@rustbot` label: +llvm-main
2024-03-27 05:21:17 +01:00
Matthias Krüger
910e23bbbb
Rollup merge of #123084 - a1phyr:unixstream_read_buf, r=workingjubilee
`UnixStream`: override `read_buf`

Split from #122441

r? ``@workingjubilee``
2024-03-27 05:21:17 +01:00
Matthias Krüger
d589021b4b
Rollup merge of #123038 - he32:netbsd-ilp32-fix, r=workingjubilee
std library thread.rs: fix NetBSD code for ILP32 CPUs.
2024-03-27 05:21:16 +01:00
Matthias Krüger
4bdf1711c6
Rollup merge of #122880 - a1phyr:preadv_more_platform, r=workingjubilee
Unix: Support more platforms with `preadv` and `pwritev`

- `aix`, `dragonfly` and `openbsd` with direct call
- `watchos` with weak linkage

cc #89517
2024-03-27 05:21:15 +01:00
Matthias Krüger
a2122dc1e3
Rollup merge of #122439 - Nadrieril:store-built-place, r=compiler-errors
match lowering: build the `Place` instead of keeping a `PlaceBuilder` around

Outside of `MatchPair::new` we don't construct new places, so we don't need to keep a `PlaceBuilder` around.

A bit annoyingly we have to store an `Option<Place>` even though it's never `None` after simplification, but the alternative would be to re-entangle `MatchPair` construction and simplification and I'd rather not do that.
2024-03-27 05:21:15 +01:00
Trevor Gross
0cd57725f9 Update RwLock deadlock example to not use shadowing
Tweak variable names in the deadlock example to remove any potential
confusion that the behavior is somehow shadowing-related.
2024-03-26 21:40:31 -04:00
bors
435b525514 Auto merge of #122958 - jieyouxu:port-backtrace-dylib-dep, r=workingjubilee
Port backtrace dylib-dep test to a ui test

Original test: [dylib-dep](6fa4b85b99/crates/dylib-dep)
Part of #122899.
2024-03-27 01:08:47 +00:00
chloekek
1942f956a3 rustdoc: Swap fields and variant documentations
Previously, the documentation for a variant appeared after the documentation
for each of its fields. This was inconsistent with structs and unions, and made
little sense on its own; fields are subordinate to variants and should
therefore appear later in the documentation.
2024-03-27 01:23:48 +01:00
Alex van de Sandt
07d3806eb1 Implement Vec::pop_if 2024-03-26 18:25:24 -04:00
bors
a1b499134a Auto merge of #123108 - matthiaskrgr:rollup-zossklv, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #108675 (Document `adt_const_params` feature in Unstable Book)
 - #122120 (Suggest associated type bounds on problematic associated equality bounds)
 - #122589 (Fix diagnostics for async block cloning)
 - #122835 (Require `DerefMut` and `DerefPure` on `deref!()` patterns when appropriate)
 - #123049 (In `ConstructCoroutineInClosureShim`, pass receiver by mut ref, not mut pointer)
 - #123055 (enable cargo miri test doctests)
 - #123057 (unix fs: Make hurd using explicit new rather than From)
 - #123087 (Change `f16` and `f128` clippy stubs to be nonpanicking)
 - #123103 (Rename `Inherited` -> `TypeckRootCtxt`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-26 22:25:03 +00:00
Matthias Krüger
781b225831
Rollup merge of #123103 - compiler-errors:inherited-is-a-weird-name, r=oli-obk
Rename `Inherited` -> `TypeckRootCtxt`

`Inherited` is a confusing name. Rename it to `TypeckRootCtxt`.

I don't think this needs a type MCP or anything since it's not nearly as pervasive as `FnCtxt` , for example.

r? `@lcnr` `@oli-obk`
2024-03-26 21:23:51 +01:00
Matthias Krüger
7af95edd29
Rollup merge of #123087 - tgross35:clippy-f16-f128-check-stubs, r=blyxyas
Change `f16` and `f128` clippy stubs to be nonpanicking

It turns out there is a bit of a circular dependency - I cannot add anything to `core` because Clippy fails, and I can't actually add correct Clippy implementations without new implementations from `core`.

Change some of the Clippy stubs from `unimplemented!` to success values and leave a FIXME in their place to mitigate this.

Fixes <https://github.com/rust-lang/rust/issues/122587>
2024-03-26 21:23:50 +01:00
Matthias Krüger
ac5ffa51cd
Rollup merge of #123057 - sthibaul:systemtime, r=jhpratt
unix fs: Make hurd using explicit new rather than From

408c0ea216 ("unix time module now return result") dropped the From impl for SystemTime, breaking the hurd build (and probably the horizon build)

Fixes #123032
2024-03-26 21:23:50 +01:00
Matthias Krüger
b8e8d658a7
Rollup merge of #123055 - onur-ozkan:miri-rustdoc, r=RalfJung
enable cargo miri test doctests

This was the cleanest solution that came to my mind so far.

cc `@RalfJung`

Resolves #123028
2024-03-26 21:23:49 +01:00
Matthias Krüger
b63dca138e
Rollup merge of #123049 - compiler-errors:coroutine-closure-rcvr, r=oli-obk
In `ConstructCoroutineInClosureShim`, pass receiver by mut ref, not mut pointer

The receivers were compatible at codegen time, but did not necessarily have the same layouts due to niches, which was caught by miri.

Fixes rust-lang/miri#3400

r? oli-obk
2024-03-26 21:23:49 +01:00
Matthias Krüger
0029a11d7d
Rollup merge of #122835 - compiler-errors:deref-pure, r=Nadrieril
Require `DerefMut` and `DerefPure` on `deref!()` patterns when appropriate

Waiting on the deref pattern syntax pr to merge

r? nadrieril
2024-03-26 21:23:48 +01:00
Matthias Krüger
20770ac3fc
Rollup merge of #122589 - wutchzone:121547, r=compiler-errors
Fix diagnostics for async block cloning

Closes #121547

r? diagnostics
2024-03-26 21:23:48 +01:00
Matthias Krüger
ff8cdc9e14
Rollup merge of #122120 - fmease:sugg-assoc-ty-bound-on-eq-bound, r=compiler-errors
Suggest associated type bounds on problematic associated equality bounds

Fixes #105056. TL;DR: Suggest `Trait<Ty: Bound>` on `Trait<Ty = Bound>` in Rust >=2021.

~~Blocked on #122055 (stabilization of `associated_type_bounds`), I'd say.~~ (merged)
2024-03-26 21:23:47 +01:00
Matthias Krüger
9162776c66
Rollup merge of #108675 - Shadlock0133:adt_const_params, r=compiler-errors
Document `adt_const_params` feature in Unstable Book
2024-03-26 21:23:47 +01:00
bors
47ecded352 Auto merge of #118644 - madsmtm:macos-weak-linking-test, r=compiler-errors
Add test for Apple's `-weak_framework` linker argument

The [`-weak_framework`](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html) linker argument can sometimes be useful to reduce startup times, and to link newer frameworks while still having older deployment targets.

So I made a test to ensure that it continues to work.

Discussed in https://github.com/rust-lang/rust/issues/99427.
2024-03-26 20:22:54 +00:00
Michael Goulet
bf7a745077 Inherited -> TypeckRootCtxt 2024-03-26 15:22:46 -04:00
许杰友 Jieyou Xu (Joe)
7764e8ace3
Port backtrace dylib-dep test to a ui test 2024-03-26 19:07:12 +00:00
Nadrieril
14f186c756 Store Place instead of PlaceBuilder in MatchPair 2024-03-26 19:26:16 +01:00
Nadrieril
3878b3716d Rename 2024-03-26 19:26:16 +01:00
Augie Fackler
2a0107496e RustWrapper: update call for llvm/llvm-project@44d037cc25
Easy change.

@rustbot label: +llvm-main
2024-03-26 14:10:25 -04:00
bors
3b370cf46a Auto merge of #123098 - matthiaskrgr:rollup-39v4rf3, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #122766 (store segment and module in `UnresolvedImportError`)
 - #122996 (simplify_branches: add comment)
 - #123047 (triagebot: Add notification of 2024 issues)
 - #123066 (CFI: (actually) check that methods are object-safe before projecting their receivers to `dyn Trait` in CFI)
 - #123067 (match lowering: consistently merge simple or-patterns)
 - #123069 (Revert `cargo update` changes and bump `download-artifact` to v4)
 - #123070 (Add my former address to .mailmap)
 - #123086 (Fix doc link to BufWriter in std::fs::File documentation)
 - #123090 (Remove `CacheSelector` trait now that we can use GATs)
 - #123091 (Delegation: fix ICE on wrong `self` resolution)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-26 17:44:57 +00:00
Trevor Gross
2cfd5326a5 Change f16 and f128 clippy stubs to be nonpanicking
It turns out there is a bit of a circular dependency - I cannot add
anything to `core` because Clippy fails, and I can't actually add
correct Clippy implementations without new implementations from `core`.

Change some of the Clippy stubs from `unimplemented!` to success values
and leave a FIXME in their place to mitigate this.

Fixes <https://github.com/rust-lang/rust/issues/122587>
2024-03-26 13:37:00 -04:00
Michael Goulet
22bc5c538d In ConstructCoroutineInClosureShim, pass receiver by ref, not pointer 2024-03-26 12:10:51 -04:00
Matthias Krüger
4d1fb9e98a
Rollup merge of #123091 - Bryanskiy:delegation-fixes, r=petrochenkov
Delegation: fix ICE on wrong `self` resolution

fixes https://github.com/rust-lang/rust/issues/122874

Delegation item should be wrapped in a `rib` to behave like a regular function during name resolution.

r? `@petrochenkov`
2024-03-26 17:06:43 +01:00
Matthias Krüger
e7c983cca5
Rollup merge of #123090 - oli-obk:gatify, r=compiler-errors
Remove `CacheSelector` trait now that we can use GATs

No change in behaviour. Just noticed while digging around in the query infrastructure
2024-03-26 17:06:43 +01:00