Commit Graph

244707 Commits

Author SHA1 Message Date
Amanieu d'Antras
ab8b661667 Disable conversions between portable_simd and stdarch on big-endian ARM
stdarch no longer provide SIMD on big-endian ARM due to
https://github.com/rust-lang/stdarch/issues/1484
2024-01-30 04:47:01 +00:00
Amanieu d'Antras
31007f51ed Add stdarch_wasm_atomic_wait feature in std 2024-01-30 03:34:30 +00:00
Amanieu d'Antras
bfe6421d0b Update allowed depdendencies for cranelift 2024-01-30 03:34:30 +00:00
Amanieu d'Antras
a00ec2d93b Update ahash dependency to 0.8.7 2024-01-30 03:34:28 +00:00
Amanieu d'Antras
9a39e41637 Update feature names for new stdarch 2024-01-30 03:33:12 +00:00
Amanieu d'Antras
f8d4b2a150 Update stdarch submodule 2024-01-30 03:33:12 +00:00
bors
5518eaa946 Auto merge of #120466 - Dylan-DPC:rollup-v0or19a, r=Dylan-DPC
Rollup of 9 pull requests

Successful merges:

 - #116677 (References refer to allocated objects)
 - #118625 (Improve handling of expressions in patterns)
 - #120266 (Improve documentation for [A]Rc::into_inner)
 - #120373 (Adjust Behaviour of `read_dir` and `ReadDir` in Windows Implementation: Check Whether Path to Search In Exists)
 - #120390 (Borrow check inline const patterns)
 - #120420 (Stop using derivative in rustc_pattern_analysis)
 - #120428 (hir: Two preparatory changes for #120206)
 - #120453 (Fix incorrect comment in normalize_newlines)
 - #120462 (Clean dead code)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-29 21:53:39 +00:00
bors
af08c64e38 Auto merge of #120275 - estebank:issue-120241, r=fmease
Avoid ICE in trait without `dyn` lint

Do not attempt to provide an accurate suggestion for `impl Trait` in bare trait types when linting. Instead, only do the object safety check when an E0782 is already going to be emitted in the 2021 edition.

Fix #120241.
2024-01-29 19:43:09 +00:00
Esteban Küber
09f16b596d Avoid ICE in trait without dyn lint
Do not attempt to provide an accurate suggestion for `impl Trait`
in bare trait types when linting. Instead, only do the object
safety check when an E0782 is already going to be emitted in the
2021 edition.

Fix #120241.
2024-01-29 18:33:52 +00:00
Dylan DPC
c70c4cc708
Rollup merge of #120462 - mu001999:clean, r=Nilstrieb
Clean dead code

Detected by #118257
2024-01-29 12:56:55 +00:00
Dylan DPC
15e8b903b2
Rollup merge of #120453 - mattheww:2024-01_normalize_newlines, r=oli-obk
Fix incorrect comment in normalize_newlines

The incorrect comment seems to be left over from sometime before this function was first merged.
2024-01-29 12:56:54 +00:00
Dylan DPC
eaa100204e
Rollup merge of #120428 - petrochenkov:somehir2, r=compiler-errors
hir: Two preparatory changes for #120206

cc https://github.com/rust-lang/rust/pull/120206
r? ```@compiler-errors```
2024-01-29 12:56:54 +00:00
Dylan DPC
5de94a3c80
Rollup merge of #120420 - lnicola:rm-pattern-analysis-derivative, r=Nilstrieb
Stop using derivative in rustc_pattern_analysis

CC #109302, https://github.com/rust-lang/rust-analyzer/pull/16420#discussion_r1464357157

r? ````@Nadrieril````
2024-01-29 12:56:53 +00:00
Dylan DPC
549eeb077d
Rollup merge of #120390 - matthewjasper:inline-constant-pat-mir, r=davidtwco
Borrow check inline const patterns

Add type annotations to MIR so that borrowck can pass constraints from inline constants in patterns to the containing function.
Also enables some inline constant pattern tests that were fixed by the THIR unsafeck stabilization.

