1
Fork 0
Commit graph

277575 commits

Author SHA1 Message Date
Chris Denton
00448ab45a
Make bare-fn test less dependent on path width 2025-01-09 17:32:29 +00:00
bors
a580b5c379 Auto merge of #134523 - dingxiangfei2009:issue-130836-attempt-2, r=nikomatsakis
Run borrowck tests on BIDs and emit tail-expr-drop-order lints for violations

Fix #132861

r? `@nikomatsakis`
cc `@compiler-errors`

This patch enlarges the scope where the `tail-expr-drop-order` lint applies, so that all locals involved in tail expressions are inspected. This is necessary to run borrow-checking to capture the cases where it used to compile under Edition 2021 but is not going to pass borrow-checking from Edition 2024 onwards.

The way it works is to inspect each BID against the set of borrows that are still live. If the local involved in BID has a borrow index which happens to be live as well at the location of this BID statement, in the future this will be a borrow-checking violation. The lint will fire in this case.
2025-01-08 16:22:17 +00:00
Michael Goulet
c55eefe8bc Try to explain borrow for tail expr temporary drop order change in 2024 2025-01-08 16:02:44 +00:00
Michael Goulet
4a099b29cd Don't do AccessDepth::Drop for types with no drop impl 2025-01-08 15:58:10 +00:00
Michael Goulet
197f6d8081 Don't create cycles by normalizing opaques defined in the body we're checking 2025-01-08 15:58:10 +00:00
wieDasDing
13c7122df8 remove an extraneous comment
Co-authored-by: Rémy Rakic <remy.rakic+github@gmail.com>
2025-01-08 15:58:09 +00:00
Ding Xiang Fei
34edb21f0b apply suggestions on fn name 2025-01-08 15:58:09 +00:00
Ding Xiang Fei
045271cccc run borrowck tests on BIDs and emit tail-expr-drop-order lints for
potential violations
2025-01-08 15:58:09 +00:00
bors
6afee111c2 Auto merge of #133858 - dianne:better-blame-constraints-for-static, r=lcnr
`best_blame_constraint`: Blame better constraints when the region graph has cycles from invariance or `'static`

This fixes #132749 by changing which constraint is blamed for region errors in several cases. `best_blame_constraint` had a heuristic that tried to pinpoint the constraint causing an error by filtering out any constraints where the outliving region is unified with the ultimate target region being outlived. However, it used the SCCs of the region graph to do this, which is unreliable; in particular, if the target region is `'static`, or if there are cycles from the presence of invariant types, it was skipping over the constraints it should be blaming. As is the case in that issue, this could lead to confusing diagnostics. The simplest fix seems to work decently, judging by test stderr: this makes `best_blame_constraint` no longer filter constraints by their outliving region's SCC.

There are admittedly some quirks in the test output. In many cases, subdiagnostics that depend on the particular constraint being blamed have either started or stopped being emitted. After starting at this for quite a while, I think anything too fickle about whether it outputs based on the particular constraint being blamed should instead be looking at the constraint path as a whole, similar to what's done for [the placeholder-from-predicate note](https://github.com/rust-lang/rust/compare/master...dianne:rust:better-blame-constraints-for-static#diff-3c0de6462469af483c9ecdf2c4b00cb26192218ef2d5c62a0fde75107a74caaeR506).

Very many tests involving invariant types gained a note pointing out the types' invariance, but in a few cases it was lost. A particularly illustrative example is [tests/ui/lifetimes/copy_modulo_regions.stderr](https://github.com/rust-lang/rust/compare/master...dianne:rust:better-blame-constraints-for-static?expand=1#diff-96e1f8b29789b3c4ce2f77a5e0fba248829b97ef9d1ce39e7d2b4aa57b2cf4f0); I'd argue the new constraint is a better one to blame, but it lacks the variance diagnostic information that's elsewhere in the constraint path. If desired, I can try making that note check the whole path rather than just the blamed constraint.

