Commit Graph

35888 Commits

Author SHA1 Message Date
Jules Bertholet
9d92a7f355
Match ergonomics 2024: migration lint
Unfortunately, we can't always offer a machine-applicable suggestion when there are subpatterns from macro expansion.

Co-Authored-By: Guillaume Boisseau <Nadrieril@users.noreply.github.com>
2024-05-12 11:13:33 -04:00
bors
686bfc4c42 Auto merge of #125010 - matthiaskrgr:rollup-270pck3, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #124928 (Stabilize `byte_slice_trim_ascii` for `&[u8]`/`&str`)
 - #124954 (Document proper usage of `fmt::Error` and `fmt()`'s `Result`.)
 - #124969 (check if `x test tests` missing any test directory)
 - #124978 (Handle Deref expressions in invalid_reference_casting)
 - #125005 (Miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-11 12:46:54 +00:00
Matthias Krüger
8eac6d2333
Rollup merge of #124978 - saethlin:ref-casting_derefs, r=Urgau,Nilstrieb
Handle Deref expressions in invalid_reference_casting

Similar to https://github.com/rust-lang/rust/pull/124908

See https://github.com/rust-lang/rust/issues/124951 for context; this PR fixes the last of the known false postiive cases with this lint that we encounter in Crater.
2024-05-11 13:16:41 +02:00
bors
35c5e67c69 Auto merge of #124567 - Jules-Bertholet:and-eats-andmut, r=Nadrieril
Match ergonomics 2024: let `&` patterns eat `&mut`

r? `@Nadrieril`

cc https://github.com/rust-lang/rust/issues/123076

`@rustbot` label A-edition-2024 A-patterns
2024-05-11 10:39:11 +00:00
bors
2259028a70 Auto merge of #124762 - madsmtm:refactor-apple-target-abi, r=lcnr,BlackHoleFox
Refactor Apple `target_abi`

This was bundled together with `Arch`, which complicated a few code paths and meant we had to do more string matching than necessary.

CC `@BlackHoleFox` as you've worked on the Apple target spec before

Related: Is there a reason why `Target`/`TargetOptions` use `StaticCow` for so many things, instead of an enum with defined values (and perhaps a catch-all case for custom target json files)? Tagging `@Nilstrieb,` as you might know?
2024-05-11 08:32:35 +00:00
Matthias Krüger
3c40e383df
Rollup merge of #124818 - compiler-errors:ena, r=Mark-Simulacrum
Update ena to 0.14.3

Includes https://github.com/rust-lang/ena/pull/53, which removes a trivial `Self: Sized` bound that prevents `ena` from building on the new solver.
2024-05-11 08:00:15 +02:00
bors
f9a3fd9661 Auto merge of #124993 - jieyouxu:rollup-u02aso7, r=jieyouxu
Rollup of 5 pull requests

Successful merges:

 - #124233 (Add `-lmingwex` second time in `mingw_libs`)
 - #124318 (ignore generics args in attribute paths)
 - #124899 (bootstrap: add comments for the automatic dry run)
 - #124904 (reachable computation: extend explanation of what this does, and why)
 - #124930 (Make sure we consume a generic arg when checking mistyped turbofish)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-11 00:31:30 +00:00
许杰友 Jieyou Xu (Joe)
e7bb090d0a
Rollup merge of #124930 - compiler-errors:consume-arg, r=petrochenkov
Make sure we consume a generic arg when checking mistyped turbofish