cc #76001
2024-01-29 12:56:53 +00:00
Dylan DPC
d04bede047
Rollup merge of #120373 - HTGAzureX1212:HTGAzureX1212/issue-120040, r=ChrisDenton
Adjust Behaviour of `read_dir` and `ReadDir` in Windows Implementation: Check Whether Path to Search In Exists

This pull request changes the `read_dir` function's and the `ReadDir` structure's internal implementations for the Windows operating system to make its behaviour more accurate.

It should be noted that `ERROR_FILE_NOT_FOUND` is returned by the `FindFirstFileW` function when *no matching files can be found*, not necessarily that the path to search in does not exist in the first place. Therefore, directly returning the "The system cannot find the file specified." may not be accurate.

An extra check for whether the path to search in exists is added, returning a constructed `ReadDir` iterator with its handle being an `INVALID_HANDLE_VALUE` returned by the `FindFirstFileW` function if `ERROR_FILE_NOT_FOUND` is indeed the last OS error. The `ReadDir` implementation for the Windows operating system is correspondingly updated to always return `None` if the handle it has is an `INVALID_HANDLE_VALUE` which can only be the case if and only if specifically constructed by the `read_dir` function in the aforementioned conditions.

It should also be noted that `FindFirstFileW` would have returned `ERROR_PATH_NOT_FOUND` if the path to search in does not exist in the first place.

Presumably fixes #120040.
2024-01-29 12:56:52 +00:00
Dylan DPC
4528b37196
Rollup merge of #120266 - steffahn:a_rc_into_inner_docs, r=Mark-Simulacrum
Improve documentation for [A]Rc::into_inner

General improvements, and also aims to better encourage the reader to actually check out Arc::try_unwrap.

This addresses concerns from https://github.com/rust-lang/rust/issues/106894#issuecomment-1905627234.

Rendered:

![Screenshot_20240123_114436](https://github.com/rust-lang/rust/assets/3986214/68896d62-13e0-4f3a-8073-91d8e77c5554)
![Screenshot_20240123_114455](https://github.com/rust-lang/rust/assets/3986214/dc58e4bd-dd7f-40b1-bc50-fd6200dde593)
2024-01-29 12:56:52 +00:00
Dylan DPC
0138151c21
Rollup merge of #118625 - ShE3py:expr-in-pats, r=WaffleLapkin
Improve handling of expressions in patterns

Closes #112593.

Methodcalls' dots in patterns are silently recovered as commas (e.g. `Foo("".len())` -> `Foo("", len())`) so extra diagnostics are emitted:
```rs
struct Foo(u8, String, u8);

fn bar(foo: Foo) -> bool {
    match foo {
        Foo(4, "yippee".yeet(), 7) => true,
        _ => false
    }
}
```
```
error: expected one of `)`, `,`, `...`, `..=`, `..`, or `|`, found `.`
 --> main.rs:5:24
  |
5 |         Foo(4, "yippee".yeet(), 7) => true,
  |                        ^
  |                        |
  |                        expected one of `)`, `,`, `...`, `..=`, `..`, or `|`
  |                        help: missing `,`

error[E0531]: cannot find tuple struct or tuple variant `yeet` in this scope
 --> main.rs:5:25
  |
5 |         Foo(4, "yippee".yeet(), 7) => true,
  |                         ^^^^ not found in this scope

error[E0023]: this pattern has 4 fields, but the corresponding tuple struct has 3 fields
 --> main.rs:5:13
  |
1 | struct Foo(u8, String, u8);
  |            --  ------  -- tuple struct has 3 fields
...
5 |         Foo(4, "yippee".yeet(), 7) => true,
  |             ^  ^^^^^^^^ ^^^^^^  ^ expected 3 fields, found 4

error: aborting due to 3 previous errors
```

