Commit graph

258909 commits

Author SHA1 Message Date
Zalathar 8016940ef4 Tweak a confusing comment in create_match_candidates 2024-06-25 12:16:49 +10:00
surechen 2a6a42329f Change E0369 diagnostic give note information for foreign items.
Make it easy for developers to understand why the binop cannot be applied.

fixes #125631
2024-06-25 10:00:30 +08:00
bors 5b270e1198 Auto merge of #126813 - compiler-errors:SliceLike, r=lcnr
Add `SliceLike` to `rustc_type_ir`, use it in the generic solver code (+ some other changes)

First, we split out `TraitRef::new_from_args` which takes *just* `ty::GenericArgsRef` from `TraitRef::new` which takes `impl IntoIterator<Item: Into<GenericArg>>`. I will explain in a minute why.

Second, we introduce `SliceLike`, which allows us to be generic over `List<T>` and `[T]`. This trait has an `as_slice()` and `into_iter()` method, and some other convenience functions. However, importantly, since types like `I::GenericArgs` now implement `SliceLike` rather than `IntoIter<Item = I::GenericArg>`, we can't use `TraitRef::new` on this directly. That's where `new_from_args` comes in.

Finally, we adjust all the code to use these slice operators. Some things get simpler, some things get a bit more annoying since we need to use `as_slice()` in a few places. 🤷

r? lcnr
2024-06-25 00:33:49 +00:00
bors 6b0f4b5ec3 Auto merge of #126914 - compiler-errors:rollup-zx0hchm, r=compiler-errors
Rollup of 11 pull requests

Successful merges:

 - #124460 (Show notice about  "never used" of Debug for enum)
 - #124712 (Deprecate no-op codegen option `-Cinline-threshold=...`)
 - #125082 (Remove `MaybeUninit::uninit_array()` and replace it with inline const blocks.)
 - #125575 (SmartPointer derive-macro)
 - #126413 (compiletest: make the crash test error message abit more informative)
 - #126673 (Ensure we don't accidentally succeed when we want to report an error)
 - #126682 (coverage: Overhaul validation of the `#[coverage(..)]` attribute)
 - #126899 (Suggest inline const blocks for array initialization)
 - #126904 (Small fixme in core now that NonZero is generic)
 - #126909 (add `@kobzol` to bootstrap team for triagebot)
 - #126911 (Split the lifetimes of `MirBorrowckCtxt`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-24 21:33:02 +00:00
SparkyPotato 26677eb06e don't suggest awaiting type expr patterns 2024-06-24 16:20:22 -05:00
Ana Hobden 553a69030e
Specify target specific linker for riscv64gc-gnu job 2024-06-24 12:58:40 -07:00
Michael Goulet 16bd6e25e1
Rollup merge of #126911 - oli-obk:do_not_count_errors, r=compiler-errors
Split the lifetimes of `MirBorrowckCtxt`

These lifetimes are sometimes too general and will link things together that are independent. These are a blocker for actually finishing tracking more state (e.g. error tainting) in the diagnostic context handle, and I'd rather land it in its own PR instead of together with functional changes.

Also changes a bunch of named lifetimes to `'_` where they were irrelevant

follow-up to https://github.com/rust-lang/rust/pull/126623
2024-06-24 15:51:06 -04:00
Michael Goulet 59c258f51f
Rollup merge of #126909 - onur-ozkan:add-kobzol, r=matthiaskrgr
add @kobzol to bootstrap team for triagebot

Welcome ``@Kobzol`` !
2024-06-24 15:51:05 -04:00
Michael Goulet 85eb835a14
Rollup merge of #126904 - GrigorenkoPV:nonzero-fixme, r=joboet
Small fixme in core now that NonZero is generic

I doubt I have the rights to, but
`@bors` rollup=always
2024-06-24 15:51:05 -04:00
Michael Goulet a7721a0373
Rollup merge of #126899 - GrigorenkoPV:suggest-const-block, r=davidtwco
Suggest inline const blocks for array initialization

#126894
2024-06-24 15:51:04 -04:00
Michael Goulet 9ce2a070b3
Rollup merge of #126682 - Zalathar:coverage-attr, r=lcnr
coverage: Overhaul validation of the `#[coverage(..)]` attribute

This PR makes sweeping changes to how the (currently-unstable) coverage attribute is validated:
- Multiple coverage attributes on the same item/expression are now treated as an error.
- The attribute must always be `#[coverage(off)]` or `#[coverage(on)]`, and the error messages for this are more consistent.
  -  A trailing comma is still allowed after off/on, since that's part of the normal attribute syntax.
- Some places that silently ignored a coverage attribute now produce an error instead.
  - These cases were all clearly bugs.
