about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2024-04-25Only suggest `split_at_mut` on indexing borrowck errors for std typesEsteban Küber-13/+23
2024-04-25Detect borrow error involving sub-slices and suggest `split_at_mut`Esteban Küber-18/+57
``` error[E0499]: cannot borrow `foo` as mutable more than once at a time --> $DIR/suggest-split-at-mut.rs:13:18 | LL | let a = &mut foo[..2]; | --- first mutable borrow occurs here LL | let b = &mut foo[2..]; | ^^^ second mutable borrow occurs here LL | a[0] = 5; | ---- first borrow later used here | = help: use `.split_at_mut(position)` or similar method to obtain two mutable non-overlapping sub-slices ``` Address most of #58792. For follow up work, we should emit a structured suggestion for cases where we can identify the exact `let (a, b) = foo.split_at_mut(2);` call that is needed.
2024-04-25Auto merge of #124058 - TechVest:master, r=fmeasebors-5/+5
Fix some typos in comments
2024-04-25Auto merge of #124368 - RalfJung:miri, r=RalfJungbors-516/+3265
Miri subtree update r? `@ghost`
2024-04-25update lockfileRalf Jung-2/+4
2024-04-25Auto merge of #3514 - RalfJung:hyperfine, r=RalfJungbors-6/+6
CI: run benches with hyperfine rather than bash The hyperfine installation is cached so this should not cost a lot of CI time. This is step 1/2 to getting rid of the BASH variable hack.
2024-04-25CI: run benches with hyperfine rather than bashRalf Jung-6/+6
2024-04-25Auto merge of #119650 - chenyukang:yukang-fix-118596-ref-mut, r=wesleywiserbors-41/+164
Suggest ref mut for pattern matching assignment Fixes #118596
2024-04-25Auto merge of #3501 - RalfJung:tls-many-seeds, r=RalfJungbors-12/+47
add a test for the TLS memory leak This is a regression test for https://github.com/rust-lang/rust/issues/123583.
2024-04-25run many-seeds tests at least a few times on all tier 1 targetsRalf Jung-11/+28
2024-04-25add a test for the TLS memory leakRalf Jung-0/+13
2024-04-25weak memory outdated loads: show where the load was fromRalf Jung-5/+10
2024-04-25Auto merge of #3512 - RalfJung:miri-script-build, r=RalfJungbors-1/+3
make miri-script a workspace root This is needed to make miri-script build on stable (as is done by the `./miri` script) when the parent package uses unstable cargo features.
2024-04-25Auto merge of #3513 - rust-lang:rustup-2024-04-25, r=RalfJungbors-2829/+4213
Automatic Rustup
2024-04-25Auto merge of #124360 - matthiaskrgr:rollup-k6bffhd, r=matthiaskrgrbors-193/+256
Rollup of 3 pull requests Successful merges: - #124257 (Rewrite the `no-input-file.stderr` test in Rust and support diff) - #124324 (Minor AST cleanups) - #124327 (CI: implement job skipping in Python matrix calculation) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-25Auto merge of #3505 - RalfJung:ci, r=RalfJungbors-1/+1
CI: don't run cron-fail-notify when the job just got canceled Doesn't seem right to prepare a PR in that case
2024-04-25fmtThe Miri Cronjob Bot-80/+149
2024-04-25Merge from rustcThe Miri Cronjob Bot-2769/+4084
2024-04-25Preparing for merge from rustcThe Miri Cronjob Bot-1/+1
2024-04-25Auto merge of #121298 - nikic:writable, r=cuviperbors-4/+33
Set writable and dead_on_unwind attributes for sret arguments Set the `writable` and `dead_on_unwind` attributes for `sret` arguments. This allows call slot optimization to remove more memcpy's. See https://llvm.org/docs/LangRef.html#parameter-attributes for the specification of these attributes. In short, the statement we're making here is that: * The return slot is writable. * The return slot will not be read if the function unwinds. Fixes https://github.com/rust-lang/rust/issues/90595.
2024-04-25Rollup merge of #124327 - Kobzol:ci-skip-jobs, r=pietroalbiniMatthias Krüger-98/+31
CI: implement job skipping in Python matrix calculation This removes the `step` YAML anchor and the corresponding bash script. Best reviewed commit-by-commit. r? ```@pietroalbini```
2024-04-25Rollup merge of #124324 - nnethercote:minor-ast-cleanups, r=estebankMatthias Krüger-90/+79
Minor AST cleanups r? ``@estebank``
2024-04-25Rollup merge of #124257 - JoverZhang:rmake-diff, r=jieyouxuMatthias Krüger-5/+146
Rewrite the `no-input-file.stderr` test in Rust and support diff Rewrite the `no-input-file.stderr` test from #121876. Use the `similar` lib to replace the `diff` command.
2024-04-25Fix some typos in commentsTechVest-8/+8
Signed-off-by: TechVest <techdashen@qq.com>
2024-04-25Add needs-unwind to codegen testNikita Popov-0/+1
When compiled with -C panic=abort we'd generate an extra panic_cannot_unwind shim in the variant calling C-unwind.
2024-04-25Fix incorrect CHECK-LABELNikita Popov-1/+1
2024-04-25Set writable and dead_on_unwind attributes for sret argumentsNikita Popov-3/+31
2024-04-25Rewrite `no-input-file.stderr` test in Rust and support diffJover Zhang-5/+146
2024-04-25Auto merge of #124136 - estebank:clone-o-rama-2, r=nnethercotebors-128/+1098
Provide more context and suggestions in borrowck errors involving closures Start pointing to where bindings where declared when they are captured in closures: ``` error[E0597]: `x` does not live long enough --> $DIR/suggest-return-closure.rs:23:9 | LL | let x = String::new(); | - binding `x` declared here ... LL | |c| { | --- value captured here LL | x.push(c); | ^ borrowed value does not live long enough ... LL | } | -- borrow later used here | | | `x` dropped here while still borrowed ``` Suggest cloning in more cases involving closures: ``` error[E0507]: cannot move out of `foo` in pattern guard --> $DIR/issue-27282-move-ref-mut-into-guard.rs:11:19 | LL | if { (|| { let mut bar = foo; bar.take() })(); false } => {}, | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait | | | `foo` is moved here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard help: consider cloning the value if the performance cost is acceptable | LL | if { (|| { let mut bar = foo.clone(); bar.take() })(); false } => {}, | ++++++++ ``` Mention when type parameter could be Clone ``` error[E0382]: use of moved value: `t` --> $DIR/use_of_moved_value_copy_suggestions.rs:7:9 | LL | fn duplicate_t<T>(t: T) -> (T, T) { | - move occurs because `t` has type `T`, which does not implement the `Copy` trait ... LL | (t, t) | - ^ value used here after move | | | value moved here | help: if `T` implemented `Clone`, you could clone the value --> $DIR/use_of_moved_value_copy_suggestions.rs:4:16 | LL | fn duplicate_t<T>(t: T) -> (T, T) { | ^ consider constraining this type parameter with `Clone` ... LL | (t, t) | - you could clone this value help: consider restricting type parameter `T` | LL | fn duplicate_t<T: Copy>(t: T) -> (T, T) { | ++++++ ``` The `help` is new. On ADTs, we also extend the output with span labels: ``` error[E0507]: cannot move out of static item `FOO` --> $DIR/issue-17718-static-move.rs:6:14 | LL | let _a = FOO; | ^^^ move occurs because `FOO` has type `Foo`, which does not implement the `Copy` trait | note: if `Foo` implemented `Clone`, you could clone the value --> $DIR/issue-17718-static-move.rs:1:1 | LL | struct Foo; | ^^^^^^^^^^ consider implementing `Clone` for this type ... LL | let _a = FOO; | --- you could clone this value help: consider borrowing here | LL | let _a = &FOO; | + ``` Suggest cloning captured binding in move closure ``` error[E0507]: cannot move out of `bar`, a captured variable in an `FnMut` closure --> $DIR/borrowck-move-by-capture.rs:9:29 | LL | let bar: Box<_> = Box::new(3); | --- captured outer variable LL | let _g = to_fn_mut(|| { | -- captured by this `FnMut` closure LL | let _h = to_fn_once(move || -> isize { *bar }); | ^^^^^^^^^^^^^^^^ ---- | | | | | variable moved due to use in closure | | move occurs because `bar` has type `Box<isize>`, which does not implement the `Copy` trait | `bar` is moved here | help: clone the value before moving it into the closure 1 | LL ~ let value = bar.clone(); LL ~ let _h = to_fn_once(move || -> isize { value }); | ```
2024-04-25Add comments about attribute tokens.Nicholas Nethercote-0/+2
This clarifies something that has puzzled me for some time.
2024-04-24Auto merge of #124354 - matthiaskrgr:rollup-xsdnixm, r=matthiaskrgrbors-27/+24
Rollup of 5 pull requests Successful merges: - #124322 (chore: fix some typos in comments) - #124333 (Improve diagnostic for unknown `--print` request) - #124334 (Strengthen tracking issue policy with consequences) - #124335 (Stabilize `std::path::absolute`) - #124351 (fix typo in binary_heap docs) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-24Suggest cloning captured binding in `move` closureEsteban Küber-22/+267
``` error[E0507]: cannot move out of `bar`, a captured variable in an `FnMut` closure --> $DIR/borrowck-move-by-capture.rs:9:29 | LL | let bar: Box<_> = Box::new(3); | --- captured outer variable LL | let _g = to_fn_mut(|| { | -- captured by this `FnMut` closure LL | let _h = to_fn_once(move || -> isize { *bar }); | ^^^^^^^^^^^^^^^^ ---- | | | | | variable moved due to use in closure | | move occurs because `bar` has type `Box<isize>`, which does not implement the `Copy` trait | `bar` is moved here | help: clone the value before moving it into the closure | LL ~ let value = bar.clone(); LL ~ let _h = to_fn_once(move || -> isize { value }); | ```
2024-04-24Mention when type parameter could be `Clone`Esteban Küber-86/+640
``` error[E0382]: use of moved value: `t` --> $DIR/use_of_moved_value_copy_suggestions.rs:7:9 | LL | fn duplicate_t<T>(t: T) -> (T, T) { | - move occurs because `t` has type `T`, which does not implement the `Copy` trait ... LL | (t, t) | - ^ value used here after move | | | value moved here | help: if `T` implemented `Clone`, you could clone the value --> $DIR/use_of_moved_value_copy_suggestions.rs:4:16 | LL | fn duplicate_t<T>(t: T) -> (T, T) { | ^ consider constraining this type parameter with `Clone` ... LL | (t, t) | - you could clone this value help: consider restricting type parameter `T` | LL | fn duplicate_t<T: Copy>(t: T) -> (T, T) { | ++++++ ``` The `help` is new. On ADTs, we also extend the output with span labels: ``` error[E0507]: cannot move out of static item `FOO` --> $DIR/issue-17718-static-move.rs:6:14 | LL | let _a = FOO; | ^^^ move occurs because `FOO` has type `Foo`, which does not implement the `Copy` trait | note: if `Foo` implemented `Clone`, you could clone the value --> $DIR/issue-17718-static-move.rs:1:1 | LL | struct Foo; | ^^^^^^^^^^ consider implementing `Clone` for this type ... LL | let _a = FOO; | --- you could clone this value help: consider borrowing here | LL | let _a = &FOO; | + ```
2024-04-24Modify `find_expr` from `Span` to better account for closuresEsteban Küber-31/+202
Start pointing to where bindings were declared when they are captured in closures: ``` error[E0597]: `x` does not live long enough --> $DIR/suggest-return-closure.rs:23:9 | LL | let x = String::new(); | - binding `x` declared here ... LL | |c| { | --- value captured here LL | x.push(c); | ^ borrowed value does not live long enough ... LL | } | -- borrow later used here | | | `x` dropped here while still borrowed ``` Suggest cloning in more cases involving closures: ``` error[E0507]: cannot move out of `foo` in pattern guard --> $DIR/issue-27282-move-ref-mut-into-guard.rs:11:19 | LL | if { (|| { let mut bar = foo; bar.take() })(); false } => {}, | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait | | | `foo` is moved here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard help: consider cloning the value if the performance cost is acceptable | LL | if { (|| { let mut bar = foo.clone(); bar.take() })(); false } => {}, | ++++++++ ```
2024-04-25Rollup merge of #124351 - Treeniks:master, r=workingjubileeMatthias Krüger-1/+1
fix typo in binary_heap docs There was an extra "the" that should not be there.
2024-04-25Rollup merge of #124335 - ChrisDenton:stabilize-absolute, r=dtolnayMatthias Krüger-7/+1
Stabilize `std::path::absolute` FCP complete in https://github.com/rust-lang/rust/issues/92750#issuecomment-2075046985
2024-04-25Rollup merge of #124334 - oli-obk:tracking-issue-policy, r=fmeaseMatthias Krüger-0/+2
Strengthen tracking issue policy with consequences As per the T-compiler MCP: https://github.com/rust-lang/compiler-team/issues/739
2024-04-25Rollup merge of #124333 - Urgau:better-bad-print, r=fmeaseMatthias Krüger-10/+11
Improve diagnostic for unknown `--print` request This PR improves the diagnostic when encountering a unknown `--print` request. It also moves the run-make test to a simple UI test.
2024-04-25Rollup merge of #124322 - whosehang:master, r=NilstriebMatthias Krüger-9/+9
chore: fix some typos in comments
2024-04-24fix typo in binary_heap docsThomas Lindae-1/+1
2024-04-25Suggest ref mut for pattern matching assignmentyukang-41/+164
2024-04-24Auto merge of #124330 - fmease:rollup-a98y7jf, r=fmeasebors-24/+365
Rollup of 6 pull requests Successful merges: - #123316 (Test `#[unix_sigpipe = "inherit"]` with both `SIG_DFL` and `SIG_IGN`) - #123794 (More DefineOpaqueTypes::Yes) - #123881 (Bump Fuchsia versions) - #124281 (fix weak memory bug in TLS on Windows) - #124282 (windows fill_utf16_buf: explain the expected return value) - #124308 (Add diagnostic item for `std::iter::Enumerate`) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-24Auto merge of #104087 - nbdd0121:const, r=scottmcmbors-319/+206
Stabilise inline_const # Stabilisation Report ## Summary This PR will stabilise `inline_const` feature in expression position. `inline_const_pat` is still unstable and will *not* be stabilised. The feature will allow code like this: ```rust foo(const { 1 + 1 }) ``` which is roughly desugared into ```rust struct Foo; impl Foo { const FOO: i32 = 1 + 1; } foo(Foo::FOO) ``` This feature is from https://github.com/rust-lang/rfcs/pull/2920 and is tracked in #76001 (the tracking issue should *not* be closed as it needs to track inline const in pattern position). The initial implementation is done in #77124. ## Difference from RFC There are two major differences (enhancements) as implemented from the RFC. First thing is that the RFC says that the type of an inline const block inferred from the content *within* it, but we currently can infer the type using the information from outside the const block as well. This is a frequently requested feature to the initial implementation (e.g. #89964). The inference is implemented in #89561 and is done by treating inline const similar to a closure and therefore share inference context with its parent body. This allows code like: ```rust let v: Vec<i32> = const { Vec::new() }; ``` Another enhancement that differs from the RFC is that we currently allow inline consts to reference generic parameters. This is implemented in #96557. This allows code like: ```rust fn create_none_array<T, const N: usize>() -> [Option<T>; N] { [const { None::<T> }; N] } ``` This enhancement also makes inline const usable as static asserts: ```rust fn require_zst<T>() { const { assert!(std::mem::size_of::<T>() == 0) } } ``` ## Documentation Reference: rust-lang/reference#1295 ## Unresolved issues We still have a few issues that are not resolved, but I don't think it necessarily has to block stabilisation: * expr fragment specifier issue: #86730 * ~~`const {}` behaves similar to `async {}` but not to `{}` and `unsafe {}` (they are treated as `ExpressionWithoutBlock` rather than `ExpressionWithBlock`): https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/const.20blocks.20differ.20from.20normal.20and.20from.20unsafe.20blocks/near/290229453~~ ## Tests There are a few tests in https://github.com/rust-lang/rust/tree/master/src/test/ui/inline-const
2024-04-24make miri-script a workspace rootRalf Jung-1/+3
2024-04-24Auto merge of #3511 - obi1kenobi:patch-1, r=RalfJungbors-3/+3
Upgrade to `actions/checkout@v4` in `ci.yml`. This is a newer version of the same action. None of the uses here were particularly special (no complex features of v3 were used) so this is a straightforward as-is upgrade.
2024-04-24Upgrade to `actions/checkout@v4` in `ci.yml`.Predrag Gruevski-3/+3
This is a newer version of the same action. None of the uses here were particularly special (no complex features of v3 were used) so this is a straightforward as-is upgrade.
2024-04-24Stabilize `std::path::absolute`Chris Denton-7/+1
2024-04-24Strengthen tracking issue policy with consequencesOli Scherer-0/+2
2024-04-24Improve diagnostic for unknown --print requestUrgau-10/+11
2024-04-24Auto merge of #3510 - RalfJung:sigpipe-default, r=RalfJungbors-3/+2
unix_sigpipe: don't inline DEFAULT, just use it from rustc The default anyway changed since this code was written... it's now 0, not 2.