Commit Graph

291081 Commits

Author SHA1 Message Date
Matthias Krüger
7412a7c833 Rollup merge of #141288 - yotamofek:pr/rustdoc/nuke-bufdisplay, r=GuillaumeGomez
Get rid of unnecessary `BufDisplay` abstraction

r? `@GuillaumeGomez` , since you reviewed the introduction of `BufDisplay` in #136784 . Not sure when it became unnecessary, but it did :)
(feel free to reassign if you wish)
2025-05-20 20:57:27 +02:00
Matthias Krüger
8e1ce2059d Rollup merge of #141282 - DJMcNab:core-float-math-math, r=tgross35
`core_float_math`: Move functions to `math` module

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 the `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.

I believe that I've made the module unstable correctly. I presume that this does not require a test to make sure stable code can't depend on the module existing?

I've left the stability attribute on each function - happy to tweak this if a different pattern is more correct.

Tracking issue for `core_float_math`: https://github.com/rust-lang/rust/issues/137578.
This PR is as requested in https://github.com/rust-lang/rust/pull/138087.

r? `@tgross35`

Recommended reviewing with whitespace hidden.

(This is my first PR to `std/core`/this repository, as far as I can remember)
2025-05-20 20:57:27 +02:00
Matthias Krüger
221d6c734c Rollup merge of #140972 - Stypox:machine-tracing-flag, r=RalfJung
Add TRACING_ENABLED to Machine and add enter_trace_span!()

This PR adds the necessary infrastructure to make it possible to do tracing calls from within `rustc_const_eval` when running Miri, while making sure they don't impact the performance of normal compiler execution. This is done by adding a `const` boolean to `Machine`, false by default, but that will be set to true in Miri only. The tracing macro `enter_trace_span!()` checks if it is true before doing anything, and since the value of a `const` is known at compile time, if it it false it the whole tracing call should be optimized out.

I will soon open further PRs to add tracing macro calls similar to this one, so that afterwards it will be possible to learn more about Miri's time spent in the various interpretation steps:
```rs
let _guard = enter_trace_span!(M, "eval_statement", "{:?}", stmt);
```

r? `@RalfJung`
2025-05-20 20:57:26 +02:00
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
Boxy
f499cd0000 Merge pull request #2400 from smanilov/patch-13
Make it clear we talk about early bound params
2025-05-20 16:36:21 +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
Boxy
1710217ebe Merge pull request #2398 from smanilov/patch-12
Update links between ty-module and binders
2025-05-20 16:18:22 +01: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
Stan Manilov
50211e008e Make it clear we talk about early bound params 2025-05-20 16:25:11 +03: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
Marcelo Domínguez
b21c9e7bfb Split autodiff into autodiff_forward and autodiff_reverse
Pending fix.
```
error: cannot find a built-in macro with name `autodiff_forward`
    --> library\core\src\macros\mod.rs:1542:5
     |
1542 | /     pub macro autodiff_forward($item:item) {
1543 | |         /* compiler built-in */
1544 | |     }
     | |_____^

error: cannot find a built-in macro with name `autodiff_reverse`
    --> library\core\src\macros\mod.rs:1549:5
     |
1549 | /     pub macro autodiff_reverse($item:item) {
1550 | |         /* compiler built-in */
1551 | |     }
     | |_____^

error: could not compile `core` (lib) due to 2 previous errors
```
2025-05-20 11:58:26 +00:00
León Orell Valerian Liehr
1944bce61a Merge pull request #2399 from steffahn/fix-tenv-link
Fix misdirected link for `TypingEnv`
2025-05-20 13:57:50 +02:00
Michael Goulet
6555ef7f09 Querify coroutine_hidden_types 2025-05-20 11:50:25 +00:00
Frank Steffahn
a611f5016a Fix misdirected link for TypingEnv 2025-05-20 13:26:22 +02:00
Stan Manilov
2754f18199 Update links between ty-module and binders
The order might have been reversed at some point, leading to the two
chapters talking about each other in the wrong order.
2025-05-20 13:52:33 +03: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
yanglsh
520cb092b8 Apply needless_for_each to clippy itself 2025-05-20 18:07:57 +08:00
yanglsh
e5617a79fb fix: needless_for_each suggests wrongly when closure has no braces 2025-05-20 18:07:57 +08: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
nora
33aa48c1f3 Merge pull request #2396 from smanilov/patch-11
Small typo and style fixes in  binders.md
2025-05-20 11:10:30 +02:00
Stan Manilov
0653799745 Small typo and style fixes in binders.md
Normally I refrain from nit picking, but this seamed worth it.
2025-05-20 11:41:55 +03: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