Commit Graph

282511 Commits

Author SHA1 Message Date
Jack Wrenn
91034adf30 Do not require that unsafe fields lack drop glue
Instead, we adopt the position that introducing an `unsafe` field
itself carries a safety invariant: that if you assign an invariant
to that field weaker than what the field's destructor requires,
you must ensure that field is in a droppable state in your
destructor.

See:
- https://github.com/rust-lang/rfcs/pull/3458#discussion_r1971676100
- https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/unsafe.20fields.20RFC/near/502113897
2025-02-28 16:32:06 +00:00
bors
2f581937e1 Auto merge of #137753 - ChrisDenton:remove-sdk, r=Kobzol
Remove latest Windows SDK from 32-bit CI

This is an alternative to #137766, in case that doesn't work. It is in some ways simpler but is less principled and may be more flaky (as it involves deleting stuff).

try-job: i686-msvc-1
try-job: i686-msvc-2
try-job: dist-i686-msvc
2025-02-28 10:12:31 +00:00
Chris Denton
25617c7e69
Remove Win SDK 10.0.26100.0 from CI 2025-02-28 09:13:00 +00:00
bors
cb08599451 Auto merge of #137710 - matthiaskrgr:rollup-3vmxxu9, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #136542 ([`compiletest`-related cleanups 4/7] Make the distinction between root build directory vs test suite specific build directory in compiletest less confusing)
 - #136579 (Fix UB in ThinVec::flat_map_in_place)
 - #136688 (require trait impls to have matching const stabilities as the traits)
 - #136846 (Make `AssocOp` more like `ExprKind`)
 - #137304 (add `IntoBounds::intersect` and `RangeBounds::is_empty`)
 - #137455 (Reuse machinery from `tail_expr_drop_order` for `if_let_rescope`)
 - #137480 (Return unexpected termination error instead of panicing in `Thread::join`)
 - #137694 (Spruce up `AttributeKind` docs)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-28 03:52:52 +00:00
Chris Denton
f3399516fa
Revert "Fix 32-bit MSVC CI"
This reverts commit 6ea4823733.
2025-02-28 00:47:45 +00:00
bors
e6059f5222 Auto merge of #137669 - DianQK:fn-atts-virtual, r=saethlin
Don't infer attributes of virtual calls based on the function body

Fixes (after backport) #137646.
Since we don't know the exact implementation of the virtual call, it might write to parameters, we can't infer the readonly attribute.
2025-02-28 00:31:26 +00:00
bors
f45d4acf1b Auto merge of #137749 - Kobzol:fix-ci-2, r=Kobzol
Fix 32-bit MSVC CI

By throwing more hardware at it. The large runners should still use the old image. This could buy us a couple of... hours? Days? Who knows.

See https://github.com/rust-lang/rust/issues/137733 for context.

r? `@ghost`

try-job: i686-msvc-1
try-job: i686-msvc-2
try-job: dist-i686-msvc
2025-02-27 20:40:04 +00:00
Jakub Beránek
6ea4823733 Fix 32-bit MSVC CI
By throwing more hardware at it.
2025-02-27 21:36:28 +01:00
Matthias Krüger
89a202d179
Rollup merge of #137694 - aDotInTheVoid:aDotInTheVoid-patch-1, r=jdonszelmann
Spruce up `AttributeKind` docs

- Remove dead link to `rustc_attr` crate.
- Add link to `rustc_attr_parsing` crate.
- Split up first paragraph so it looks better at crate-level summary

r? `@jdonszelmann`
2025-02-27 08:56:40 +01:00
Matthias Krüger
f19d4b5f97
Rollup merge of #137480 - fuzzypixelz:fix/124466, r=workingjubilee
Return unexpected termination error instead of panicing in `Thread::join`

