Commit Graph

290443 Commits

Author SHA1 Message Date
Urgau
b8732aaa4d Fix pagetoc inactive color in rustc book 2025-05-20 20:03:17 +02:00
bohan
097b7a2ac7 collect doc alias as tips during resolution 2025-05-21 00:47:36 +08:00
Josh Triplett
17fdf19c9c CommandExt::chroot: Add tracking issue 2025-05-20 18:25:06 +02:00
Josh Triplett
c3b750ce0f CommandExt::chroot: Document difference to underlying chroot 2025-05-20 18:25:06 +02:00
Josh Triplett
a3cf6f6408 Add std::os::unix::process::CommandExt::chroot to safely chroot a child process
This adds a `chroot` method to the `CommandExt` extension trait for the
`Command` builder, to set a directory to chroot into. This will chroot
the child process into that directory right before calling chdir for the
`Command`'s working directory.

To avoid allowing a process to have a working directory outside of the
chroot, if the `Command` does not yet have a working directory set,
`chroot` will set its working directory to "/".
2025-05-20 18:25:05 +02:00
bors
444a62712a Auto merge of #141292 - matthiaskrgr:rollup-9nhhk7k, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #139419 (Error on recursive opaque ty in HIR typeck)
 - #141236 (Resolved issue with mismatched types triggering ICE in certain scenarios)
 - #141253 (Warning added when dependency crate has async drop types, and the feature is disabled)
 - #141269 (rustc-dev-guide subtree update)
 - #141275 (`gather_locals`: only visit guard pattern guards when checking the guard)
 - #141279 (`lower_to_hir` cleanups)
 - #141285 (Add tick to `RePlaceholder` debug output)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-20 15:48:56 +00:00
Daniel McNab
f6709bb683 core_float_math: Move functions to math folder
When these functions were added in
https://github.com/rust-lang/rust/pull/138087
It made a relatively common pattern for emulating
these functions using an extension trait (which
internally uses `libm`) much more fragile.
If `core::f32` happened to be imported by the user
(to access a constant, say), then that import in
the module namespace would take precedence over
`f32` in the type namespace for resolving these
functions, running headfirst into the stability
attribute.