This PR checks for patterns that ends with a dot and a lowercase ident (as structs/variants should be uppercase):
```
error: expected a pattern, found a method call
 --> main.rs:5:16
  |
5 |         Foo(4, "yippee".yeet(), 7) => true,
  |                ^^^^^^^^^^^^^^^ method calls are not allowed in patterns

error: aborting due to 1 previous error
```

Also check for expressions:
```rs
fn is_idempotent(x: f32) -> bool {
    match x {
        x * x => true,
        _ => false,
    }
}

fn main() {
    let mut t: [i32; 5];
    let t[0] = 1;
}
```
```
error: expected a pattern, found an expression
 --> main.rs:3:9
  |
3 |         x * x => true,
  |         ^^^^^ arbitrary expressions are not allowed in patterns

error: expected a pattern, found an expression
  --> main.rs:10:9
   |
10 |     let t[0] = 1;
   |         ^^^^ arbitrary expressions are not allowed in patterns
```

Would be cool if the compiler could suggest adding a guard for `match`es, but I've no idea how to do it.

---
`@rustbot` label +A-diagnostics +A-parser +A-patterns +C-enhancement
2024-01-29 12:56:51 +00:00
Dylan DPC
8017ea4016
Rollup merge of #116677 - joshlf:patch-11, r=RalfJung
References refer to allocated objects

Partially addresses https://github.com/rust-lang/unsafe-code-guidelines/issues/465
2024-01-29 12:56:51 +00:00
Matthew Jasper
44824e0bce Enable tests for unsafe blocks in inline const patterns 2024-01-29 09:17:00 +00:00
Matthew Jasper
83fa46fe5b Borrow check inline const patterns
Add type annotations to MIR so that borrowck can pass constraints from
inline constants in patterns to the containing function.
2024-01-29 09:17:00 +00:00
bors
fb4bca04fa Auto merge of #120165 - reitermarkus:nonzero-switch-alias-direction, r=dtolnay
Switch `NonZero` alias direction.

Step 4 mentioned in https://github.com/rust-lang/rust/pull/100428#pullrequestreview-1767139731.

Depends on https://github.com/rust-lang/rust/pull/120160.

r? `@dtolnay`
2024-01-29 08:52:13 +00:00
bors
0ea334ab73 Auto merge of #120451 - RalfJung:miri, r=RalfJung
Miri subtree update

r? `@ghost`
2024-01-29 06:50:18 +00:00
r0cky
d3bf8b717b Clean dead code 2024-01-29 14:04:42 +08:00
bors
7e43442eb6 Auto merge of #119290 - Kobzol:ci-docker-registry-cache, r=Mark-simulacrum
Cache CI Docker images in ghcr registry

This PR changes the way `rust-lang` caches Docker images used in CI workflows. Before, the intermediate Docker layers were manually exported from `docker history` and backed up in S3. However, this approach doesn't work any more with the Docker version used by GitHub Actions since August 2023. We had to revert to disabling Docker BuildKit to make the old caching work, but this workaround will stop working eventually, after GitHub updates Docker again and the old build backend will be removed.