There is a time window during which the OS can terminate a thread before stdlib can retreive its `Packet`. Currently the `Thread::join` panics with no message in such an event, which makes debugging difficult; fixes #124466.
2025-02-27 08:56:39 +01:00
Matthias Krüger
25db95ec4a
Rollup merge of #137455 - compiler-errors:drop-lint-dtor, r=oli-obk
Reuse machinery from `tail_expr_drop_order` for `if_let_rescope`

Namely, it defines its own `extract_component_with_significant_dtor` which is a bit more accurate than `Ty::has_significant_drop`, since it has a hard-coded list of types from the ecosystem which are opted out of the lint.[^a]

Also, since we extract the dtors themselves, adopt the same *label* we use in `tail_expr_drop_order` to point out the destructor impl. This makes it much clear what's actually being dropped, so it should be clearer to know when it's a false positive.

This conflicts with #137444, but I will rebase whichever lands first.

[^a]: Side-note, it's kinda a shame that now there are two functions that presumably do the same thing. But this isn't my circus, nor are these my monkeys.
2025-02-27 08:56:39 +01:00
Matthias Krüger
3499846073
Rollup merge of #137304 - pitaj:rangebounds-is_empty-intersect, r=ibraheemdev
add `IntoBounds::intersect` and `RangeBounds::is_empty`

- ACP: https://github.com/rust-lang/libs-team/issues/539
- Tracking issue for `is_empty`: #137300
- Tracking issue for `IntoBounds`: #136903
2025-02-27 08:56:38 +01:00
Matthias Krüger
4ecca4c09c
Rollup merge of #136846 - nnethercote:make-AssocOp-more-like-ExprKind, r=spastorino
Make `AssocOp` more like `ExprKind`