- Some places that ignored a coverage attribute (with a warning) now produce an error instead.
  - These were originally added as lints, but I don't think it makes much sense to knowingly allow new attributes to be used in meaningless places.
  - Some of these errors might soon disappear, if it's easy to extend recursive coverage attributes to things like modules and impl blocks.

---

One of the goals of this PR is to lay a more solid foundation for making the coverage attribute recursive, so that it applies to all nested functions/closures instead of just the one it is directly attached to.

Fixes #126658.

This PR incorporates #126659, which adds more tests for validation of the coverage attribute.

`@rustbot` label +A-code-coverage
2024-06-24 15:51:03 -04:00
Michael Goulet 49bdf460a2
Rollup merge of #126673 - oli-obk:dont_rely_on_err_reporting, r=compiler-errors
Ensure we don't accidentally succeed when we want to report an error

This also changes the `DefiningOpaqueTypes::No` to `Yes` without adding tests, as it is solely run on the error path to improve diagnostics. I was unable to provide a test that changes diagnostics, as all the tests I came up with ended up successfully constraining the opaque type and thus succeeding the coercion.

r? ```@compiler-errors```

cc https://github.com/rust-lang/rust/issues/116652
2024-06-24 15:51:02 -04:00
Michael Goulet 46e43984d1
Rollup merge of #126413 - matthiaskrgr:crshmsg, r=oli-obk
compiletest: make the crash test error message abit more informative

r?  ```@oli-obk```
2024-06-24 15:51:02 -04:00
Michael Goulet ed460d2eaa
Rollup merge of #125575 - dingxiangfei2009:derive-smart-ptr, r=davidtwco
SmartPointer derive-macro

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->

Possibly replacing #123472 for continued upkeep of the proposal rust-lang/rfcs#3621 and implementation of the tracking issue #123430.

cc `@Darksonn` `@wedsonaf`
2024-06-24 15:51:01 -04:00
Michael Goulet c77dc28f87
Rollup merge of #125082 - kpreid:const-uninit, r=dtolnay
Remove `MaybeUninit::uninit_array()` and replace it with inline const blocks.

