Commit graph

236334 commits

Author SHA1 Message Date
Matthias Krüger a5aa52c23a
Rollup merge of #116717 - estebank:issue-9082, r=oli-obk
Special case iterator chain checks for suggestion

When encountering method call chains of `Iterator`, check for trailing `;` in the body of closures passed into `Iterator::map`, as well as calls to `<T as Clone>::clone` when `T` is a type param and `T: !Clone`.

Fix #9082.
2023-10-17 19:07:22 +02:00
Matthias Krüger ce407429dd
Rollup merge of #111072 - Urgau:check-cfg-new-syntax, r=petrochenkov
Add new simpler and more explicit syntax for check-cfg

<details>
<summary>
Old proposition (before the MCP)
</summary>

This PR adds a new simpler and more explicit syntax for check-cfg. It consist of two new form:
 - `exhaustive(names, values)`
 - `configure(name, "value1", "value2", ... "valueN")`

The preview forms `names(...)` and `values(...)` have implicit meaning that are not strait-forward. In particular `values(foo)`&`values(bar)` and `names(foo, bar)` are not equivalent which has created [some confusions](https://github.com/rust-lang/rust/pull/98080).

Also the `names()` and `values()` form are not clear either and again created some confusions where peoples believed that `values()`&`values(foo)` could be reduced to just `values(foo)`.

To fix that the two new forms are made to be explicit and simpler. See the table of correspondence:
  - `names()` -> `exhaustive(names)`
  - `values()` -> `exhaustive(values)`
  - `names(foo)` -> `exhaustive(names)`&`configure(foo)`
  - `values(foo)` -> `configure(foo)`
  - `values(feat, "foo", "bar")` -> `configure(feat, "foo", "bar")`
  - `values(foo)`&`values(bar)` -> `configure(foo, bar)`
  - `names()`&`values()`&`values(my_cfg)` -> `exhaustive(names, values)`&`configure(my_cfg)`

Another benefits of the new syntax is that it allow for further options (like conditional checking for --cfg, currently always on) without syntax change.

The two previous forms are deprecated and will be removed once cargo and beta rustc have the necessary support.

</details>

This PR is the first part of the implementation of [MCP636 - Simplify and improve explicitness of the check-cfg syntax](https://github.com/rust-lang/compiler-team/issues/636).

## New `cfg` form

It introduces the new [`cfg` form](https://github.com/rust-lang/compiler-team/issues/636) and deprecate the other two:
```
rustc --check-cfg 'cfg(name1, ..., nameN, values("value1", "value2", ... "valueN"))'
```

## Default built-in names and values

It also changes the default for the built-in names and values checking.

 - Built-in values checking would always be activated as long as a `--check-cfg` argument is present
 - Built-in names checking would always be activated as long as a `--check-cfg` argument is present **unless** if any `cfg(any())` arg is passed

~~**Note: depends on https://github.com/rust-lang/rust/pull/111068 but is reviewable (last two commits)!**~~

Resolve https://github.com/rust-lang/compiler-team/issues/636

r? `@petrochenkov`
2023-10-17 19:07:21 +02:00
bors 93e62a260f Auto merge of #115577 - RalfJung:atomic-load, r=Amanieu
document when atomic loads are guaranteed read-only

Based on this [discussion in Zulip](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/Can.20.60Atomic*.3A.3Aload.60.20perform.20a.20write).

The values for x86 and x86_64 are complete guesswork on my side, and I have no clue what the values might be for other architectures. I hope we can get the right people to chime in to gather the required information. :)

I'll update Miri to respect these rules once we have more data.
2023-10-17 14:11:31 +00:00
bors 616e37919c Auto merge of #116756 - fee1-dead-contrib:dupe-those-bounds, r=oli-obk
Duplicate `~const` bounds with a non-const one in effects desugaring

This should unblock #116058.

r? `@oli-obk`
2023-10-17 12:16:54 +00:00
bors 2e57d647b0 Auto merge of #116518 - vita-rust:vita, r=workingjubilee
Updated libc and doc for Vita target

Doc changes:

- Updated Vita target readme. The recommended approach to build artifacts for the platform now is [cargo-vita](https://crates.io/crates/cargo-vita) which wraps all the convoluted steps previously described in a yaml for `cargo-make`
- Updated maintainer list for Vita target. (`@ZetaNumbers` `@pheki` please agree to be added to the list, `@amg98` please let us know if you're still planning on actively maintaining target support)

Code changes:
- ~Updated libc for rust-lang/libc#3284 and rust-lang/libc#3366~ (Already merged in #116527)
- In dupfd changed the flag same as for esp target, there is no CLOEXEC on Vita
- Enabled `new_pair` since we've implemented `socketpair` in Vita newlib
2023-10-17 10:22:14 +00:00
bors 347452e7e3 Auto merge of #116196 - onur-ozkan:reorganize-bootstrap-sources, r=Mark-Simulacrum
reorganize/refactor bootstrap codebase

Currently, bootstrap stores everything on the root path, including very large modules, which makes things very hard to scale and adds too much complexity.

This PR has the following objectives:

- Improving scalability.
- Making bootstrap source more understandable for the new contributors(or for everyone).
- Improving the development experience and making maintenance easier for the bootstrap team.

The new source structure:

```
.
├── defaults
│   ├── README.md
│   ├── config.codegen.toml
│   ├── config.compiler.toml
│   ├── config.dist.toml
│   ├── config.library.toml
│   └── config.tools.toml
├── mk
│   └── Makefile.in
├── src
│   ├── bin
│   │   ├── main.rs
│   │   ├── rustc.rs
│   │   ├── rustdoc.rs
│   │   └── sccache-plus-cl.rs
│   ├── core
│   │   ├── build_steps
│   │   │   ├── check.rs
│   │   │   ├── clean.rs
│   │   │   ├── compile.rs
│   │   │   ├── dist.rs
│   │   │   ├── doc.rs
│   │   │   ├── format.rs
│   │   │   ├── install.rs
│   │   │   ├── llvm.rs
│   │   │   ├── mod.rs
│   │   │   ├── run.rs
│   │   │   ├── setup.rs
│   │   │   ├── suggest.rs
│   │   │   ├── synthetic_targets.rs
│   │   │   ├── test.rs
│   │   │   ├── tool.rs
│   │   │   └── toolstate.rs
│   │   ├── config
│   │   │   ├── config.rs
│   │   │   ├── flags.rs
│   │   │   └── mod.rs
│   │   ├── builder.rs
│   │   ├── download.rs
│   │   ├── metadata.rs
│   │   ├── mod.rs
│   │   └── sanity.rs
│   ├── tests
│   │   ├── builder.rs
│   │   ├── config.rs
│   │   └── setup.rs
│   ├── utils
│   │   ├── bin_helpers.rs
│   │   ├── cache.rs
│   │   ├── cc_detect.rs
│   │   ├── channel.rs
│   │   ├── dylib.rs
│   │   ├── helpers.rs
│   │   ├── job.rs
│   │   ├── metrics.rs
│   │   ├── mod.rs
│   │   ├── render_tests.rs
│   │   └── tarball.rs
│   └── lib.rs
├── Cargo.lock
├── Cargo.toml
├── README.md
├── bootstrap.py
├── bootstrap_test.py
├── build.rs
├── configure.py
└── download-ci-llvm-stamp
```

The next step involves:

- Adding more doc-comments to the bootstrap internals (although we already have a decent amount, there is space for improvement).
- Breaking large modules into smaller, more manageable modules.
- Significantly increasing our unit test coverage (which is currently lacking).

This PR should serve as an initial step to make the tasks above much more easier.

r? Mark-Simulacrum
2023-10-17 08:27:19 +00:00
Nikolay Arhipov ba13e37e30 Updated libc and doc for Vita target 2023-10-17 10:44:39 +03:00
onur-ozkan 3ecff1b760 bootstrap: fix warnings
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-10-17 10:07:12 +03:00
onur-ozkan f1e3e75f6c rename bootstrap module utils/dylib_util->utils/dylib
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-10-17 10:07:08 +03:00
onur-ozkan 9f381fe345 move bootstrap utils into bootstrap/src/utils module
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-10-17 10:07:04 +03:00
onur-ozkan 2bce0207d4 move bootstrap core implementation to bootstrap/src/core module
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-10-17 10:06:56 +03:00
onur-ozkan c68ab9347e improve bootstrap tests structure
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-10-17 10:06:52 +03:00
onur-ozkan acef1c2c57 reorganize bootstrap bins and helper module utilizations
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-10-17 10:06:48 +03:00
bors ddef56d5df Auto merge of #116824 - notriddle:master, r=fmease
rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 3)

Follow up

* https://github.com/rust-lang/rust/pull/116214
* https://github.com/rust-lang/rust/pull/116432
2023-10-17 06:34:03 +00:00
Ralf Jung e494df436d remove 128bit atomics, they are anyway not exposed on those targets 2023-10-17 07:56:49 +02:00
bors 631a116cd3 Auto merge of #116822 - notriddle:notriddle/rust-logo, r=fmease
docs: add Rust logo to more compiler crates

c6e6ecb1af added it to some of the compiler's crates, but avoided adding it to all of them to reduce bit-rot. This commit adds to more.

r? `@GuillaumeGomez`
2023-10-17 04:41:20 +00:00
bors c07693c160 Auto merge of #116477 - nnethercote:tidy-alpha-deps, r=wesleywiser
Use tidy to enforce alphabetical dependency ordering

I get annoyed when dependencies in `Cargo.toml` files are not in alphabetical order. The [style guide](https://github.com/rust-lang/rust/blob/master/src/doc/style-guide/src/cargo.md) agrees with me.

There are ongoing efforts to provide linting/formatting of `Cargo.toml` files, e.g. https://github.com/rust-lang/rustfmt/pull/5240, https://crates.io/crates/cargo-toml-lint, and https://github.com/TimonPost/cargo-toml-format. But it's far from clear what's the right approach.

So this PR does something very simple: it uses the order checking already present in tidy. This allows incremental application of ordering, starting right now, and avoiding the need for any kind of all-at-once conversion.

If we do end up using some more comprehensive `Cargo.toml` linting/formatting solution in the future, the `tidy-alphabetical` lines will be easy to remove.

r? `@wesleywiser`
2023-10-17 02:48:03 +00:00
Michael Howell c0b6a5d340 rustdoc: add check-pass to ICE test with no expected output 2023-10-16 18:03:22 -07:00
Michael Howell 94b39e8c86 rustdoc: move ICE test to rustdoc-ui 2023-10-16 18:02:11 -07:00
Michael Howell 43b493ebc0 Add URL to test cases 2023-10-16 18:01:02 -07:00
Michael Howell 69dc19043b Rename issue-\d+.rs tests to have meaningful names 2023-10-16 18:01:02 -07:00
bors 39164b84e0 Auto merge of #116826 - nnethercote:fix-116780-116797, r=compiler-errors
Fix a performance regression in obligation deduplication.

Commit 8378487 from #114611 changed the location of an obligation deduplication step in `opt_normalize_projection_type`. This meant that deduplication stopped happening on one path where it was still necessary, causing a couple of drastic performance regressions.

This commit moves the deduplication back to the old location. The good news is that #114611 had four commits and 8378487 was of minimal importance, so the perf benefits from that PR remain.

Fixes #116780, #116797.

r? `@compiler-errors`
2023-10-17 00:53:53 +00:00
Nicholas Nethercote 91f2fbc867 Fix a performance regression in obligation deduplication.
Commit 8378487 from #114611 changed the location of an obligation
deduplication step in `opt_normalize_projection_type`. This meant that
deduplication stopped happening on one path where it was still
necessary, causing a couple of drastic performance regressions.

This commit moves the deduplication back to the old location. The good
news is that #114611 had four commits and 8378487 was of minimal
importance, so the perf benefits from that PR remain.

Fixes #116780, #116797.
2023-10-17 11:02:59 +11:00
bors 64338796ab Auto merge of #116820 - GuillaumeGomez:rollup-l54ri5q, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #116754 (coverage: Several small cleanups in `spans`)
 - #116798 (Improve display of parallel jobs in rustdoc-gui tester script)
 - #116800 (Fix implied outlives check for GAT in RPITIT)
 - #116805 (Make `rustc_onunimplemented` export path agnostic)
 - #116808 (Add myself to smir triage)
 - #116811 (Preserve unicode escapes in format string literals when pretty-printing AST)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-16 23:01:20 +00:00
Michael Howell df5ea58287 Add crate_name to test so that it can be renamed 2023-10-16 15:41:04 -07:00
Michael Howell 2ff2624722 docs: add Rust logo to more compiler crates
c6e6ecb1af added it to some of the
compiler's crates, but avoided adding it to all of them to reduce
bit-rot. This commit adds to more.
2023-10-16 15:38:08 -07:00
Guillaume Gomez 05e2056746
Rollup merge of #116811 - narpfel:unpretty-unicode-escape-in-format-string-literal, r=Nilstrieb
Preserve unicode escapes in format string literals when pretty-printing AST

Fixes #116799

Thanks to `@Nilstrieb` for the pointer to the correct location, that was really helpful for someone unfamiliar with the codebase.
2023-10-16 23:58:06 +02:00
Guillaume Gomez 23000c3980
Rollup merge of #116808 - ouz-a:add_myself_to_triage, r=Nilstrieb
Add myself to smir triage

I would like get pinged when someone makes changes to smir
2023-10-16 23:58:05 +02:00
Guillaume Gomez 347f7f3bf4
Rollup merge of #116805 - Nilstrieb:onunimplemented-std-core-alloc-whatever-who-cares, r=compiler-errors
Make `rustc_onunimplemented` export path agnostic

This makes it so that all the matchers that match against paths use the definition path instead of the export path. This removes all duplication around `std`/`alloc`/`core`.

This is not necessarily optimal because we now depend on internal implementation details like `core::ops::control_flow::ControlFlow`, which is not very nice and probably not acceptable for a stable `on_unimplemented`.

An alternative would be to just string-replace normalize away `alloc`/`core` to `std` as a special case, keeping the export paths but making it so that we're still fully standard library flavor agnostic.

Looking at the diff, I'm starting to think that some simple string replacement would go a long way towards fixing the problem of duplication while keeping export paths...

What do you prefer?

Also `@weiznich` for your thoughts about the stable version.

r? compiler-errors
2023-10-16 23:58:05 +02:00
Guillaume Gomez d0ade3f1ba
Rollup merge of #116800 - compiler-errors:rpitit-gat-outlives, r=jackh726
Fix implied outlives check for GAT in RPITIT

We enforce certain `Self: 'lt` bounds for GATs to save space for more sophisticated implied bounds, but those currently operate on the HIR. Code was easily reworked to operate on def-ids so that we can properly let these suggestions propagate through synthetic associated types like RPITITs and AFITs.

r? `@jackh726` or `@aliemjay`

Fixes #116789
2023-10-16 23:58:04 +02:00
Guillaume Gomez 4c1c8abbf3
Rollup merge of #116798 - GuillaumeGomez:rustdoc-gui-tester-cleanup, r=notriddle
Improve display of parallel jobs in rustdoc-gui tester script

If no `-j` option is not passed to `x.py`, it would display `-1`, which isn't great.

r? `@notriddle`
2023-10-16 23:58:04 +02:00
Guillaume Gomez 581f88deda
Rollup merge of #116754 - Zalathar:spans, r=oli-obk
coverage: Several small cleanups in `spans`

While investigating the details of coverage span processing, I noticed several opportunities to make the code simpler and clearer.

---

`@rustbot` label +A-code-coverage
2023-10-16 23:58:03 +02:00
bors 49691b1f70 Auto merge of #114370 - krtab:pop_assume_cap, r=scottmcm
Add invariant to Vec::pop that len < cap if pop successful

Fixes: https://github.com/rust-lang/rust/issues/114334
2023-10-16 21:06:14 +00:00
Esteban Küber 26954f60ff address review comment 2023-10-16 19:48:53 +00:00
Paul Gey 587899e9ca Preserve unicode escapes in format string literals when pretty-printing AST 2023-10-16 21:20:21 +02:00
bors a76ec181fb Auto merge of #116804 - matthiaskrgr:rollup-m2qm8ul, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #114157 (Enable triagebot no-merges check)
 - #116257 (Suggest trait bounds for used associated type on type param)
 - #116430 (vendoring in tarball sources)
 - #116709 (Update minifier version to 0.2.3)
 - #116786 (Update my mailmap entry)
 - #116790 (opt-dist: disable unused features for tabled crate)
 - #116802 (Remove `DefiningAnchor::Bubble` from opaque wf check)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-16 18:57:44 +00:00
Guillaume Gomez ad26a0b3dd Improve display of parallel jobs in rustdoc-gui tester script 2023-10-16 20:16:08 +02:00
Oğuz Ağcayazı 5e6da1e306 add myself to smir triage 2023-10-16 20:49:03 +03:00
Nilstrieb 414135d522 Make rustc_onunimplemented export path agnostic
This makes it so that all the matchers that match against paths use the
definition path instead of the export path. This removes all duplication
around `std`/`alloc`/`core`.

This is not necessarily optimal because we now depend on internal
implementation details like `core::ops::control_flow::ControlFlow`,
which is not very nice and probably not acceptable for a stable
`on_unimplemented`.

An alternative would be to just string-replace normalize away
`alloc`/`core` to `std` as a special case, keeping the export paths but
making it so that we're still fully standard library flavor agnostic.
2023-10-16 19:37:12 +02:00
Ralf Jung 6605116463 use target-arch based table 2023-10-16 19:29:16 +02:00
Matthias Krüger b0572f1a12
Rollup merge of #116802 - compiler-errors:anchor-opaque-wf, r=oli-obk
Remove `DefiningAnchor::Bubble` from opaque wf check

Set the defining anchor to `DefiningAnchor::Bind(parent_def_id)` where `parent_def_id` is the first parent def-id that isn't an opaque.

This "fixes" some of the nested-return-type wf tests. If we *do* want these to be hard-errors for TAITs, we should probably make those error separately from this check (i.e. via some check like the code in the `OPAQUE_HIDDEN_INFERRED_BOUND` lint). The fact that some of these tests fail but not all of them seems kinda coincidental.

r? oli-obk
2023-10-16 19:10:51 +02:00
Matthias Krüger 98ea131a6e
Rollup merge of #116790 - klensy:opt-dist-tabled-no-derive, r=Kobzol
opt-dist: disable unused features for tabled crate

Features looks unused, so left only used ones.

r? `@Kobzol`
2023-10-16 19:10:51 +02:00
Matthias Krüger cacde6767f
Rollup merge of #116786 - Urgau:mailmap-update, r=Nilstrieb
Update my mailmap entry
2023-10-16 19:10:50 +02:00
Matthias Krüger 96be07e566
Rollup merge of #116709 - GuillaumeGomez:update-minifier, r=notriddle
Update minifier version to 0.2.3

Thanks for the fix `@notriddle` !

r? `@notriddle`
2023-10-16 19:10:50 +02:00
Matthias Krüger 6f9df29ad5
Rollup merge of #116430 - onur-ozkan:vendoring-in-tarball-sources, r=clubby789
vendoring in tarball sources

fixes #94782
2023-10-16 19:10:49 +02:00
Matthias Krüger 14663e09b7
Rollup merge of #116257 - estebank:issue-101351, r=b-naber
Suggest trait bounds for used associated type on type param

Fix #101351.

When an associated type on a type parameter is used, and the type parameter isn't constrained by the correct trait, suggest the appropriate trait bound:

```
error[E0220]: associated type `Associated` not found for `T`
 --> file.rs:6:15
  |
6 |     field: T::Associated,
  |               ^^^^^^^^^^ there is a similarly named associated type `Associated` in the trait `Foo`
  |
help: consider restricting type parameter `T`
  |
5 | struct Generic<T: Foo> {
  |                 +++++
  ```

When an associated type on a type parameter has a typo, suggest fixing
it:

```
error[E0220]: associated type `Baa` not found for `T`
  --> $DIR/issue-55673.rs:9:8
   |
LL |     T::Baa: std::fmt::Debug,
   |        ^^^ there is a similarly named associated type `Bar` in the trait `Foo`
   |
help: change the associated type name to use `Bar` from `Foo`
   |
LL |     T::Bar: std::fmt::Debug,
   |        ~~~
```
2023-10-16 19:10:49 +02:00
Matthias Krüger cf25110def
Rollup merge of #114157 - pitaj:triagebot_no-merges, r=ehuss
Enable triagebot no-merges check

Follow-up on https://github.com/rust-lang/triagebot/pull/1704

### Motivation

Occasionally, a merge commit like cb5c011670 makes it past manual review and gets merged into master.

At one point, we tried adding a check to CI to prevent this from happening (https://github.com/rust-lang/rust/pull/105058), but that ended up [problematic](https://github.com/rust-lang/rust/pull/106319#issuecomment-1368144076) and was [reverted](https://github.com/rust-lang/rust/pull/106320). This kind of check is simply too fragile for CI, and there must be a way for a human to override the bot's decision.

The capability to detect and warn about merge commits has been present in triagebot for quite some time, but was never enabled at rust-lang/rust, possibly due to concerns about false positives on rollup and subtree sync PRs. This PR intends to alleviate those concerns.

### Configuration

This configuration will exclude rollup PRs and subtree sync PRs from merge commit detection, and it will post the default warning message and add the `has-merge-commits` and `S-waiting-on-author` labels when merge commits are detected on other PRs.

The eventual vision is to have bors refuse to merge if the `has-merge-commits` label is present. A reviewer can still force the merge by removing that label if they so wish.

### Note for contributors

The rollup tool should add that label automatically, but anyone performing subtree updates should begin including "subtree update" in the titles of those PRs, to avoid false positives.

r? infra

## Open Questions

1. This configuration uses the default message that's built into triagebot:

> There are merge commits (commits with multiple parents) in your changes. We have a [no merge policy](https://rustc-dev-guide.rust-lang.org/git.html#no-merge-policy) so these commits will need to be removed for this pull request to be merged.
>
> You can start a rebase with the following commands:
> ```shell-session
> $ # rebase
> $ git rebase -i master
> $ # delete any merge commits in the editor that appears
> $ git push --force-with-lease
> ```

Any changes to this are easy, I'll just have to add a `message` option. Should we mention the excluded titles in the message?
2023-10-16 19:10:48 +02:00
Arthur Carcano 0bcac8a7f2 Add invariant to Vec::pop that len < cap if pop successful
Fixes: https://github.com/rust-lang/rust/issues/114334
2023-10-16 18:49:25 +02:00
bors 4af886f8ab Auto merge of #116731 - Alexendoo:hash-untracked-state, r=oli-obk
Add `Config::hash_untracked_state` callback

For context, I'm looking to use [late module passes](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/context/struct.LintStore.html#structfield.late_module_passes) in Clippy which unlike regular late passes run incrementally per module

However we have a config file which can change between runs, we need changes to that to invalidate the `lint_mod` query. This PR adds a side channel for us to hash some extra state into `Options` in order to do that

This does not make any changes to Clippy, I plan to do that in a PR to the Clippy repo along with some other required changes

An alternative implementation would be to add a new query to track this state and override the `lint_mod` query in Clippy to first call that

cc `@rust-lang/clippy`
2023-10-16 16:33:42 +00:00
Michael Goulet 743e6d1601 Remove DefiningAnchor::Bubble from opaque wf check 2023-10-16 15:50:31 +00:00