Commit Graph

253465 Commits

Author SHA1 Message Date
Jakub Beránek
744dc2aa1d
Inline base-ci-job YAML anchor and remove unused anchors 2024-04-25 10:40:09 +02:00
Jakub Beránek
144bdf5bf1
Remove master CI job 2024-04-25 10:40:09 +02:00
bors
865808b33b Auto merge of #124360 - matthiaskrgr:rollup-k6bffhd, r=matthiaskrgr
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-25 06:35:26 +00:00
bors
284f94f9c0 Auto merge of #121298 - nikic:writable, r=cuviper
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-25 04:31:56 +00:00
Matthias Krüger
036bf570ad
Rollup merge of #124327 - Kobzol:ci-skip-jobs, r=pietroalbini
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-25 06:31:04 +02:00
Matthias Krüger
fc6070cd8e
Rollup merge of #124324 - nnethercote:minor-ast-cleanups, r=estebank
Minor AST cleanups

r? ``@estebank``
2024-04-25 06:31:04 +02:00
Matthias Krüger
a2d6b1b2d6
Rollup merge of #124257 - JoverZhang:rmake-diff, r=jieyouxu
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-25 06:31:03 +02:00
Nikita Popov
976267b514 Add needs-unwind to codegen test
When compiled with -C panic=abort we'd generate an extra
panic_cannot_unwind shim in the variant calling C-unwind.
2024-04-25 11:44:32 +09:00
Nikita Popov
137775dd63 Fix incorrect CHECK-LABEL 2024-04-25 11:43:47 +09:00
Nikita Popov
3695af697e Set writable and dead_on_unwind attributes for sret arguments 2024-04-25 11:43:47 +09:00
Jover Zhang
f3530cf003 Rewrite no-input-file.stderr test in Rust and support diff 2024-04-25 09:10:10 +08:00
bors
cb3752d20e Auto merge of #124136 - estebank:clone-o-rama-2, r=nnethercote
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-25 01:00:41 +00:00
Nicholas Nethercote
2ae0765ffb Add comments about attribute tokens.
This clarifies something that has puzzled me for some time.
2024-04-25 10:14:17 +10:00
bors
dfc400e0c0 Auto merge of #124354 - matthiaskrgr:rollup-xsdnixm, r=matthiaskrgr
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-24 22:29:03 +00:00
Esteban Küber
ad9a5a5f9f 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
   |
LL ~         let value = bar.clone();
LL ~         let _h = to_fn_once(move || -> isize { value });
   |
```
2024-04-24 22:21:16 +00:00
Esteban Küber
d68f2a6b71 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;
   |              +
```
2024-04-24 22:21:15 +00:00
Esteban Küber
4aba2c55e6 Modify find_expr from Span to better account for closures
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-24 22:21:13 +00:00
Matthias Krüger
62bc38dd65
Rollup merge of #124351 - Treeniks:master, r=workingjubilee
fix typo in binary_heap docs

There was an extra "the" that should not be there.
2024-04-25 00:19:56 +02:00
Matthias Krüger
ecf794bc69
Rollup merge of #124335 - ChrisDenton:stabilize-absolute, r=dtolnay
Stabilize `std::path::absolute`

FCP complete in https://github.com/rust-lang/rust/issues/92750#issuecomment-2075046985
2024-04-25 00:19:56 +02:00
Matthias Krüger
45beb36ef2
Rollup merge of #124334 - oli-obk:tracking-issue-policy, r=fmease
Strengthen tracking issue policy with consequences

As per the T-compiler MCP: https://github.com/rust-lang/compiler-team/issues/739
2024-04-25 00:19:55 +02:00
Matthias Krüger
f46b828b55
Rollup merge of #124333 - Urgau:better-bad-print, r=fmease
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-25 00:19:55 +02:00
Matthias Krüger
177139032a
Rollup merge of #124322 - whosehang:master, r=Nilstrieb
chore: fix some typos in comments
2024-04-25 00:19:54 +02:00
Thomas Lindae
d3bbdcf26c fix typo in binary_heap docs 2024-04-24 22:59:39 +02:00
bors
ef8b9dcf23 Auto merge of #124330 - fmease:rollup-a98y7jf, r=fmease
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-24 19:26:50 +00:00
bors
7bb4f0889e Auto merge of #104087 - nbdd0121:const, r=scottmcm
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-24 17:23:03 +00:00
Chris Denton
f56afa0477
Stabilize std::path::absolute 2024-04-24 14:35:02 +00:00
Oli Scherer
21906002ed Strengthen tracking issue policy with consequences 2024-04-24 13:55:38 +00:00
Urgau
153b1f0421 Improve diagnostic for unknown --print request 2024-04-24 15:52:01 +02:00
Gary Guo
8169c4c121 Fix miri test 2024-04-24 13:12:33 +01:00
Gary Guo
f8a1cad07c Add cfg_attr(bootstrap) to doc tests 2024-04-24 13:12:33 +01:00
Gary Guo
9d16364198 Fix and bless clippy tests 2024-04-24 13:12:33 +01:00
Gary Guo
cfee72aa24 Fix tests and bless 2024-04-24 13:12:33 +01:00
Gary Guo
94c1920497 Stabilise inline_const 2024-04-24 13:12:25 +01:00
León Orell Valerian Liehr
eaeaeb92a5
Rollup merge of #124308 - CBSpeir:diagnostic-item-enumerate, r=compiler-errors
Add diagnostic item for `std::iter::Enumerate`

This adds a diagnostic item for `std::iter::Enumerate`.  The change will be used by the clippy `unused_enumerate_index` lint to move away from type paths to using diagnostic items.