The subdiagnostic [`BorrowExplanation::add_object_lifetime_default_note`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_borrowck/diagnostics/explain_borrow/enum.BorrowExplanation.html#method.add_object_lifetime_default_note) depends on a `Cast` being blamed, so [a special case](https://github.com/rust-lang/rust/pull/133858/commits/364ca7f99c12fb5220e6b568ac391979317ce878) was necessary to keep it from disappearing from tests specifically testing for it. However, see the FIXME comment in that commit; I think the special case should be removed once that subdiagnostic works properly, but it's nontrivial enough to warrant a separate PR. Incidentally, this removes the note from a test where it was being added erroneously: in [tests/ui/borrowck/two-phase-surprise-no-conflict.stderr](https://github.com/rust-lang/rust/compare/master...dianne:rust:better-blame-constraints-for-static?expand=1#diff-8cf085af8203677de6575a45458c9e6b03412a927df879412adec7e4f7ff5e14), the object lifetime is explicitly provided and it's not `'static`.
2025-01-08 12:37:54 +00:00
bors
9c87288a7d Auto merge of #135234 - jhpratt:rollup-4gvvo4y, r=jhpratt
Rollup of 8 pull requests

Successful merges:

 - #133057 (Impl String::into_chars)
 - #134389 (Condvar: implement wait_timeout for targets without threads)
 - #134920 (Convert typeck constraints in location-sensitive polonius)
 - #135032 (triagebot: register `relnotes-interest-group` ping group)
 - #135176 (More compelling env_clear() examples)
 - #135184 (Reserve x18 register for aarch64 wrs vxworks target)
 - #135203 (arm: add unstable soft-float target feature)
 - #135219 (warn about broken simd not only on structs but also enums and unions when we didn't opt in to it)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-08 07:06:22 +00:00
Jacob Pratt
485fae594c
Rollup merge of #135219 - matthiaskrgr:simd'nt, r=compiler-errors
warn about broken simd not only on structs but also enums and unions when we didn't opt in to it

addresses https://github.com/rust-lang/rust/issues/135208#issuecomment-2576015186

r? ``@Noratrieb``
2025-01-08 00:52:49 -05:00
Jacob Pratt
57eb95ca6f
Rollup merge of #135203 - RalfJung:arm-soft-float, r=workingjubilee
arm: add unstable soft-float target feature

This has an actual usecase as mentioned [here](https://github.com/rust-lang/rust/issues/116344#issuecomment-2575324988), and with my recent ARM float ABI changes there shouldn't be any soundness concerns any more. We will reject enabling this feature on `hf` targets, but disabling it on non-`hf` targets is entirely fine -- the target feature refers to whether softfloat emulation is used for float instructions, and is independent of the ABI which we set separately via `llvm_floatabi`.

Cc ``@workingjubilee``
2025-01-08 00:52:49 -05:00
Jacob Pratt
45250f367f
Rollup merge of #135184 - biabbas:reserve_18_aarch64, r=workingjubilee
Reserve x18 register for aarch64 wrs vxworks target

Fixes #135166
r? ``@workingjubilee``

Regards,
B I Abbas
2025-01-08 00:52:48 -05:00
Jacob Pratt
5fa7c6a97a
Rollup merge of #135176 - kornelski:env-example, r=cuviper
More compelling env_clear() examples

`ls` isn't a command that people usually set env vars for, and `PATH` in particular isn't even used by `ls`.
2025-01-08 00:52:48 -05:00
Jacob Pratt
a00bd69652
Rollup merge of #135032 - jieyouxu:relnotes-interest-group, r=cuviper
triagebot: register `relnotes-interest-group` ping group

Part of #133334.
https://github.com/rust-lang/team/pull/1613 merged.
cc T-release discussions in https://rust-lang.zulipchat.com/#narrow/channel/241545-t-release/topic/Please.20CC.20lang

r? release
2025-01-08 00:52:47 -05:00
Jacob Pratt
808c8f84c3
Rollup merge of #134920 - lqd:polonius-next-episode-6, r=jackh726
Convert typeck constraints in location-sensitive polonius

In this PR, we do a big chunk of the work of localizing regular outlives constraints.

The slightly annoying thing is handling effectful statements: usually the subset graph propagates loans at a single point between regions, and liveness propagates loans between points within a single region, but some statements have effects applied on exit.

This was also a problem before, in datalog polonius terms and Niko's solution at the time, this is about: the mid-point. The idea was to duplicate all MIR locations into two physical points, and orchestrate the effects with that. Somewhat easier to do, but double the CFG.

We've always believed we didn't _need_ midpoints in principle, as we can represent changes on exit as on happening entry to the successor, but there's some difficulty in tracking the position information at sufficient granularity through outlives relation (especially since we also have bidirectional edges and time-traveling now).

Now, that is surely what we should be doing in the future. In the mean time, I infer this from the kind of statement/terminator where an outlives constraint arose. It's not particularly complicated but some explanation will help clarify the code.

Assignments (in their various forms) are the quintessential example of these crossover cases: loans that would flow into the LHS would not be visible on entry to the point but on exit -- so we'll localize these edges to the successor. Let's look at a real-world example, involving invariance for bidirectional edges:

```rust
let mut _1: HashMap<i32, &'7 i32>;
let mut _3: &'9 mut HashMap<i32, &'10 i32>;
...
/* at bb1[3]: */ _3 = &'3 mut _1;
```

Here, typeck expectedly produces 3 outlives constraints today:
1. `'3 -> '9`
2. `'7 -> '10`
3. `'10 -> '7`

And we localize them like so,

1. `'3 -> '9` flows into the LHS and becomes: `3_bb1_3 -> 9_bb1_4`
2. `'7 -> '10` flows into the LHS and becomes: `7_bb1_3 -> 10_bb1_4`
3. `'10 -> '7` flows from the LHS and becomes: `10_bb1_4 -> 7_bb1_3` (time traveling 👌)

---

r? ``@jackh726``

To keep you entertained during the holidays I also threw in a couple of small changes removing cruft in the borrow checker.

We're actually getting there. The next PR will be the last one needed to get end-to-end tests working.
2025-01-08 00:52:46 -05:00
Jacob Pratt
5ed1fa84a5
Rollup merge of #134389 - rust-wasi-web:condvar-no-threads, r=m-ou-se
Condvar: implement wait_timeout for targets without threads

This always falls back to sleeping since there is no way to notify a condvar on a target without threads.

Even on a target that has no threads the following code is a legitimate use case:

```rust
use std::sync::{Condvar, Mutex};
use std::time::Duration;

fn main() {
    let cv = Condvar::new();
    let mutex = Mutex::new(());
    let mut guard = mutex.lock().unwrap();

    cv.notify_one();

    let res;
    (guard, res) = cv.wait_timeout(guard, Duration::from_secs(3)).unwrap();
    assert!(res.timed_out());
}
```
2025-01-08 00:52:45 -05:00
Jacob Pratt
e7ee58243a
Rollup merge of #133057 - tisonkun:into-chars, r=Amanieu
Impl String::into_chars

Tracking issue - https://github.com/rust-lang/rust/issues/133125

r? `@programmerjake` `@kennytm` `@Amanieu`

This refers to https://github.com/rust-lang/libs-team/issues/268

Before adding tests and creating a tracking issue, I'd like to reach a consensus on the implementation direction and two questions:

1. Whether we'd add a `String::into_char_indices` method also?
2. See inline comment.
2025-01-08 00:52:44 -05:00
bors
1f81f90689 Auto merge of #135207 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`

r? `@ghost`
2025-01-08 01:08:24 +00:00
bors
07074990a9 Auto merge of #135218 - matthiaskrgr:rollup-xngklx8, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #133810 (remove unnecessary `eval_verify_bound`)
 - #134745 (Normalize each signature input/output in `typeck_with_fallback` with its own span)
 - #134989 (Lower Guard Patterns to HIR.)
 - #135149 (Use a post-monomorphization typing env when mangling components that come from impls)
 - #135171 (rustdoc: use stable paths as preferred canonical paths)
 - #135200 (rustfmt: drop nightly-gating of the `--style-edition` flag registration)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-07 22:16:04 +00:00
Matthias Krüger
5dd21df7c1
Rollup merge of #135200 - jieyouxu:stabilize-style-edition, r=ytmimi,compiler-errors
rustfmt: drop nightly-gating of the `--style-edition` flag registration

Follow-up to [Stabilize `style_edition = "2024"` in-tree #134929](https://github.com/rust-lang/rust/pull/134929).

#134929 un-nightly-gated the *read* of `--style-edition`, but didn't also un-nightly-gate the *registration*/*declaration* of the `--style-edition` flag itself. Reading `--style-edition` on a non-nightly channel (e.g. beta) will thus panic because `--style-edition` is never declared.

This PR also un-nightly-gates the registration. Not sure how to write a regression test for this, because this *requires* the non-nightly / beta channel. Though existing tests do fail (albeit indirectly).

Checking if this fixes the panic against beta in https://github.com/rust-lang/rust/pull/135197.

r? rustfmt
2025-01-07 21:39:42 +01:00
Matthias Krüger
0e48e96e65
Rollup merge of #135171 - notriddle:notriddle/stable-path-is-better, r=GuillaumeGomez
rustdoc: use stable paths as preferred canonical paths

This accomplishes something like 16a4ad7d7b, but with the `rustc_allowed_through_unstable_modules` attribute instead of the path length.

Fixes #131676
2025-01-07 21:39:41 +01:00
Matthias Krüger
3e12d4d152
Rollup merge of #135149 - compiler-errors:mangle, r=oli-obk
Use a post-monomorphization typing env when mangling components that come from impls

When mangling associated methods of impls, we were previously using the wrong param-env. Instead of using a fully monomorphized param-env like we usually do in codegen, we were taking the post-analysis param-env, and treating it as an early binder to *re-substitute* the impl args. I've pointed out the problematic old code in an inline comment.

This would give us param-envs with possibly trivial predicates that would prevent normalization via param-env shadowing.

In the example test linked below, `tests/ui/symbol-names/normalize-in-param-env.rs`, this happens when we mangle the impl `impl<P: Point2> MyFrom<P::S> for P` with the substitution `P = Vec2`. Because the where clause of the impl is `P: Point2`, which elaborates to `[P: Point2, P: Point, <P as Point>::S projects-to <P as Point2>::S2]` and the fact that `impl Point2 for Vec2` normalizes `Vec2::S2` to `Vec2::S`, this causes a cycle.

The proper fix here is to use a fully monomorphized param-env for the case where the impl is properly substituted.

Fixes #135143

While #134081 uncovered this bug for legacy symbol mangling, it was preexisting for v0 symbol mangling. This PR fixes both. The test requires a "hack" because we strip the args of the instance we're printing for legacy symbol mangling except for drop glue, so we box a closure to ensure we generate drop glue.

r? oli-obk
2025-01-07 21:39:41 +01:00
Matthias Krüger
a20d0d5a5c
Rollup merge of #134989 - max-niederman:guard-patterns-hir, r=oli-obk
Lower Guard Patterns to HIR.

Implements lowering of [guard patterns](https://rust-lang.github.io/rfcs/3637-guard-patterns.html) (see the [tracking issue](#129967)) to HIR.
2025-01-07 21:39:40 +01:00
Matthias Krüger
c371a94e78
Rollup merge of #134745 - compiler-errors:better-arg-span-in-typeck, r=BoxyUwU
Normalize each signature input/output in `typeck_with_fallback` with its own span

Applies the same hack as #106582 but to the args in typeck. Greatly improves normalization error spans from a signature.
2025-01-07 21:39:39 +01:00
Matthias Krüger
191fb23940
Rollup merge of #133810 - lcnr:remove-verify_bound, r=compiler-errors
remove unnecessary `eval_verify_bound`

This does not impact any tests. I feel like any cases where this could useful should instead be fixed by a general improvement to `eval_verify_bound` to avoid having to promote this `TypeTest` in the first place 🤔

r? types cc ``@nikomatsakis``
2025-01-07 21:39:38 +01:00
Matthias Krüger
b9d6e9e73f warn about broken simd not only on structs but also enums and unions when we didn't opt in to it 2025-01-07 21:36:37 +01:00
Laurențiu Nicola
fd1e95538f
Merge pull request #18874 from lnicola/sync-from-rust
minor: Sync from downstream
2025-01-07 16:13:25 +00:00
Laurențiu Nicola
e103ab1608 Merge from rust-lang/rust 2025-01-07 17:57:53 +02:00
Laurențiu Nicola
aa1ef0a432 Preparing for merge from rust-lang/rust 2025-01-07 17:57:18 +02:00
bors
ad211ced81 Auto merge of #135202 - GuillaumeGomez:rollup-9xgs39t, r=GuillaumeGomez
Rollup of 9 pull requests

Successful merges:

 - #135081 (bootstrap: Build jemalloc with support for 64K pages)
 - #135174 ([AIX] Port test case run-make/reproducible-build )
 - #135177 (llvm: Ignore error value that is always false)
 - #135182 (Transmute from NonNull to pointer when elaborating a box deref (MCP807))
 - #135187 (apply a workaround fix for the release roadblock)
 - #135189 (Remove workaround from pull request template)
 - #135193 (don't bless `proc_macro_deps.rs` unless it's necessary)
 - #135198 (Avoid naming variables `str`)
 - #135199 (Eliminate an unnecessary `Symbol::to_string`; use `as_str`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-07 15:22:00 +00:00
Ralf Jung
427abb69bf arm: add unstable soft-float target feature 2025-01-07 16:13:43 +01:00
Guillaume Gomez
225ffebc0a
Rollup merge of #135199 - joshtriplett:unnecessary-to-string, r=lqd
Eliminate an unnecessary `Symbol::to_string`; use `as_str`
2025-01-07 15:30:28 +01:00
Guillaume Gomez
ec266207cb
Rollup merge of #135198 - joshtriplett:str-is-a-type, r=jieyouxu
Avoid naming variables `str`

This renames variables named `str` to other names, to make sure `str`
always refers to a type.

It's confusing to read code where `str` (or another standard type name)
is used as an identifier. It also produces misleading syntax
highlighting.
2025-01-07 15:30:28 +01:00
Guillaume Gomez
ccaa0f331c
Rollup merge of #135193 - onur-ozkan:tidy-cache-invalidation, r=jieyouxu
don't bless `proc_macro_deps.rs` unless it's necessary

Running tidy with `--bless` flag is breaking the build cache as tidy updates mtime of `proc_macro_deps.rs` (https://github.com/rust-lang/rust/pull/134865) unconditionally and that leads cargo to recompile tidy.

This patch fixes that.
2025-01-07 15:30:27 +01:00
Guillaume Gomez
ebf2e51c3e
Rollup merge of #135189 - Urgau:triagebot-html-ignored, r=lqd
Remove workaround from pull request template

This PR removes the workaround (`\`) from our pull request template as triagebot/rustbot now ignores HTML blocks.

cf. https://github.com/rust-lang/triagebot/pull/1869
cc `@jieyouxu`
r? `@ehuss`
2025-01-07 15:30:27 +01:00
Guillaume Gomez
2598d607b5
Rollup merge of #135187 - onur-ozkan:release-fix, r=pietroalbini
apply a workaround fix for the release roadblock

This has been a problem since the last two releases.

r? pietroalbini
2025-01-07 15:30:26 +01:00
Guillaume Gomez
a33da79fa9
Rollup merge of #135182 - scottmcm:box-deref-via-transmute, r=oli-obk
Transmute from NonNull to pointer when elaborating a box deref (MCP807)

Since per https://github.com/rust-lang/compiler-team/issues/807 we have to stop projecting into `NonNull`.

cc https://github.com/rust-lang/rust/issues/133652
2025-01-07 15:30:25 +01:00
Guillaume Gomez
020d8758f4
Rollup merge of #135177 - maurer:rename-module, r=nikic
llvm: Ignore error value that is always false

See llvm/llvm-project#121851

For LLVM 20+, this function (`renameModuleForThinLTO`) has no return value. For prior versions of LLVM, this never failed, but had a signature which allowed an error value people were handling.

`@rustbot` label: +llvm-main
r? `@nikic`

Wait a moment before approving while the llvm-main infrastructure picks it up.
2025-01-07 15:30:25 +01:00
Guillaume Gomez
2338e573e1
Rollup merge of #135174 - xingxue-ibm:reproducible-build-aix, r=jieyouxu
[AIX] Port test case run-make/reproducible-build

The test case `run-make/reproducible-build` verifies that two identical invocations of the compiler produce the same output by comparing the linker arguments, resulting binaries, and other artifacts. However, the AIX linker command includes an argument that specifies the file containing exported symbols, with a file path that contains a randomly generated substring to prevent collisions between different linking processes. Additionally, the AIX XCOFF file header includes a 4-byte timestamp. This PR replaces the random substring with a placeholder and nullifies the timestamp field in the XCOFF files for the comparisons.
2025-01-07 15:30:24 +01:00
Guillaume Gomez
2b97db2ff7
Rollup merge of #135081 - mrkajetanp:jemalloc-64k, r=Kobzol
bootstrap: Build jemalloc with support for 64K pages

By default, jemalloc is built to only support the same page size as the host machine. Set an env variable so that jemalloc is built with support for page sizes up to 64K regardless of the host machine.

r? `@Kobzol`

Resolves #134563
Potentially resolves #133748 (needs verification)

----

Results from local rustc-perf testing below, within 0.5% on every metric except max-rss.
AArch64:
![Screenshot 2025-01-03 at 5 53 13 pm](https://github.com/user-attachments/assets/71705c59-7d7b-4753-a184-8c784233e603)
x86_64:
![Screenshot 2025-01-03 at 5 54 16 pm](https://github.com/user-attachments/assets/ea28aded-3b90-43f4-a965-b081b07b95ab)
2025-01-07 15:30:23 +01:00
Lukas Wirth
8e4409cce3
Merge pull request #18870 from Veykril/push-vnpsptpolyol
Drop unnecessary tracing::warn
2025-01-07 13:55:28 +00:00
Lukas Wirth
21faec1fec
Merge pull request #18867 from Veykril/push-ntmxlropxkrr
internal: target-triple -> target-tuple + version fetching cleanup
2025-01-07 13:46:58 +00:00
Lukas Wirth
b039d3fc5c Drop unnecessary tracing::warn
We already emit an error
2025-01-07 14:40:00 +01:00
Lukas Wirth
380439c5f3 Add some smoke tests to toolchain_info 2025-01-07 14:33:24 +01:00
Lukas Wirth
d28a0b8fcd Align toolchain version fetching with other toolchain info querying
Fix --target flag argument order in rustc_cfg fetching
2025-01-07 14:30:46 +01:00
Lukas Wirth
05770f2599 target-triple -> target-tuple 2025-01-07 14:25:43 +01:00
Lukas Wirth
c360bf5517
Merge pull request #18788 from Veykril/push-zxystwnotuvq
Remove `rust-analyzer.cargo.sysrootQueryMetadata` config again
2025-01-07 13:14:29 +00:00
Lukas Wirth
764ce49445 Remove rust-analyzer.cargo.sysrootQueryMetadata config again 2025-01-07 14:00:22 +01:00
许杰友 Jieyou Xu (Joe)
b77eb96baa rustfmt: drop nightly-gating of the --style-edition flag registration 2025-01-07 20:49:29 +08:00