\[This PR originally contained the changes in #125995 too. See edit history for the original PR description.]

The documentation of `MaybeUninit::uninit_array()` says:

> Note: in a future Rust version this method may become unnecessary when Rust allows [inline const expressions](https://github.com/rust-lang/rust/issues/76001). The example below could then use `let mut buf = [const { MaybeUninit::<u8>::uninit() }; 32];`.

The PR adding it also said: <https://github.com/rust-lang/rust/pull/65580#issuecomment-544200681>

> if it’s stabilized soon enough maybe it’s not worth having a standard library method that will be replaceable with `let buffer = [MaybeUninit::<T>::uninit(); $N];`

That time has come to pass — inline const expressions are stable — so `MaybeUninit::uninit_array()` is now unnecessary. The only remaining question is whether it is an important enough *convenience* to keep it around.

I believe it is net good to remove this function, on the principle that it is better to compose two orthogonal features (`MaybeUninit` and array construction) than to have a specific function for the specific combination, now that that is possible.
2024-06-24 15:51:01 -04:00
Michael Goulet faa28be2f1
Rollup merge of #124712 - Enselic:deprecate-inline-threshold, r=pnkfelix
Deprecate no-op codegen option `-Cinline-threshold=...`

This deprecates `-Cinline-threshold` since using it has no effect. This has been the case since the new LLVM pass manager started being used, more than 2 years ago.

Recommend using `-Cllvm-args=--inline-threshold=...` instead.

Closes #89742 which is E-help-wanted.
2024-06-24 15:51:00 -04:00
Michael Goulet 00e5f5886a
Rollup merge of #124460 - long-long-float:show-notice-about-enum-with-debug, r=pnkfelix
Show notice about  "never used" of Debug for enum

Close #123068

If an ADT implements `Debug` trait and it is not used, the compiler says a note that indicates intentionally ignored during dead code analysis as [this note](2207179a59/tests/ui/lint/dead-code/unused-variant.stderr (L9)).
However this node is not shown for variants that have fields in enum. This PR fixes to show the note.
2024-06-24 15:51:00 -04:00
bors d8d5732456 Auto merge of #126784 - scottmcm:smaller-terminator, r=compiler-errors
Save 2 pointers in `TerminatorKind` (96 → 80 bytes)

These things don't need to be `Vec`s; boxed slices are enough.

The frequent one here is call arguments, but MIR building knows the number of arguments from the THIR, so the collect is always getting the allocation right in the first place, and thus this shouldn't ever add the shrink-in-place overhead.
2024-06-24 19:22:01 +00:00
onur-ozkan 51f6e68559 handle cargo submodule in a lazy-load way
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-06-24 22:04:30 +03:00
onur-ozkan 8c3ebf7a4d refactor tool_doc macro in bootstrap
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-06-24 22:04:28 +03:00
onur-ozkan 457ac5d570 don't fetch/sync cargo submodule by default
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-06-24 22:04:26 +03:00
onur-ozkan 11acf83159 bootstrap: exclude cargo from package metadata
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-06-24 22:04:24 +03:00
Kevin Reid 13fca73f49 Replace MaybeUninit::uninit_array() with array repeat expression.
This is possible now that inline const blocks are stable; the idea was
even mentioned as an alternative when `uninit_array()` was added:
<https://github.com/rust-lang/rust/pull/65580#issuecomment-544200681>

> if it’s stabilized soon enough maybe it’s not worth having a
> standard library method that will be replaceable with
> `let buffer = [MaybeUninit::<T>::uninit(); $N];`

Const array repetition and inline const blocks are now stable (in the
next release), so that circumstance has come to pass, and we no longer
have reason to want `uninit_array()` other than convenience. Therefore,
let’s evaluate the inconvenience by not using `uninit_array()` in
the standard library, before potentially deleting it entirely.
2024-06-24 10:23:50 -07:00
Michael Goulet 6521c3971d Deny use<> for RPITITs 2024-06-24 12:03:09 -04:00
John Paul Adrian Glaubitz e57bbb3779 rustc_target: Build sparc_unknown_linux_gnu with -mcpu=v9 and -m32
The previously -mv8plus parameter is supported by GCC only, so let's
use something that the SPARC backend in LLVM supports as well.
2024-06-24 17:58:21 +02:00
John Paul Adrian Glaubitz a194f42d21 rustc_target: Rewrite sparc_unknown_linux_gnu spec to use TargetOptions 2024-06-24 17:57:59 +02:00
bors 5a3e2a4e92 Auto merge of #126523 - joboet:the_great_big_tls_refactor, r=Mark-Simulacrum
std: refactor the TLS implementation

As discovered by Mara in #110897, our TLS implementation is a total mess. In the past months, I have simplified the actual macros and their expansions, but the majority of the complexity comes from the platform-specific support code needed to create keys and register destructors. In keeping with #117276, I have therefore moved all of the `thread_local_key`/`thread_local_dtor` modules to the `thread_local` module in `sys` and merged them into a new structure, so that future porters of `std` can simply mix-and-match the existing code instead of having to copy the same (bad) implementation everywhere. The new structure should become obvious when looking at `sys/thread_local/mod.rs`.

Unfortunately, the documentation changes associated with the refactoring have made this PR rather large. That said, this contains no functional changes except for two small ones:
* the key-based destructor fallback now, by virtue of sharing the implementation used by macOS and others, stores its list in a `#[thread_local]` static instead of in the key, eliminating one indirection layer and drastically simplifying its code.
* I've switched over ZKVM (tier 3) to use the same implementation as WebAssembly, as the implementation was just a way worse version of that

Please let me know if I can make this easier to review! I know these large PRs aren't optimal, but I couldn't think of any good intermediate steps.

`@rustbot` label +A-thread-locals
2024-06-24 15:55:28 +00:00
Michael Goulet 8998ce24e0 Replace Deref bounds on Interner in favor of a SliceLike trait 2024-06-24 11:53:34 -04:00
Michael Goulet d521e2148e Also migrate FnInputTys 2024-06-24 11:53:34 -04:00
Michael Goulet 24e41f1d13 Replace Deref bounds on Interner in favor of a SliceLike trait 2024-06-24 11:53:34 -04:00
onur-ozkan 45261ff2ec add @kobzol to bootstrap team for triagebot
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-06-24 18:38:55 +03:00
Michael Goulet a155c38989 Split out IntoIterator and non-Iterator constructors for AliasTy/AliasTerm/TraitRef/projection 2024-06-24 11:28:21 -04:00
Michael Goulet f26cc349d9 Split out IntoIterator and non-Iterator constructors for AliasTy/AliasTerm/TraitRef/projection 2024-06-24 11:28:21 -04:00
John Paul Adrian Glaubitz 8f7175c199 bootstrap: Link against libatomic on 32-bit SPARC
While at it, order the list of architectures alphabetically.
2024-06-24 17:20:55 +02:00
klensy 606ada193f bump strip-ansi-escapes 2024-06-24 18:06:02 +03:00
John Paul Adrian Glaubitz dc8ac3ec91 rustc_llvm: Link against libatomic on 32-bit SPARC
While at it, order the list of architectures alphabetically.
2024-06-24 16:53:09 +02:00
John Paul Adrian Glaubitz 572ae3b227 rustc_data_structures: Use portable AtomicU64 on 32-bit SPARC
While at it, order the list of architectures alphabetically.
2024-06-24 16:52:19 +02:00
Pavel Grigorenko 84474a25a4 Small fixme in core now that NonZero is generic 2024-06-24 17:42:08 +03:00
joboet 50a02ed789
std: fix wasm builds 2024-06-24 16:37:09 +02:00
Oli Scherer 8fc6b3de19 Separate the mir body lifetime from the other lifetimes 2024-06-24 14:28:14 +00:00
Oli Scherer 1c4d0ced58 Separate the lifetimes of the BorrowckInferCtxt from the other borrowed items 2024-06-24 14:28:13 +00:00
Vadim Petrochenkov c4c7859e40 resolve: Implement a lint for out-of-scope use of macro_rules 2024-06-24 17:12:08 +03:00
bors d371d17496 Auto merge of #126900 - matthiaskrgr:rollup-24ah97b, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #125241 (Add `rust_analyzer` as a predefined tool)
 - #126213 (Update docs for AtomicBool/U8/I8 with regard to alignment)
 - #126414 (Tier 2 std support must always be known)
 - #126882 (Special case when a code line only has multiline span starts)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-24 13:42:05 +00:00
bors 863179081e Auto merge of #12986 - Alexendoo:cache-lintcheck-bin, r=flip1995
Cache lintcheck binary in ci

Always trims ~40s off the `diff` job as it no longer needs to install the rust toolchain or compile lintcheck. Saves a further ~20s for the `base`/`head` jobs when the cache is warm

It now uses artifacts for restoring the JSON between jobs as per https://github.com/rust-lang/rust-clippy/pull/10398#discussion_r1642364392, cc `@flip1995`

The lintcheck changes are to make `./target/debug/lintcheck` work, running `cargo-clippy`/`clippy-driver` directly doesn't work without `LD_LIBRARY_PATH`/etc being set which is currently being done by `cargo run`. By merging the `--recursive` and normal cases to both go via regular `cargo check` we can have Cargo set up the environment for us

r? `@xFrednet`

changelog: none
2024-06-24 13:23:51 +00:00
Matthias Krüger 8ffb5f936a compiletest: make the crash test error message abit more informative 2024-06-24 15:18:50 +02:00
Vadim Petrochenkov 8c718e5524 ast: Standardize visiting order for attributes and node IDs 2024-06-24 16:08:51 +03:00
Vadim Petrochenkov 0195758c1a ast: Standardize visiting order for attributes and node IDs 2024-06-24 16:08:51 +03:00
Matthias Krüger a80ee9159b
Rollup merge of #126882 - estebank:multiline-order, r=WaffleLapkin
Special case when a code line only has multiline span starts

Minimize multline span overlap when there are multiple of them starting on the same line:

```
3 |       X0 Y0 Z0
  |  _____^  -  -
  | | _______|  |
  | || _________|
4 | |||   X1 Y1 Z1
5 | |||   X2 Y2 Z2
  | |||____^__-__- `Z` label
  | ||_____|__|
  | |______|  `Y` is a good letter too
  |        `X` is a good letter
```
2024-06-24 15:06:23 +02:00
Matthias Krüger 8bfde609e2
Rollup merge of #126414 - ChrisDenton:target-known, r=Nilstrieb
Tier 2 std support must always be known

We should never have a tier 2 target without knowing its support status so I think this line in the tier 2 section is a bit wrong:

> ? indicates the standard library support is unknown or a work-in-progress.

My first inclination was just to drop the "unknown or" part. However, after thinking about it some more, I think we should just use `✓` for this. The only affected targets are UEFI and frankly there are targets with worse std support that are marked with `✓` (e.g. wasm).

I think a `✓` should mean "this supports building with std (and is checked in CI for tier 2+)". The target errata can detail the current limitations or special requirements for doing so.
2024-06-24 15:06:22 +02:00
Matthias Krüger 94b9ea417d
Rollup merge of #126213 - zachs18:atomicbool-u8-i8-from-ptr-alignment, r=Nilstrieb
Update docs for AtomicBool/U8/I8 with regard to alignment

Fixes #126084.

Since `AtomicBool`/`AtomicU8`/`AtomicI8` are guaranteed to have size == 1, and Rust guarantees that `size % align == 0`, they also must have alignment equal to 1, so some current docs are contradictory/confusing when describing their alignment requirements.

Specifically:

* Fix `AtomicBool::from_ptr` claiming that `align_of::<AtomicBool>() > align_of::<bool>()` on some platforms. (same for `AtomicU8::from_ptr`/`AtomicI8::from_ptr`)
* Explicitly state that `AtomicU8`/`AtomicI8` have the same alignment as `u8`/`i8` (in addition to size and bit validity)
* (internal) Change the `if_not_8_bit` macro to be `if_8_bit` and to allow an "if-else"-like structure, instead of just "if"-like.

---

I opted to leave the "`ptr` must be aligned" wording in `from_ptr`'s docs and just clarify that it is always satsified, instead of just removing the wording entirely. If that is instead preferred I can do that.
2024-06-24 15:06:21 +02:00