see: https://github.com/rust-lang/rust-clippy/issues/5393
2024-04-24 14:00:58 +02:00
León Orell Valerian Liehr
388dc0d0b7
Rollup merge of #124282 - RalfJung:fill_utf16_buf, r=ChrisDenton
windows fill_utf16_buf: explain the expected return value

The comment just says "return what the syscall returns", but that doesn't work for all syscalls as the Windows API is not consistent in how buffer size is negotiated. For instance, GetUserProfileDirectoryW works a bit differently, and so home_dir_crt has to translate this to the usual protocol itself. So it's worth describing that protocol.

r? ``@ChrisDenton``
2024-04-24 14:00:57 +02:00
León Orell Valerian Liehr
4eda87603d
Rollup merge of #124281 - RalfJung:win-tls, r=joboet
fix weak memory bug in TLS on Windows

We need to store the `key` *after* we register the dtor.

Now I hope there isn't also some other reason why we have to actually register the dtor last... `@joboet` is there a reason you picked this particular order in https://github.com/rust-lang/rust/pull/102655?

Fixes https://github.com/rust-lang/rust/issues/123583
2024-04-24 14:00:57 +02:00
León Orell Valerian Liehr
bef0f3fb4c
Rollup merge of #123881 - erickt:bump-fuchsia, r=tmandry
Bump Fuchsia versions

This updates the Fuchsia commit used in `auto - x86_64-gnu-integration` CI bot to use the Rust commit 703dc9ce64. This should help improve the coverage of this builder.

It also updates the SDK version to F20.20240412.3.1, and the Fuchsia Clang version to c777c011a709dffd4fa5e79cad7947b7c3405d02.

r? ``@tmandry``
2024-04-24 14:00:56 +02:00
León Orell Valerian Liehr
dc81f6d549
Rollup merge of #123794 - oli-obk:define_opaque_types2, r=lcnr
More DefineOpaqueTypes::Yes

This accepts more code on stable. It is now possible to have match arms return a function item `foo::<ConcreteType>` and a function item `foo::<OpaqueTypeInDefiningScope>` in another, and that will constrain `OpaqueTypeInDefiningScope` to have the hidden type `ConcreteType`. So the following function will now compile, but on master it errors with a type mismatch on the second match arm

```rust
// The function item whose generic params we want to merge.
fn foo<T>(t: T) -> T { t }
// Helper ensuring we can constrain `T` on `F` without explicitly specifying it
fn bind<T, F: FnOnce(T) -> T>(_: T, f: F) -> F { f }

fn k() -> impl Sized {
    let x = match true {
        true => {
            // `f` is `FnDef(foo, [infer_var])`
            let f = foo;
            // Get a value of an opaque type on stable
            let t = k();
            // this returns `FnDef(foo, [k::return])`
            bind(t, f)
        }
        false => foo::<()>,
    };
    todo!()
}
```

r? ``@compiler-errors``

cc https://github.com/rust-lang/rust/issues/116652
2024-04-24 14:00:56 +02:00
León Orell Valerian Liehr
453c23f0f5
Rollup merge of #123316 - Enselic:sigpipe-inherit-variants, r=fmease
Test `#[unix_sigpipe = "inherit"]` with both `SIG_DFL` and `SIG_IGN`

Extend our `#[unix_sigpipe = "inherit"]` test so that it detects if  `SIGPIPE` wrongly ends up being `SIG_DFL` when the parent has `SIG_IGN`. We have no current test for this particular case.

Tracking issue: https://github.com/rust-lang/rust/issues/97889
2024-04-24 14:00:55 +02:00
bors
5557f8c9d0 Auto merge of #122500 - petrochenkov:deleg, r=fmease
delegation: Support renaming, and async, const, extern "ABI" and C-variadic functions

Also allow delegating to functions with opaque types (`impl Trait`).
The delegation item will refer to the original opaque type from the callee, fresh opaque type won't be created, which seems like a reasonable behavior.
(Such delegation items will cause query cycles when used in trait impls, but it can be fixed later.)

Part of https://github.com/rust-lang/rust/issues/118212.
2024-04-24 11:57:35 +00:00
Jakub Beránek
c36d78ed64
Turn CI_ONLY_WHEN_CHANNEL from an environment variable to a job attribute 2024-04-24 12:44:13 +02:00
Jakub Beránek
c59bc9a06a
Fix documentation 2024-04-24 12:15:17 +02:00
Oli Scherer
5c55d6a128 Register hidden types when equating function definitions in coercion 2024-04-24 10:05:33 +00:00
Oli Scherer
ca4a18fafc Add some FnDef LUB coercion tests 2024-04-24 10:05:32 +00:00
Jakub Beránek
4942a35f24
Remove step YAML anchor and env.SKIP_JOB 2024-04-24 11:12:39 +02:00
Jakub Beránek
246ee53637
Remove should-skip-this.sh 2024-04-24 11:12:17 +02:00
Jakub Beránek
e25735908f
Skip jobs based on the active channel in Python 2024-04-24 11:11:16 +02:00
Jakub Beránek
2a7fe14acd
Use a type alias for a CI job 2024-04-24 11:09:42 +02:00
bors
e9362896e0 Auto merge of #123792 - oli-obk:coroutine_closures, r=compiler-errors
Require explicitly marking closures as coroutines

instead of relying on patching up the closure to be a coroutine if it happens to contain a `yield` expression.

I only do this in the 2024 edition, as the `gen` keyword is only available there.
2024-04-24 08:43:30 +00:00
Oli Scherer
aef0f4024a Error on using yield without also using #[coroutine] on the closure
And suggest adding the `#[coroutine]` to the closure
2024-04-24 08:05:29 +00:00