This is step 1 of [MCP 831](https://github.com/rust-lang/compiler-team/issues/831).

r? ``@estebank``
2025-02-27 08:56:37 +01:00
Matthias Krüger
88dcab75b0
Rollup merge of #136688 - fee1-dead-contrib:push-nppsusmpokqo, r=compiler-errors
require trait impls to have matching const stabilities as the traits

This resolves https://github.com/rust-lang/project-const-traits/issues/5 by implementing the suggested solution in the given thread

r? ``@RalfJung``
cc ``@rust-lang/project-const-traits``
2025-02-27 08:56:36 +01:00
Matthias Krüger
18c47ad639
Rollup merge of #136579 - bjorn3:fix_thinvec_ext_ub, r=BoxyUwU
Fix UB in ThinVec::flat_map_in_place

`thin_vec.as_ptr()` goes through the `Deref` impl of `ThinVec`, which will not allow access to any memory as we did call `set_len(0)` first.

Found in the process of investigating https://github.com/rust-lang/rust/issues/135870.
2025-02-27 08:56:36 +01:00
Matthias Krüger
f435138da9
Rollup merge of #136542 - jieyouxu:build-base, r=onur-ozkan
[`compiletest`-related cleanups 4/7] Make the distinction between root build directory vs test suite specific build directory in compiletest less confusing

Reference for overall changes: https://github.com/rust-lang/rust/pull/136437
Part **4** of **7** of the *`compiletest`-related cleanups* PR series.

### Summary

- Remove `--build-base` compiletest flag, and introduce `--build-{root,test-suite-root}` flags instead. `--build-base` previously actually is test suite specific build directory, not the root `build/` directory.
- Feed the root build directory directly from bootstrap to compiletest via `--build-root` instead of doing multiple layers of parent unwrapping[^parent] based on the test suite specific build directory.
- Remove a redundant `to_path_buf()`.

[^parent]: Please do not unwrap the parents.

r? bootstrap
2025-02-27 08:56:35 +01:00
DianQK
fbe0075a86
Don't infer unwinding of virtual calls based on the function attributes 2025-02-27 12:58:18 +08:00
DianQK
8089fce101
Don't infer attributes of virtual calls based on the function body 2025-02-27 12:57:26 +08:00
Deadbeef
ef66cbb27b require trait impls to have matching const stabilities as the traits 2025-02-27 04:56:27 +00:00
bors
96cfc75584 Auto merge of #132295 - the8472:remove-randomize-exclusion1, r=onur-ozkan
fixed wast version was released, remove randomization exemption
2025-02-27 01:37:30 +00:00
Nicholas Nethercote
2ac46f6517 Rename AssocOp::As as AssocOp::Cast.
To match `ExprKind::Cast`, and because a semantic name makes more sense
here than a syntactic name.
2025-02-27 09:53:18 +11:00
Nicholas Nethercote
fc8e87b274 Replace AssocOp::DotDot{,Eq} with AssocOp::Range.
It makes `AssocOp` more similar to `ExprKind` and makes things a little
simpler. And the semantic names make more sense here than the syntactic
names.
2025-02-27 09:53:18 +11:00
Nicholas Nethercote
ceafbad81f Introduce AssocOp::Binary.
It mirrors `ExprKind::Binary`, and contains a `BinOpKind`. This makes
`AssocOp` more like `ExprKind`. Note that the variants removed from
`AssocOp` are all named differently to `BinOpToken`, e.g. `Multiply`
instead of `Mul`, so that's an inconsistency removed.

The commit adds `precedence` and `fixity` methods to `BinOpKind`, and
calls them from the corresponding methods in `AssocOp`. This avoids the
need to create an `AssocOp` from a `BinOpKind` in a bunch of places, and
`AssocOp::from_ast_binop` is removed.

`AssocOp::to_ast_binop` is also no longer needed.

Overall things are shorter and nicer.
2025-02-27 09:53:17 +11:00
Nicholas Nethercote
a8364f3b2a In AssocOp::AssignOp, use BinOpKind instead of BinOpToken
`AssocOp::AssignOp` contains a `BinOpToken`. `ExprKind::AssignOp`
contains a `BinOpKind`. Given that `AssocOp` is basically a cut-down
version of `ExprKind`, it makes sense to make `AssocOp` more like
`ExprKind`. Especially given that `AssocOp` and `BinOpKind` use semantic
operation names (e.g. `Mul`, `Div`), but `BinOpToken` uses syntactic
names (e.g. `Star`, `Slash`).

This results in more concise code, and removes the need for various
conversions. (Note that the removed functions `hirbinop2assignop` and
`astbinop2assignop` are semantically identical, because `hir::BinOp` is
just a synonum for `ast::BinOp`!)

The only downside to this is that it allows the possibility of some
nonsensical combinations, such as `AssocOp::AssignOp(BinOpKind::Lt)`.
But `ExprKind::AssignOp` already has that problem. The problem can be
fixed for both types in the future with some effort, by introducing an
`AssignOpKind` type.
2025-02-27 09:47:22 +11:00
Alona Enraght-Moony
df845c97f3 Spruce up AttributeKind docs
- Remove dead link to `rustc_attr` crate.
- Add link to `rustc_attr_parsing` crate.
- Split up first paragraph so it looks better at crate-level summary
2025-02-26 22:21:36 +00:00
bors
00f245915b Auto merge of #137688 - fmease:rollup-gbeuj9j, r=fmease
Rollup of 10 pull requests

Successful merges:

 - #134585 (remove `MaybeUninit::uninit_array`)
 - #136187 (Use less CString in the examples of CStr.)
 - #137201 (Teach structured errors to display short `Ty<'_>`)
 - #137620 (Fix `attr` cast for espidf)
 - #137631 (Avoid collecting associated types for undefined trait)
 - #137635 (Don't suggest constraining unstable associated types)
 - #137642 (Rustc dev guide subtree update)
 - #137660 (Update gcc submodule)
 - #137670 (revert accidental change in get_closest_merge_commit)
 - #137671 (Make -Z unpretty=mir suggest -Z dump-mir as well for discoverability)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-26 20:21:40 +00:00
Michael Goulet
864cca80b0 Print out destructor 2025-02-26 19:03:29 +00:00
León Orell Valerian Liehr
46eb43e71b
Rollup merge of #137671 - meithecatte:discoverable-dump-mir, r=Nadrieril
Make -Z unpretty=mir suggest -Z dump-mir as well for discoverability

While debugging something else, I got quite annoyed with `-Z unpretty=mir` showing me post-processed MIR instead of the one just after it is built. I ended up asking on Zulip and got pointed to `-Z dump-mir`. While this feature is documented in the rustc dev guide, I think it'd be good if the possibility of making use of it was staring you in the face while you need it.
2025-02-26 19:03:59 +01:00
León Orell Valerian Liehr
526dd27b4d
Rollup merge of #137670 - RalfJung:llvm-commit-logic-revert, r=Kobzol
revert accidental change in get_closest_merge_commit

This was accidentally merged as part of https://github.com/rust-lang/rust/pull/137594. I need this local diff to be able to debug miri syncs, and then typed `git commit -a` too fast and didn't realize it includes this change... sorry for that.

r? ``@Kobzol``
2025-02-26 19:03:58 +01:00
León Orell Valerian Liehr
bd9e38df98
Rollup merge of #137660 - Kobzol:gcc-update, r=GuillaumeGomez
Update gcc submodule

To add support for the x87 feature (see https://github.com/rust-lang/rust/pull/137612#issuecomment-2683303111).

r? `@antoyo`
2025-02-26 19:03:58 +01:00
León Orell Valerian Liehr
0ae0110083
Rollup merge of #137642 - BoxyUwU:rdg-push, r=Kobzol
Rustc dev guide subtree update

r? ``@Kobzol`` ``@jieyouxu``
2025-02-26 19:03:57 +01:00
León Orell Valerian Liehr
875e390589
Rollup merge of #137635 - compiler-errors:constrain-unstable, r=SparrowLii
Don't suggest constraining unstable associated types

Fixes #137624

This could be made a bit more specific, considering the local crate's stability or nightly status or something, but I think in general we should not be suggesting associated type bounds on unstable associated items.
2025-02-26 19:03:57 +01:00
León Orell Valerian Liehr
2fc88233cd
Rollup merge of #137631 - TaKO8Ki:issue-137508, r=compiler-errors
Avoid collecting associated types for undefined trait

Fixes #137508
Fixes #137554
2025-02-26 19:03:56 +01:00
León Orell Valerian Liehr
c5d57274c0
Rollup merge of #137620 - SergioGasquez:fix/espidf-maybeunit, r=ChrisDenton
Fix `attr` cast for espidf

https://github.com/rust-lang/rust/pull/136826 broke ESP-IDF builds with: https://github.com/esp-rs/esp-idf-template/actions/runs/13516221587/job/37765336588.

This PR fixes it.

cc: ``@ivmarkov`` ``@xizheyin``
2025-02-26 19:03:55 +01:00
León Orell Valerian Liehr
5da5c37387
Rollup merge of #137201 - estebank:structured-errors-long-ty, r=oli-obk
Teach structured errors to display short `Ty<'_>`

Make it so that in every structured error annotated with `#[derive(Diagnostic)]` that has a field of type `Ty<'_>`, the printing of that value into a `String` will look at the thread-local storage `TyCtxt` in order to shorten to a length appropriate with the terminal width. When this happen, the resulting error will have a note with the file where the full type name was written to.

```
error[E0618]: expected function, found `((..., ..., ..., ...), ..., ..., ...)``
 --> long.rs:7:5
  |
6 | fn foo(x: D) { //~ `x` has type `(...
  |        - `x` has type `((..., ..., ..., ...), ..., ..., ...)`
7 |     x(); //~ ERROR expected function, found `(...
  |     ^--
  |     |
  |     call expression requires function
  |
  = note: the full name for the type has been written to 'long.long-type-14182675702747116984.txt'
  = note: consider using `--verbose` to print the full type name to the console
```

Follow up to and response to the comments on #136898.

r? ``@oli-obk``
2025-02-26 19:03:55 +01:00
León Orell Valerian Liehr
f3a445bf75
Rollup merge of #136187 - hkBst:patch-27, r=workingjubilee
Use less CString in the examples of CStr.

Fixes #83999
2025-02-26 19:03:54 +01:00
León Orell Valerian Liehr
bcfff3d40a
Rollup merge of #134585 - cyrgani:uninit_array, r=Amanieu
remove `MaybeUninit::uninit_array`

Closes #134584.
Closes #66845.
The future of this unstable method was described in https://github.com/rust-lang/rust/pull/125082#issuecomment-2161242816. Since `inline_const` was stabilized in 1.79 (4 stable releases away) and no one expressed interest for keeping it in https://github.com/rust-lang/rust/issues/96097, I think it can be removed now as it is not a stable method.
2025-02-26 19:03:53 +01:00
bjorn3
3477297c37 Fix UB in ThinVec::flat_map_in_place
thin_vec.as_ptr() goes through the Deref impl of ThinVec, which will
not allow access to any memory as we did call set_len(0) first.
2025-02-26 15:49:19 +00:00
bors
ac91805f31 Auto merge of #137354 - FractalFir:intern_with_cap, r=FractalFir
Change interners to start preallocated with an increased capacity

Inspired by https://github.com/rust-lang/rust/issues/137005.

Added a `with_capacity` function to `InternedSet`. Changed the `CtxtInterners` to start with `InternedSets` preallocated with a capacity.

This *does* increase memory usage at very slightly(by ~1 MB at the start), altough that increase quickly disaperars for larger crates(since they require such capacity anyway).

A local perf run indicates this improves compiletimes for small crates(like `ripgrep`), without a negative effect on larger ones.
2025-02-26 13:01:45 +00:00
Ralf Jung
bab71fc8d6 revert accidental change in get_closest_merge_commit 2025-02-26 13:35:51 +01:00
Maja Kądziołka
b8c7e8aa72
Make -Z unpretty=mir suggest -Z dump-mir as well 2025-02-26 13:07:12 +01:00
DianQK
28d3fef399
Add a test case for #137646 2025-02-26 19:54:34 +08:00
bors
2af87eab3b Auto merge of #137036 - jieyouxu:drivers-license, r=Kobzol
Include version number of libs being built in cargo lib metadata (esp. `librustc_driver*.so`)

Previously, on a non-stable channel, it's possible for two builds from different versioned sources (e.g. 1.84.0 vs 1.84.1) to produce a `librustc_driver*.so` with the same filename hashes. This causes problems with side-by-side installs wrt. linker search paths because 1.84.1 rustc bin and 1.84.0 rustc bin may try to link to the "same" `librustc_driver*.so` (same filename hash) but fail because the contents of the so is actually different.

We try to mitigate this by including the version number of artifacts being built via `__CARGO_DEFAULT_LIB_METADATA` (kind of an ugly hack, but I don't think cargo has a way for us to tell cargo to use a package version override).

Fixes #136701 (mitigates, really).

### Testing

Tested manually[^host] by:

```bash
$ cat src/version
1.86.0
$ ./x build library # w/ compiler profile, (non-stable) dev channel
$ lddtree build/host/stage1/bin/rustc
rustc => build/host/stage1/bin/rustc (interpreter => /lib64/ld-linux-x86-64.so.2)
    librustc_driver-ea1b1b2291881cc4.so => build/host/stage1/bin/../lib/librustc_driver-ea1b1b2291881cc4.so
[...]
```

and observing that changing `src/version` to bump a point release causes `librustc_driver*.so` to have a different hash while sources are unmodified otherwise.

```bash
$ cat src/version
1.86.1
$ ./x build library # w/ compiler profile, (non-stable) dev channel
$ lddtree build/host/stage1/bin/rustc
rustc => build/host/stage1/bin/rustc (interpreter => /lib64/ld-linux-x86-64.so.2)
    librustc_driver-746badadbcb74721.so => build/host/stage1/bin/../lib/librustc_driver-746badadbcb74721.so
[...]
```

cc `@clan` `@demize` could you check that if you backport this change against 1.84.{0,1} as reported in #136701, that the produced `rustc` binary works, under the context of the Gentoo build system setup?

[^host]: on a `x86_64-unknown-linux-gnu` host, no cross
2025-02-26 09:42:41 +00:00
Jakub Beránek
ee8ed8c207
Update gcc submodule
To add support for the x87 feature.
2025-02-26 09:23:52 +01:00
bors
2b3cef882a Auto merge of #137651 - fmease:rollup-s3s7m6f, r=fmease
Rollup of 14 pull requests

Successful merges:

 - #136576 (pass optimization level to llvm-bitcode-linker)
 - #137154 (Add UTF-8 validation fast paths in `Wtf8Buf`)
 - #137311 (Enable `f16` for MIPS)
 - #137320 (fix(rustdoc): Fixed stability version in rustdoc)
 - #137529 (remove few unused args)
 - #137544 (tests: Add regression test for derive token invalidation (#81099))
 - #137559 (run some tests on emscripten again)
 - #137601 (ssa/mono: deduplicate `type_has_metadata`)
 - #137603 (codegen_llvm: avoid `Deref` impls w/ extern type)
 - #137604 (trait_sel: resolve vars in host effects)
 - #137609 (Complete the list of resources used in rustdoc output)
 - #137613 (hir_analysis: skip self type of host effect preds in variances_of)
 - #137614 (fix doc in library/core/src/pin.rs)
 - #137622 (fix attribute-related ICE when parsing macro on the rhs of a name-value attribute)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-26 06:21:59 +00:00
León Orell Valerian Liehr
1bb43192a2
Rollup merge of #137622 - jdonszelmann:fix-137589, r=compiler-errors
fix attribute-related ICE when parsing macro on the rhs of a name-value attribute

r? ``@oli-obk``

Closes: #137589
2025-02-26 04:15:09 +01:00
León Orell Valerian Liehr
0d4af0861e
Rollup merge of #137614 - xizheyin:issue-134874, r=cuviper
fix doc in library/core/src/pin.rs

Fixes #134874
2025-02-26 04:15:08 +01:00
León Orell Valerian Liehr
cf8498d36a
Rollup merge of #137613 - davidtwco:const-traits-variances, r=compiler-errors
hir_analysis: skip self type of host effect preds in variances_of

Discovered as part of an implementation of rust-lang/rfcs#3729 - w/out this then when introducing const trait bounds: many more interesting tests change with different output, missing errors, new errors, etc related to this but they all depend on feature flags and are much more complex than this test.

r? ``@oli-obk``
2025-02-26 04:15:08 +01:00
León Orell Valerian Liehr
a82ad9494c
Rollup merge of #137609 - ColinPitrat:master, r=GuillaumeGomez
Complete the list of resources used in rustdoc output

The Nanum Barun Gothic Font was missing in the list and should clearly be mentionned.

Arguably referencing the Rust logos is not really necessary as the file mentions "third party resources" but it doesn't hurt and should make things clearer for anybody who wants to publish their Rust doc.
2025-02-26 04:15:07 +01:00
León Orell Valerian Liehr
677295aa85
Rollup merge of #137604 - davidtwco:host-effect-resolve-vars, r=compiler-errors
trait_sel: resolve vars in host effects

In the standard library, the `Extend` impl for `Iterator` (specialised with `TrustedLen`) has a parameter which is constrained by a projection predicate. This projection predicate provides a value for an inference variable but - if the default bound is `const Sized` instead of `Sized` - host effect evaluation wasn't resolving variables first. Added a test that doesn't depend on a rust-lang/rfcs#3729 implementation.

Adding the extra resolve can the number of errors in some tests when they gain host effect predicates, but this is not unexpected as calls to `resolve_vars_if_possible` can cause more error tainting to happen.
2025-02-26 04:15:07 +01:00