Commit Graph

236359 Commits

Author SHA1 Message Date
Ali MJ Al-Nasrawy a1e274f172 revert rust-lang/rust#114586 2023-10-18 06:19:04 +00:00
bors 5d5edf0248 Auto merge of #116505 - saethlin:infer-inline, r=cjgillot
Automatically enable cross-crate inlining for small functions

This is basically reviving https://github.com/rust-lang/rust/pull/70550

The `#[inline]` attribute can have a significant impact on code generation or runtime performance (because it enables inlining between CGUs where it would normally not happen) and also on compile-time performance (because it enables MIR inlining). But it has to be added manually, which is awkward.

This PR factors whether a DefId is cross-crate inlinable into a query, and replaces all uses of `CodegenFnAttrs::requests_inline` with this new query. The new query incorporates all the other logic that is used to determine whether a Def should be treated as cross-crate-inlinable, and as a last step inspects the function's optimized_mir to determine if it should be treated as cross-crate-inlinable.

The heuristic implemented here is deliberately conservative; we only infer inlinability for functions whose optimized_mir does not contain any calls or asserts. I plan to study adjusting the cost model later, but for now the compile time implications of this change are so significant that I think this very crude heuristic is well worth landing.
2023-10-18 02:00:44 +00:00
bors ca89f732ec Auto merge of #116840 - nikic:update-llvm-15, r=cuviper
Update to LLVM 17.0.3

Fixes https://github.com/rust-lang/rust/issues/116582.
Fixes miscompile reported at https://github.com/rust-lang/rust/pull/104862.

r? `@cuviper`
2023-10-18 00:04:46 +00:00
Ben Kimock a76cae0234 Bless coverage-map tests 2023-10-17 19:53:51 -04:00
Ben Kimock 33b0e4be06 Automatically enable cross-crate inlining for small functions 2023-10-17 19:53:51 -04:00
bors 09df6108c8 Auto merge of #116767 - cjgillot:alloc-normalize, r=oli-obk
Normalize alloc-id in tests.

AllocIds are globally numbered in a rustc invocation. This makes them very sensitive to changes unrelated to what is being tested. This commit normalizes them by renumbering, in order of appearance in the output.

The renumbering allows to keep the identity, that a simple `allocN` wouldn't. This is useful when we have memory dumps.

cc `@saethlin`
r? `@oli-obk`
2023-10-17 20:46:53 +00:00
bors 94ba57cef4 Auto merge of #116855 - matthiaskrgr:rollup-i2izdwb, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #111072 (Add new simpler and more explicit syntax for check-cfg)
 - #116717 (Special case iterator chain checks for suggestion)
 - #116719 (Add MonoItems and Instance to stable_mir)
 - #116787 (Implement an internal lint encouraging use of `Span::eq_ctxt`)
 - #116827 (Make `handle_options` public again.)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-17 18:51:46 +00:00
Matthias Krüger 6e6cd68cd0
Rollup merge of #116827 - nnethercote:pub-handle_options, r=compiler-errors
Make `handle_options` public again.

r? ``@compiler-errors``
2023-10-17 19:07:24 +02:00
Matthias Krüger 3ea438eb3a
Rollup merge of #116787 - a-lafrance:span-internal-lint, r=oli-obk
Implement an internal lint encouraging use of `Span::eq_ctxt`