We ran into this in Color -
https://github.com/linebender/color - and chose to
release the remedial 0.3.1 and 0.2.4, to allow
downstream crates to build on `docs.rs`.
As these methods are perma-unstable, moving them
into a new module should not have any long-term
concerns, and ensures that this breakage doesn't
adversely impact anyone else.
2025-05-20 16:41:43 +01:00
Stypox
28db348fdd Add enter_trace_span!() that checks if tracing is enabled 2025-05-20 17:28:30 +02:00
binarycat
c506046ba2 triagebot: ping me if rustdoc js is modified 2025-05-20 10:22:13 -05:00
stefnotch
8e3d0b2b03 Update availability of Cranelift (#1579)
- include source
2025-05-20 17:17:36 +02:00
Matthias Krüger
cc0ee34b43 Rollup merge of #141285 - compiler-errors:tick, r=lcnr
Add tick to `RePlaceholder` debug output

Present when debug printing canonical queries

r? lcnr
2025-05-20 16:50:43 +02:00
Matthias Krüger
3b9ccbbaf1 Rollup merge of #141279 - nnethercote:lower_to_hir, r=compiler-errors
`lower_to_hir` cleanups

Some minor cleanups I made when reading this code.

r? `@Nadrieril`
2025-05-20 16:50:42 +02:00
Matthias Krüger
ac500add80 Rollup merge of #141275 - dianne:gather-guard-pat-locals-once, r=compiler-errors
`gather_locals`: only visit guard pattern guards when checking the guard

When checking a pattern with guards in it, `GatherLocalsVisitor` will visit both the pattern (when type-checking the let, arm, or param containing it) and local declarations in the guard expression (when checking the guard itself). This keeps it from visiting the guard when visiting the pattern, since otherwise it would gather locals from the guard twice, which would lead to a delayed bug: "evaluated expression more than once".

Tracking issue for guard patterns: #129967
2025-05-20 16:50:41 +02:00
Matthias Krüger
1f54e14cd5 Rollup merge of #141269 - tshepang:rdg-push, r=jieyouxu
rustc-dev-guide subtree update

r? `@ghost`
2025-05-20 16:50:41 +02:00
Matthias Krüger
5364668fb5 Rollup merge of #141253 - azhogin:azhogin/async-drop-feature-inconsistency-warning, r=oli-obk
Warning added when dependency crate has async drop types, and the feature is disabled

In continue of https://github.com/rust-lang/rust/pull/141031.

When dependency crate has non-empty `adt_async_destructor` table in metadata, and `async_drop` feature is disabled for local crate, warning will be emitted.

Test `dependency-dropped` has two revisions - with and without feature enabled. With feature enabled, async drop for dropee is executed ("Async drop" printed). Without the feature enabled, sync drop is executed ("Sync drop" printed) and warning is emitted.

Warning example:
```
warning: found async drop types in dependecy `async_drop_dep`, but async_drop feature is disabled for `dependency_dropped`
  --> $DIR/dependency-dropped.rs:7:1
   |
LL | #![cfg_attr(with_feature, feature(async_drop))]
   | ^
   |
   = help: if async drop type will be dropped in a crate without `feature(async_drop)`, sync Drop will be used
```
2025-05-20 16:50:40 +02:00
Matthias Krüger
42ed69c756 Rollup merge of #141236 - jagunter:issue-140823, r=compiler-errors
Resolved issue with mismatched types triggering ICE in certain scenarios

## Background

The function `annotate_mut_binding_to_immutable_binding` called in `emit_coerce_suggestions` performs a type comparison between the `expected` and `found` types from `ExpectedFound` in the `TypeError`. This can fail if the `found` type contains a region variable that's been rolled back.

## What is being changed?

This updates `annotate_mut_binding_to_immutable_binding` to use `expr_ty` and `expected` from the parent function instead of the types from the `TypeError`. This sidesteps the issue of using `found` from `TypeError` which may leak lingering inference region variables.

This does change the diagnostic behavior to _only_ support cases where the expected outermost type is `&T`, but that seems to be the intended functionality.

Also fixed the example in the `annotate_mut_binding_to_immutable_binding` rustdocs.

r? rust-lang/types

Fixes #140823
2025-05-20 16:50:39 +02:00
Matthias Krüger
7e3af744bb Rollup merge of #139419 - compiler-errors:recursive-opaque, r=lcnr
Error on recursive opaque ty in HIR typeck

"Non-trivially recursive" opaques are opaques whose hidden types are inferred to be equal to something other than themselves. For example, if we have a TAIT like `type TAIT = impl Sized`, if we infer the hidden type to be `TAIT := (TAIT,)`, that would be a non-trivial recursive definition. We don't want to support opaques that are non-trivially recursive, since they will (almost!! -- see caveat below) always result in borrowck errors, and are generally a pain to deal with.

On the contrary, trivially recursive opaques may occur today because the old solver overagerly uses `replace_opaque_types_with_inference_vars`. This infer var can then later be constrained to be equal to the opaque itself. These cases will not necessarily result in borrow-checker errors, since other uses of the opaque may properly constrain the opaque. If there are no other uses we may instead fall back to `()` today.

The only weird case that we have to unfortunately deal with was discovered in https://github.com/rust-lang/rust/issues/139406:

```rust
#![allow(unconditional_recursion)]

fn what1<T>(x: T) -> impl Sized {
    what1(x)
}

fn what2<T>(x: T) -> impl Sized {
    what2(what2(x))
}

fn print_return_type<T, U>(_: impl Fn(T) -> U) {
    println!("{}", std::any::type_name::<U>())
}

fn main() {
    print_return_type(what1::<i32>); // ()
    print_return_type(what2::<i32>); // i32
}
```

> HIR typeck eagerly replaces the return type with an infer var, ending up with `RPIT<T> = RPIT<RPIT<T>>` in the storage. While we return this in the `TypeckResults`, it's never actually used anywhere.
>
> MIR building then results in the following statement
> ```rust
> let _0: impl RPIT<T> /* the return place */ = build<RPIT<T>>(_some_local);
> ```
> Unlike HIR typeck MIR typeck now directly equates `RPIT<T>` with `RPIT<RPIT<T>>`. This does not try to define `RPIT` but instead relates its generic arguments b9856b6e40/compiler/rustc_infer/src/infer/relate/type_relating.rs (L185-L190)
>
> This means we relate `T` with `RPIT<T>`, which results in a defining use `RPIT<T> = T`

I think it's pretty obvious that this is not desirable behavior, and according to the crater run there were no regressions, so let's break this so that we don't have any inference hazards in the new solver.

In the future `what2` may end up compiling again by also falling back to `()`. However, that is not yet guaranteed and the transition to this state is made significantly harder by not temporarily breaking it on the way. It is also concerning to change the inferred hidden type like this without any notification to the user, even if likely not an issue in this concrete case.
2025-05-20 16:50:38 +02:00
Dan Johnson
b68ebd04a5 link tracking issue in explicit-extern-abis.md 2025-05-20 07:40:52 -07:00
Michael Goulet
7b5ea0e7f5 use Self alias in self types rather than manually substituting it 2025-05-20 16:03:04 +02:00
Yotam Ofek
8682dfc7a3 Get rid of unnecessary BufDisplay abstraction 2025-05-20 13:20:29 +00:00
Yotam Ofek
7a68021dfc Replace some unwraps with ?s where possible 2025-05-20 13:19:39 +00:00
Yotam Ofek
29d97cdabe Make some fns return fmt::Result to get rid of a few unwraps 2025-05-20 13:18:23 +00:00
MarcoIeni
a8173fcd1f ci: split powerpc64le-linux job 2025-05-20 15:16:29 +02:00
bjorn3
4c39287e34 Update to Cranelift 0.120 2025-05-20 12:59:03 +00:00
bors
6cab15c1ae Auto merge of #140932 - onur-ozkan:llvm-tools, r=Kobzol
update llvm-tools logic for `dist` and `install` steps

First commit aligns `build_steps::compile` and `build_steps::dist` logics for copying llvm-tools, and the second commit adds the correct `should_run` condition for `LlvmTools` step as the previous one was clearly incorrect.

Fixes #140913
2025-05-20 12:44:14 +00:00
bjorn3
81af658cb3 Make clif ir debug output a bit nicer 2025-05-20 12:16:04 +00:00
Michael Goulet
6555ef7f09 Querify coroutine_hidden_types 2025-05-20 11:50:25 +00:00
Michael Goulet
1d8db54f76 Add tick to RePlaceholder debug output 2025-05-20 10:30:07 +00:00
Michael Goulet
37260e1c5b Allow trailing comma after argument in query definition 2025-05-20 10:22:08 +00:00
Michael Goulet
47b9e373cb Revert "Fix stack overflow in exhaustiveness due to recursive HIR opaque type values"
This reverts commit b08e9c2a60.
2025-05-20 10:09:01 +00:00
Michael Goulet
7e7c2c3947 Just error on recursive opaque ty in HIR typeck 2025-05-20 10:08:56 +00:00
bjorn3
04c7e5a7e3 Rustup to rustc 1.89.0-nightly (60dabef95 2025-05-19) 2025-05-20 09:43:45 +00:00
bors
28174fc1a0 Auto merge of #141278 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`

r? `@ghost`
2025-05-20 09:28:44 +00:00
Jason Newcomb
f00c58b374 Make lint span smaller for needless return (#14790)
Fixes rust-lang/rust-clippy#14750 by reducing the lint span for
needless_return.

changelog: [`needless_return`]: Lint span no longer wraps to previous
line
2025-05-20 09:23:56 +00:00
Jakub Beránek
eb530325f0 Use Docker cache from the current repository
This is needed to make the cache work after moving CI from the `rust-lang-ci` org to `rust-lang`.
2025-05-20 10:39:34 +02:00
Laurențiu Nicola
2147783b79 Merge pull request #19826 from lnicola/sync-from-rust
minor: Sync from downstream
2025-05-20 07:15:48 +00:00
Laurențiu Nicola
a667495297 Bump rustc crates 2025-05-20 10:03:14 +03:00
Laurențiu Nicola
50a6c5b789 Merge from rust-lang/rust 2025-05-20 10:01:00 +03:00
Laurențiu Nicola
1dafeea8cf Preparing for merge from rust-lang/rust 2025-05-20 10:00:23 +03:00
Ralf Jung
49482caad2 Merge pull request #4335 from RalfJung/rustup
Rustup
2025-05-20 06:30:54 +00:00
dianne
c343b2a47c gather_locals: only visit guard pattern guards when checking the guard
When checking a pattern with guards in it, `GatherLocalsVisitor` will
visit both the pattern (when type-checking the let, arm, or param
containing it) and the guard expression (when checking the guard
itself). This keeps it from visiting the guard when visiting the
pattern, since otherwise it would gather locals from the guard twice,
which would lead to a delayed bug: "evaluated expression more than
once".
2025-05-19 23:18:08 -07:00
bors
f8e9e7636a Auto merge of #139916 - RalfJung:intrinsic-wrappers, r=Mark-Simulacrum
make std::intrinsics functions actually be intrinsics

Most of the functions in `std::intrinsics` are actually intrinsics, but some are not: for historical reasons, `std::intrinsics::{copy,copy_nonoverlapping,write_bytes}` are accessible on stable, and the versions in `std::ptr` are just re-exports. These functions are not intrinsics, but wrappers around the intrinsic, because they add extra debug assertions.

This PR makes the functions in `std::intrinsics` actually be intrinsics.
- The advantage is that we can now use it in tests that need to directly call the intrinsic, thus removing a footgun for compiler development. We also remove the extended user-facing doc comments of these functions out of a file that should be largely internal documentation.
- The downside is that if users are using those functions directly, they will not get the debug assertions any more. Note however that those users are already ignoring a deprecation warning, so I think this is fine. Furthermore, if someone imports the `intrinsic` name of this function and turns that into a function pointer, that will no longer work, since only the wrapper functions can be turned into a function pointer. I would be rather surprised if anyone did this, though... and again, they must have already ignored a deprecation warning. Still, seems worth a crater run, if there's general agreement that we want to go ahead with this change.

(`intrinsics::drop_in_place` also remains not-an-intrinsic, which bugs me, but oh well, not much we can do about it; we can't remove it from the module as the path is accidentally-stable.)

Cc `@rust-lang/libs-api` `@saethlin`
2025-05-20 06:12:41 +00:00
xizheyin
4ec991989a Add println! test for sugg-field-in-format-string-issue-141136
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-20 14:10:17 +08:00
Ralf Jung
a29756d085 make std::intrinsic functions actually be intrinsics 2025-05-20 08:09:16 +02:00
Ralf Jung
b13251e923 Merge from rustc 2025-05-20 08:04:42 +02:00
Ralf Jung
969a25b6ce Preparing for merge from rustc 2025-05-20 08:02:40 +02:00
Nicholas Nethercote
8a927e63ff Inline and remove lower_* methods.
They are all short and have a single call site.
2025-05-20 14:13:33 +10:00
Nicholas Nethercote
7c62e78cf9 Hoist ItemLowerer out of a loop. 2025-05-20 14:04:24 +10:00
Nicholas Nethercote
0c0b2cbcb5 Remove unused return value from lower_node. 2025-05-20 14:01:58 +10:00
bors
a8e4c68dcb Auto merge of #141270 - Zalathar:rollup-jd1y1f6, r=Zalathar
Rollup of 5 pull requests

Successful merges:

 - #141211 (Replace `try_reserve_exact` with `try_with_capacity` in `std::fs::read`)
 - #141257 (trim cache module in utils bootstrap)
 - #141259 (Update books)
 - #141261 (current_dll_path: fix mistake in assertion message)
 - #141262 (Properly remove Noratrieb from review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-20 02:56:53 +00:00