When recovering un-turbofish-ed args in expr position (e.g. `let x = a<T, U>();` in `check_mistyped_turbofish_with_multiple_type_params`, we used `parse_seq_to_before_end` to parse the fake generic args; however, it used `parse_generic_arg` which *optionally* parses a generic arg. If it doesn't end up parsing an arg, it returns `Ok(None)` and consumes no tokens. If we don't find a delimiter after this (`,`), we try parsing *another* element. In this case, we just infinitely loop looking for a subsequent element.

We can fix this by making sure that we either parse a generic arg or error in `parse_seq_to_before_end`'s callback.

Fixes #124897
2024-05-11 01:15:10 +01:00
许杰友 Jieyou Xu (Joe)
d8bf3fd584
Rollup merge of #124904 - RalfJung:reachable, r=tmiasko
reachable computation: extend explanation of what this does, and why

Follow-up to https://github.com/rust-lang/rust/pull/122769. I had the time to think about this some more, in particular in the context of https://github.com/rust-lang/rust/issues/119214, so I felt it was worth extending these comments some more.

I also gave up on the context of "externally reachable" as it is not called that way anywhere else in the compiler.

Cc `@tmiasko` `@saethlin`
2024-05-11 01:15:10 +01:00
许杰友 Jieyou Xu (Joe)
69122f1da4
Rollup merge of #124318 - bvanjoi:fix-123911, r=petrochenkov
ignore generics args in attribute paths

Fixes #97006
Fixes #123911
Fixes #123912

This patch ensures that we no longer have to handle invalid generic arguments in attribute paths.

r? `@petrochenkov`
2024-05-11 01:15:08 +01:00
许杰友 Jieyou Xu (Joe)
150633eea2
Rollup merge of #124233 - mati865:fix-support-for-upcoming-mingw-w64, r=petrochenkov
Add `-lmingwex` second time in `mingw_libs`

Upcoming mingw-w64 releases will contain small math functions refactor which moved implementation around. As a result functions like `lgamma`
now depend on libraries in this order:
`libmingwex.a` -> `libmsvcrt.a` -> `libmingwex.a`.

Fixes #124221
2024-05-11 01:15:08 +01:00
bors
19dacee0d8 Auto merge of #124982 - compiler-errors:uplift-trait-ref, r=lcnr
Uplift `TraitRef` into `rustc_type_ir`

Emotional rollercoaster

r? lcnr
2024-05-10 22:24:53 +00:00
bors
6e1d94708a Auto merge of #123886 - scottmcm:more-rvalue-operands, r=matthewjasper
Avoid `alloca`s in codegen for simple `mir::Aggregate` statements

The core idea here is to remove the abstraction penalty of simple newtypes in codegen.

Even something simple like constructing a
```rust
#[repr(transparent)] struct Foo(u32);
```
forces an `alloca` to be generated in nightly right now.

Certainly LLVM can optimize that away, but it would be nice if it didn't have to.

Quick example:
```rust
#[repr(transparent)]
pub struct Transparent32(u32);

#[no_mangle]
pub fn make_transparent(x: u32) -> Transparent32 {
    let a = Transparent32(x);
    a
}
```
on nightly we produce <https://rust.godbolt.org/z/zcvoM79ae>
```llvm
define noundef i32 `@make_transparent(i32` noundef %x) unnamed_addr #0 {
  %a = alloca i32, align 4
  store i32 %x, ptr %a, align 4
  %0 = load i32, ptr %a, align 4, !noundef !3
  ret i32 %0
}
```
but after this PR we produce
```llvm
define noundef i32 `@make_transparent(i32` noundef %x) unnamed_addr #0 {
start:
  ret i32 %x
}
```
(even before the optimizer runs).
2024-05-10 20:17:22 +00:00
Michael Goulet
b55d8a3b49 Apply nits, make some bounds into supertraits on inherent traits 2024-05-10 15:44:03 -04:00
Michael Goulet
f368527802 Also debug 2024-05-10 15:44:03 -04:00
Michael Goulet
1e5ec0a12c Lift TraitRef into rustc_type_ir 2024-05-10 15:44:03 -04:00
Michael Goulet
5e606c0bde Lift Lift 2024-05-10 15:44:03 -04:00
bors
2cce088584 Auto merge of #124952 - compiler-errors:no-error, r=lcnr
Rename some `FulfillmentErrorCode`/`ObligationCauseCode` variants to be less redundant

1. Rename some `FulfillmentErrorCode` variants.
2. Always use `ObligationCauseCode::` to prefix a code, rather than using a glob import and naming them through `traits::`.
3. Rename some `ObligationCauseCode` variants -- I wasn't particularly thorough with thinking of a new names for these, so could workshop them if necessary.
4. Misc stuff from renaming.

r? lcnr
2024-05-10 18:11:02 +00:00
Jules Bertholet
6d5c6f541f
Add comment on cap_to_weakly_not
Co-authored-by: Guillaume Boisseau <Nadrieril@users.noreply.github.com>
2024-05-10 13:53:48 -04:00
Jules Bertholet
7951311c1b
Move all ref pat logic into check_pat_ref 2024-05-10 13:50:19 -04:00
Jules Bertholet
bff287b4a5
Remove redundant comment 2024-05-10 13:47:39 -04:00
Jules Bertholet
d8a798b5e9
No more Option<Option<>> 2024-05-10 13:47:38 -04:00
Jules Bertholet
0f03c2be58
Rename explicit_ba 2024-05-10 13:47:38 -04:00
Jules Bertholet
f57b970de8
Comments and fixes 2024-05-10 13:47:37 -04:00
Jules Bertholet
91bbbaa0f7
Fix spans when macros are involved 2024-05-10 13:47:36 -04:00
Jules Bertholet
ed96c655c6
Various fixes:
- Only show error when move-check would not be triggered
- Add structured suggestion
2024-05-10 13:47:36 -04:00
Jules Bertholet
4f76f1069a
Match ergonomics 2024: let & patterns eat &mut 2024-05-10 13:47:34 -04:00
Ben Kimock
2bb25d3f4a Handle Deref expressions in invalid_reference_casting 2024-05-10 12:33:07 -04:00
bohan
f70f900036 ignore generics args in attribute paths 2024-05-11 00:13:27 +08:00
bors
6a19a87097 Auto merge of #124972 - matthiaskrgr:rollup-3fablim, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #124615 (coverage: Further simplify extraction of mapping info from MIR)
 - #124778 (Fix parse error message for meta items)
 - #124797 (Refactor float `Primitive`s to a separate `Float` type)
 - #124888 (Migrate `run-make/rustdoc-output-path` to rmake)
 - #124957 (Make `Ty::builtin_deref` just return a `Ty`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-10 16:04:26 +00:00
Michael Goulet
6f77bfe8b6 Name tweaks 2024-05-10 10:42:57 -04:00
Michael Goulet
9108294a6c More rename fallout 2024-05-10 10:42:57 -04:00
Michael Goulet
534e267d48 Rename some ObligationCauseCode variants 2024-05-10 10:42:57 -04:00
Michael Goulet
4bde8a8f4b Remove glob imports for ObligationCauseCode 2024-05-10 10:42:56 -04:00
Michael Goulet
04c049498d rename some variants in FulfillmentErrorCode 2024-05-10 10:42:14 -04:00
Matthias Krüger
9a9ec90567
Rollup merge of #124957 - compiler-errors:builtin-deref, r=michaelwoerister
Make `Ty::builtin_deref` just return a `Ty`

Nowhere in the compiler are we using the mutability part of the `TyAndMut` that we used to return.
2024-05-10 16:10:47 +02:00
Matthias Krüger
1ae0d90b72
Rollup merge of #124797 - beetrees:primitive-float, r=davidtwco
Refactor float `Primitive`s to a separate `Float` type

Now there are 4 of them, it makes sense to refactor `F16`, `F32`, `F64` and `F128` out of `Primitive` and into a separate `Float` type (like integers already are). This allows patterns like `F16 | F32 | F64 | F128` to be simplified into `Float(_)`, and is consistent with `ty::FloatTy`.

As a side effect, this PR also makes the `Ty::primitive_size` method work with `f16` and `f128`.

Tracking issue: #116909

`@rustbot` label +F-f16_and_f128
2024-05-10 16:10:46 +02:00
Matthias Krüger
f605174ea7
Rollup merge of #124778 - fmease:fix-diag-msg-parse-meta-item, r=nnethercote
Fix parse error message for meta items

Addresses https://github.com/rust-lang/rust/issues/122796#issuecomment-2010803906, cc [``@]Thomasdezeeuw.``

For attrs inside of a macro like `#[doc(alias = $ident)]` or `#[cfg(feature = $ident)]` where `$ident` is a macro metavariable of fragment kind `ident`, we used to say the following when expanded (with `$ident` ⟼ `ident`):

```
error: expected unsuffixed literal or identifier, found `ident`
  --> weird.rs:6:19
   |
6  |      #[cfg(feature = $ident)]
   |                      ^^^^^^
...
11 | m!(id);
   | ------ in this macro invocation
   |
   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
```

This was incorrect and caused confusion, justifiably so (see #122796).

In this position, we only accept/expect *unsuffixed literals* which consist of numeric & string literals as well as the boolean literals / the keywords / the reserved identifiers `false` & `true` **but not** arbitrary identifiers.

Furthermore, we used to suggest garbage when encountering unexpected non-identifier tokens:

```
error: expected unsuffixed literal, found `-`
  --> weird.rs:16:17
   |
16 | #[cfg(feature = -1)]
   |                 ^
   |
help: surround the identifier with quotation marks to parse it as a string
   |
16 | #[cfg(feature =" "-1)]
   |                + +
```

Now we no longer do.
2024-05-10 16:10:45 +02:00
Matthias Krüger
c768a0e99f
Rollup merge of #124615 - Zalathar:extracted-mappings, r=davidtwco
coverage: Further simplify extraction of mapping info from MIR

This is another round of rearrangement and simplification that builds on top of the changes made to mapping-extraction by #124603.

The overall theme is to take the computation of `bcb_has_mappings` and `test_vector_bitmap_bytes` out of the main body of `generate_coverage_spans`, which then lets us perform a few other small changes that had previously been held up by the need to work around those computations.
2024-05-10 16:10:45 +02:00
bors
66f877007d Auto merge of #124932 - RalfJung:temporal, r=compiler-errors
codegen: memmove/memset cannot be non-temporal

non-temporal memset is not a thing.
And for memmove, since the LLVM backend doesn't support this, surely we don't need it in the GCC backend.
2024-05-10 13:55:59 +00:00
León Orell Valerian Liehr
0ad3c5da72
Fix parse error message for meta items 2024-05-10 09:16:27 +02:00
bors
f7b1501ce7 Auto merge of #124961 - matthiaskrgr:rollup-1jj65p6, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #124551 (Add benchmarks for `impl Debug for str`)
 - #124915 (`rustc_target` cleanups)
 - #124918 (Eliminate some `FIXME(lcnr)` comments)
 - #124927 (opt-dist: use xz2 instead of xz crate)
 - #124936 (analyse visitor: build proof tree in probe)
 - #124943 (always use `GenericArgsRef`)
 - #124955 (Use fewer origins when creating type variables.)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-10 06:50:46 +00:00
Matthias Krüger
0ee258009c
Rollup merge of #124955 - nnethercote:next_ty_var, r=lcnr
Use fewer origins when creating type variables.

To reduce lots of repetitive boilerplate code. Details in the individual commit messages.

r? ``@lcnr``
2024-05-10 07:30:22 +02:00
Matthias Krüger
30bd6cb726
Rollup merge of #124943 - lcnr:generic-args-ref, r=compiler-errors
always use `GenericArgsRef`

r? ```@compiler-errors```
2024-05-10 07:30:21 +02:00
Matthias Krüger
43ddd1d963
Rollup merge of #124936 - lcnr:cool-beans, r=compiler-errors
analyse visitor: build proof tree in probe

see inline comments

fixes #124791
fixes #124702

r? ```@compiler-errors```
2024-05-10 07:30:21 +02:00
Matthias Krüger
7e4f6082ce
Rollup merge of #124918 - nnethercote:FIXME-lcnr, r=lcnr
Eliminate some `FIXME(lcnr)` comments

In some cases this involved changing code. In some cases the comment was able to removed or replaced.

r? ``@lcnr``
2024-05-10 07:30:20 +02:00
Matthias Krüger
0b4715e7f8
Rollup merge of #124915 - nnethercote:rustc_target-cleanups, r=bjorn3
`rustc_target` cleanups

Minor improvement I found while looking at this code.

r? ```@lqd```
2024-05-10 07:30:19 +02:00
bors
98dabb622a Auto merge of #124953 - compiler-errors:own-params, r=lcnr
Rename `Generics::params` to `Generics::own_params`

I hope this makes it slightly more obvious that `generics.own_params` is insufficient when considering nested items. I didn't actually audit any of the usages, for the record.

r? lcnr
2024-05-10 04:43:57 +00:00
Michael Goulet
d50c2b0a52 Make builtin_deref just return a Ty 2024-05-09 22:55:00 -04:00
Michael Goulet
1c19b6ad60 Rename Generics::params to Generics::own_params 2024-05-09 20:58:46 -04:00