Adds a new Rustc internal lint that forbids use of `.ctxt() == .ctxt()` for spans, encouraging use of `.eq_ctxt()` instead (see https://github.com/rust-lang/rust/issues/49509).

Also fixed a few violations of the lint in the Rustc codebase (a fun additional way I could test my code). Edit: MIR opt folks I believe that's why you're CC'ed, just a heads up.

Two things I'm not sure about:
1. The way I chose to detect calls to `Span::ctxt`. I know adding diagnostic items to methods is generally discouraged, but after some searching and experimenting I couldn't find anything else that worked, so I went with it. That said, I'm happy to implement something different if there's a better way out there. (For what it's worth, if there is a better way, it might be worth documenting in the rustc-dev-guide, which I'm happy to take care of)
2. The error message for the lint. Ideally it would probably be good to give some context as to why the suggestion is made (e.g. `rustc::default_hash_types` tells the user that it's because of performance), but I don't have that context so I couldn't put it in the error message. Happy to iterate on the error message based on feedback during review.

r? ``@oli-obk``
2023-10-17 19:07:23 +02:00
Matthias Krüger 00f529d246
Rollup merge of #116719 - celinval:smir-mono, r=oli-obk
Add MonoItems and Instance to stable_mir

Also add a few methods to instantiate instances and get an instance definition. We're still missing support to actually monomorphize the instance body.

This is related to https://github.com/rust-lang/project-stable-mir/issues/36

r? ``@oli-obk``

``@oli-obk`` is that what you were thinking? I incorporated ``@bjorn3`` idea of just adding a Shim instance definition in https://github.com/rust-lang/rust/pull/116465.
2023-10-17 19:07:23 +02:00
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 bb74d1fa85 Auto merge of #116844 - weihanglo:update-cargo, r=weihanglo
Update cargo

17 commits in 6fa6fdc7606cfa664f9bee2fb33ee2ed904f4e88..ff768b45b302efd488178b31b35489e4fabb8799
2023-10-10 23:06:08 +0000 to 2023-10-17 12:51:31 +0000
- Clarify flag behavior in `cargo remove --help` (rust-lang/cargo#12823)
- doc(cargo-login): mention args after `--` in manpage (rust-lang/cargo#12832)
- changelog: add compat notice for `cargo login -- &lt;arg&gt;` (rust-lang/cargo#12830)
- update SPDX License info (rust-lang/cargo#12827)
- Add test for `-V` short argument (rust-lang/cargo#12822)
- add detailed message when target folder path is invalid (rust-lang/cargo#12820)
- chore(deps): update rust crate toml_edit to 0.20.2 (rust-lang/cargo#12761)
- Support `public` dependency configuration with workspace deps (rust-lang/cargo#12817)
- Update rustix to 0.38.18 (rust-lang/cargo#12815)
- contrib docs: add some conveniences (rust-lang/cargo#12812)
- Better suggestion for unsupported `--path` flag (rust-lang/cargo#12811)
- contrib docs: update rfc and roadmap links (rust-lang/cargo#12814)
- contrib doc: remove extraneous word (rust-lang/cargo#12813)
- Update curl-sys to pull in curl 8.4.0 (rust-lang/cargo#12808)
- feat: add package name and version to warning messages (rust-lang/cargo#12799)
- Do not call it "Downgrading" when difference is only build metadata (rust-lang/cargo#12796)
- Add unsupported short flag suggestion for `--target` and `--exclude` flags (rust-lang/cargo#12805)

r? ghost
2023-10-17 16:57:40 +00:00
Weihang Lo 8f970c72a6
Update cargo 2023-10-17 10:26:13 -04: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
Nikita Popov ab22470eb3 Update to LLVM 17.0.3 2023-10-17 10:44:45 +02: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
Arthur Lafrance e89d4d4871 fix lint failures in clippy 2023-10-16 19:50:31 -07:00
Arthur Lafrance 52ad8199d5 tweak pass description and fix lint fail post-rebase 2023-10-16 19:50:31 -07:00
Arthur Lafrance 5895102c4d debug Span::ctxt() call detection 2023-10-16 19:50:29 -07: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
Arthur Lafrance f77dea89e1 basic lint v2 implemented 2023-10-16 19:47:33 -07:00
Arthur Lafrance 8769e02d0b implement the basics of the lint static analysis 2023-10-16 19:47:33 -07:00
Nicholas Nethercote b0e1a52e37 Make `handle_options` public again. 2023-10-17 13:25:58 +11: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