This PR changes the caching to use [Docker caching](https://docs.docker.com/build/cache/) instead. There are several backends for the cache, for our use-case S3 and Docker registry makes sense. This PR uses the Docker registry backend and uses the ghcr.io registry.

The caching creates a Docker image labeled `rust-ci`, which is currently stored to the `ghcr.io/rust-lang-ci` package registry. This image appears [here](https://ghcr.io/rust-lang-ci/rust-ci). The image is stored in `rust-lang-ci` and not `rust-lang`, because `try` and `auto` builds run in the context of that repository, so the used `GITHUB_TOKEN` has permissions for it (unlike for `rust-lang`).

For pull request CI runs, the provided `GITHUB_TOKEN` reduces its permissions automatically to `packages: read`, which means that we won't be able to write the Docker image. If we're not able to write, we won't have anything to read. So I disabled the caching entirely for PR runs (it makes it slightly faster to build the Docker image if we don't have to deal with exporting and using a separate build driver). Note that before this PR, we also weren't able to read or write the cache on PR runs.

Rustup part of this change is [here](https://github.com/rust-lang/rustup/pull/3648).

Related issue: https://github.com/rust-lang/infra-team/issues/81

r? `@Mark-Simulacrum`
2024-01-29 02:50:57 +00:00
bors
8a0b5ae199 Auto merge of #119972 - nnethercote:add-ErrCode, r=oli-obk
Add `ErrCode`

Error codes are integers, but `String` is used everywhere to represent them. Gross!

This commit introduces `ErrCode`, an integral newtype for error codes, replacing `String`. The commit also introduces constants like `E0123` for all the used error codes.

r? `@estebank`
2024-01-29 00:03:53 +00:00
Nicholas Nethercote
5d9dfbd08f Stop using String for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!

This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.

With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123)  // macro call

struct_span_code_err!(dcx, span, E0123, "msg");  // bare ident arg to macro call

\#[diag(name, code = "E0123")]  // string
struct Diag;
```

With the new code, they all use the `E0123` constant.
```
E0123  // constant

struct_span_code_err!(dcx, span, E0123, "msg");  // constant

\#[diag(name, code = E0123)]  // constant
struct Diag;
```

The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
  used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
  moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
  code constants and the `DIAGNOSTIC_TABLES`. This is in its new
  `codes.rs` file.
2024-01-29 07:41:41 +11:00
Nicholas Nethercote
0321de2778 Remove bogus {code} attributes on TraitImplMismatch.
This makes no sense, and has no effect. I suspect it's been confused
with a `code = "{code}"` attribute on a subdiagnostic suggestion, where
it is valid (but the "code" there is suggested source code, rather than
an error code.)
2024-01-29 07:40:10 +11:00
Nicholas Nethercote
d91d164b00 Sort attributes in compiler/rustc_errors/src/lib.rs.
As is already done in `rustc_span` and `rustc_data_structures`.
2024-01-29 07:40:08 +11:00
Matthew Woodcraft
67558055e3 normalize_newlines(): fix incorrect comment 2024-01-28 19:30:41 +00:00
Jakub Beránek
09e0d4f89a
Print image input file and Docker version 2024-01-28 17:01:47 +01:00
bors
71f8f4949e Auto merge of #3181 - devnexen:stat_calls_fbsd, r=RalfJung
freebsd add *stat calls interception support
2024-01-28 15:47:14 +00:00
Ralf Jung
8302e25529
tweak comments 2024-01-28 16:45:52 +01:00
Lieselotte
6f014a81b2
Handle methodcalls & operators in patterns 2024-01-28 16:12:21 +01:00
Vadim Petrochenkov
b2b5b91bfb hir: Use InferArg in ArrayLen::Infer 2024-01-28 02:04:39 +03:00
Vadim Petrochenkov
5f8030dcc9 hir: Remove unnecessary HirId from hir::Let
It has 1-to-1 correspondence to its expression id.

Also remove mostly useless `visit_let_expr`.
2024-01-28 02:04:39 +03:00
bors
6351247048 Auto merge of #120024 - Mark-Simulacrum:fast-union-merge, r=cjgillot
Merge into larger interval set

This reduces the work done while merging rows. In at least one case (#50450), we have thousands of union([range], [20,000 ranges]), which previously inserted each of the 20,000 ranges one by one. Now we only insert one range into the right hand set after copying the set over.

This cuts the runtime of the test case in #50450 from ~26 seconds to ~6 seconds locally, though it doesn't change the memory usage peak (~9.5GB).
2024-01-27 22:26:37 +00:00
Joshua Liebow-Feeser
b867c7c707
Update primitive_docs.rs 2024-01-27 08:47:14 -08:00
Markus Reiter
021739c840
Update tests. 2024-01-27 16:38:57 +01:00
Markus Reiter
117eb9f376
Fix NonZero suggestions. 2024-01-27 16:38:57 +01:00
Markus Reiter
ca2ec7af35
Fix NonZero clippy lints. 2024-01-27 16:38:57 +01:00
Markus Reiter
554b0f70c3
Add NonZero symbol. 2024-01-27 16:38:57 +01:00
Markus Reiter
4f0ce6fca2
Switch NonZero alias direction. 2024-01-27 16:38:57 +01:00
bors
6b4f1c5e78 Auto merge of #120201 - clubby789:dep-update, r=dtolnay
Bump some deps with syn 1.0 dependencies

cc #109302

`cargo update`ing `unic-langid` and `object` removes two dependencies on Syn 1.0.
2024-01-27 14:19:12 +00:00
bors
0186c24d9e Auto merge of #3281 - RalfJung:typo, r=RalfJung
fix typo in operator.rs
2024-01-27 12:52:34 +00:00
Laurențiu Nicola
f5c78955c8 Stop using derivative in rustc_pattern_analysis 2024-01-27 14:21:01 +02:00
bors
8af70c7a18 Auto merge of #120062 - davidtwco:llvm-data-layout-check, r=wesleywiser
llvm: change data layout bug to an error and make it trigger more

Fixes #33446.

Don't skip the inconsistent data layout check for custom LLVMs or non-built-in targets.

With #118708, all targets will have a simple test that would trigger this error if LLVM's data layouts do change - so data layouts would be corrected during the LLVM upgrade. Therefore, with builtin targets, this error won't happen with our LLVM because each target will have been confirmed to work. With non-builtin targets, this error is probably useful to have because you can change the data layout in your target and if it is wrong then that could lead to bugs.

When using a custom LLVM, the same justification makes sense for non-builtin targets as with our LLVM, the user can update their target to match their LLVM and that's probably a good thing to do. However, with a custom LLVM, the user cannot change the builtin target data layouts if they don't match - though given that the compiler's data layout is used for layout computation and a bunch of other things - you could get some bugs because of the mismatch and probably want to know about that. I'm not sure if this is something that people do and is okay, but I doubt it?

`CFG_LLVM_ROOT` was also always set during local development with `download-ci-llvm` so this bug would never trigger locally.

In #33446, two points are raised:

- In the issue itself, changing this from a `bug!` to a proper error is what is suggested, by using `isCompatibleDataLayout` from LLVM, but that function still just does the same thing that we do and check for equality, so I've avoided the additional code necessary to do that FFI call.
- `@Mark-Simulacrum` suggests a different check is necessary to maintain backwards compatibility with old LLVM versions. I don't know how often this comes up, but we can do that with some simple string manipulation + LLVM version checks as happens already for LLVM 17 just above this diff.
2024-01-27 12:19:41 +00:00
Ralf Jung
3cc0f02dac fix typo in operator.rs 2024-01-27 12:48:52 +01:00
bors
7df6f4a15e Auto merge of #120417 - matthiaskrgr:rollup-5rszkmd, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #118182 (Properly recover from trailing attr in body)
 - #119641 (Remove feature not required by `Ipv6Addr::to_cononical` doctest)
 - #119957 (fix: correct suggestion arg for impl trait)
 - #120386 (ScopeTree: remove destruction_scopes as unused)
 - #120398 (Improve handling of numbers in `IntoDiagnosticArg`)
 - #120399 (Remove myself from review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-27 10:14:36 +00:00
Matthias Krüger
574d35fbeb
Rollup merge of #120399 - thomcc:thomcc-no-rotation, r=Nilstrieb
Remove myself from review rotation

Still willing to do reviews (and make it through my backlog), but I don't have the bandwidth to be on the rotation right now.
2024-01-27 10:48:49 +01:00
Matthias Krüger
0972d4441e
Rollup merge of #120398 - Urgau:into_diag_arg-numbers, r=compiler-errors
Improve handling of numbers in `IntoDiagnosticArg`

While working on https://github.com/rust-lang/rust/pull/120393, I realize that my fluent selectors were not working. So here is an improvement (not a fix unfortunately).
2024-01-27 10:48:48 +01:00