Commit Graph

212308 Commits

Author SHA1 Message Date
KaDiWa
9bc69925cb
compiler: remove unnecessary imports and qualified paths 2022-12-10 18:45:34 +01:00
bors
a161a7b654 Auto merge of #105384 - uweigand:s390x-test-codegen, r=Mark-Simulacrum
Fix failing codegen tests on s390x

Several codegen tests are currently failing due to making assumptions that are not valid for the s390x architecture:

- catch-unwind.rs: fails due to inlining differences. Already ignored on another platform for the same reason. Solution: Ignore on s390x.

- remap_path_prefix/main.rs: fails due to different alignment requirement for string constants. Solution: Do not test for the alignment requirement.

- repr-transparent-aggregates-1.rs: many ABI assumptions. Already ignored on many platforms for the same reason. Solution: Ignore on s390x.

- repr-transparent.rs: no vector ABI by default on s390x. Already ignored on another platform for a similar reason. Solution: Ignore on s390x.

- uninit-consts.rs: hard-coded little-endian constant. Solution: Match both little- and big-endian versions.

Fixes part of https://github.com/rust-lang/rust/issues/105383.
2022-12-10 13:56:58 +00:00
bors
b12b83674f Auto merge of #105525 - matthiaskrgr:rollup-ricyw5s, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #98391 (Reimplement std's thread parker on top of events on SGX)
 - #104019 (Compute generator sizes with `-Zprint_type_sizes`)
 - #104512 (Set `download-ci-llvm = "if-available"` by default when `channel = dev`)
 - #104901 (Implement masking in FileType comparison on Unix)
 - #105082 (Fix Async Generator ABI)
 - #105109 (Add LLVM KCFI support to the Rust compiler)
 - #105505 (Don't warn about unused parens when they are used by yeet expr)
 - #105514 (Introduce `Span::is_visible`)
 - #105516 (Update cargo)
 - #105522 (Remove wrong note for short circuiting operators)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-10 11:16:18 +00:00
Matthias Krüger
f6c2add0ed
Rollup merge of #105522 - est31:remove_or_and_note, r=scottmcm
Remove wrong note for short circuiting operators

They *are* representable by traits, even if the short-circuiting behaviour requires a different approach than the non-short-circuiting operators. For an example proposal, see the postponed [RFC 2722](https://github.com/rust-lang/rfcs/pull/2722). As it is not accurate, remove most of the note.
2022-12-10 09:24:45 +01:00
Matthias Krüger
6d7e3dfc6f
Rollup merge of #105516 - weihanglo:update-cargo, r=weihanglo
Update cargo

2 commits in f6e737b1e3386adb89333bf06a01f68a91ac5306..70898e522116f6c23971e2a554b2dc85fd4c84cd 2022-12-02 20:21:24 +0000 to 2022-12-05 19:43:44 +0000

- Rename `generate_units` -> `generate_root_units` (rust-lang/cargo#11458)
- Implements cargo file locking using fcntl on Solaris. (rust-lang/cargo#11439)

r? `@ghost`
2022-12-10 09:24:45 +01:00
Matthias Krüger
cf840069f3
Rollup merge of #105514 - estebank:is_visible, r=oli-obk
Introduce `Span::is_visible`

r? `@oli-obk`
2022-12-10 09:24:44 +01:00
Matthias Krüger
9e87dd907e
Rollup merge of #105505 - WaffleLapkin:yeet_unused_parens_lint, r=fee1-dead
Don't warn about unused parens when they are used by yeet expr

Don't even get me started on how I've found this.
2022-12-10 09:24:44 +01:00
Matthias Krüger
947fe7e341
Rollup merge of #105109 - rcvalle:rust-kcfi, r=bjorn3
Add LLVM KCFI support to the Rust compiler

This PR adds LLVM Kernel Control Flow Integrity (KCFI) support to the Rust compiler. It initially provides forward-edge control flow protection for operating systems kernels for Rust-compiled code only by aggregating function pointers in groups identified by their return and parameter types. (See llvm/llvm-project@cff5bef.)

Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by identifying C char and integer type uses at the time types are encoded (see Type metadata in the design document in the tracking issue #89653).

LLVM KCFI can be enabled with -Zsanitizer=kcfi.

Thank you again, `@bjorn3,` `@eddyb,` `@nagisa,` and `@ojeda,` for all the help!
2022-12-10 09:24:43 +01:00
Matthias Krüger
020d7af949
Rollup merge of #105082 - Swatinem:async-abi, r=compiler-errors
Fix Async Generator ABI

This change was missed when making async generators implement `Future` directly.
It did not cause any problems in codegen so far, as `GeneratorState<(), Output>`
happens to have the same ABI as `Poll<Output>`.
2022-12-10 09:24:43 +01:00
Matthias Krüger
eb1159cbd8
Rollup merge of #104901 - krtab:filetype_compare, r=the8472
Implement masking in FileType comparison on Unix

Fixes: https://github.com/rust-lang/rust/issues/104900
2022-12-10 09:24:42 +01:00
Matthias Krüger
1ce18d2d65
Rollup merge of #104512 - jyn514:download-ci-llvm-default, r=Mark-Simulacrum
Set `download-ci-llvm = "if-available"` by default when `channel = dev`

See https://github.com/rust-lang/compiler-team/issues/566. The motivation for changing the default is to avoid downloading and building LLVM when someone runs `x build` before running `x setup`. The motivation for only doing it on `channel = "dev"` is to avoid breaking distros or users installing from source. It works because `dev` is also the default channel.

The diff looks larger than it is; most of it is moving the `llvm` branch below the `rust` so `config.channel` is set.

r? `@Mark-Simulacrum` cc `@oli-obk` `@bjorn3` `@cuviper`
2022-12-10 09:24:41 +01:00
Matthias Krüger
0f5d3ba30f
Rollup merge of #104019 - compiler-errors:print-generator-sizes, r=wesleywiser
Compute generator sizes with `-Zprint_type_sizes`

Fixes #103887
r? `@pnkfelix`
2022-12-10 09:24:41 +01:00
Matthias Krüger
ae8794ce6a
Rollup merge of #98391 - joboet:sgx_parker, r=m-ou-se
Reimplement std's thread parker on top of events on SGX

Mutex and Condvar are being replaced by more efficient implementations, which need thread parking themselves (see #93740). Therefore, the generic `Parker` needs to be replaced on all platforms where the new lock implementation will be used.

SGX enclaves have a per-thread event state, which allows waiting for and setting specific bits. This is already used by the current mutex implementation. The thread parker can however be much more efficient, as it only needs to store the `TCS` address of one thread. This address is stored in a state variable, which can also be set to indicate the thread was already notified.

`park_timeout` does not guard against spurious wakeups like the current condition variable does. This is allowed by the API of `Parker`, and I think it is better to let users handle these wakeups themselves as the guarding is quite expensive and might not be necessary.

`@jethrogb` as you wrote the initial SGX support for `std`, I assume you are the target maintainer? Could you help me test this, please? Lacking a x86_64 chip, I can't run SGX.
2022-12-10 09:24:40 +01:00
bors
cbc70ff277 Auto merge of #105357 - oli-obk:feeding, r=cjgillot,petrochenkov
Group some fields in a common struct so we only pass one reference instead of three

r? `@cjgillot`
2022-12-10 08:23:16 +00:00
est31
f069e7159f Correct wrong note for short circuiting operators
They *are* representable by traits, even if the short-circuiting
behaviour requires a different approach than the non-short-circuiting
operators. For an example proposal, see the postponed RFC 2722.
As it is not accurate, reword the note.
2022-12-10 08:11:19 +01:00
bors
a000811405 Auto merge of #105512 - matthiaskrgr:rollup-i74avrf, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #102406 (Make `missing_copy_implementations` more cautious)
 - #105265 (Add `rustc_on_unimplemented` to `Sum` and `Product` trait.)
 - #105385 (Skip test on s390x as LLD does not support the platform)
 - #105453 (Make `VecDeque::from_iter` O(1) from `vec(_deque)::IntoIter`)
 - #105468 (Mangle "main" as "__main_void" on wasm32-wasi)
 - #105480 (rustdoc: remove no-op mobile CSS `#sidebar-toggle { text-align }`)
 - #105489 (Fix typo in apple_base.rs)
 - #105504 (rustdoc: make stability badge CSS more consistent)
 - #105506 (Tweak `rustc_must_implement_one_of` diagnostic output)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-10 05:32:44 +00:00
Weihang Lo
ac90c9be6d
Update cargo
2 commits in f6e737b1e3386adb89333bf06a01f68a91ac5306..70898e522116f6c23971e2a554b2dc85fd4c84cd
2022-12-02 20:21:24 +0000 to 2022-12-05 19:43:44 +0000
- Rename `generate_units` -&gt; `generate_root_units` (rust-lang/cargo#11458)
- Implements cargo file locking using fcntl on Solaris. (rust-lang/cargo#11439)
2022-12-10 01:00:55 +00:00
Esteban Küber
b9da55afb5 Introduce Span::is_visible 2022-12-09 14:35:55 -08:00
Matthias Krüger
376b0bce36
Rollup merge of #105506 - estebank:rustc_must_implement_one_of, r=compiler-errors
Tweak `rustc_must_implement_one_of` diagnostic output
2022-12-09 22:31:59 +01:00
Matthias Krüger
d0563c64b8
Rollup merge of #105504 - notriddle:notriddle/stab-css, r=GuillaumeGomez
rustdoc: make stability badge CSS more consistent

# Before

![image](https://user-images.githubusercontent.com/1593513/206763667-8e0deb74-be63-4906-8229-9a7eb51725c2.png)

![image](https://user-images.githubusercontent.com/1593513/206764007-6301c0e8-4594-4a41-ba93-105824dffee6.png)

# After

![image](https://user-images.githubusercontent.com/1593513/206763698-e187cee2-3a50-4e48-b7b5-c3cfa41a797d.png)

![image](https://user-images.githubusercontent.com/1593513/206764058-3999ee67-1439-4c98-8216-b90575342aa8.png)

# Description

* They all get rounded corners now. A test case has been added for this, too.

* There are now broadly two kinds of stability badge, where there used to be three: item-info "fat badge", and the "thin badge" in both item tables and in docblocks (which got merged). The fat badges can have icons, while the thin badges can't.

* The old Ayu design doesn't make sense to me. Does anyone know why it was done that way?
2022-12-09 22:31:58 +01:00
Matthias Krüger
f78babd6c4
Rollup merge of #105489 - eltociear:patch-17, r=Dylan-DPC
Fix typo in apple_base.rs

erronous -> erroneous
2022-12-09 22:31:58 +01:00
Matthias Krüger
d4773866be
Rollup merge of #105480 - notriddle:notriddle/sidebar-toggle-mobile-center, r=GuillaumeGomez
rustdoc: remove no-op mobile CSS `#sidebar-toggle { text-align }`

Since 8b001b4da0 make the sidebar toggle a flex container, and already centers its content in desktop mode, this rule doesn't do anything.
2022-12-09 22:31:57 +01:00
Matthias Krüger
320d018268
Rollup merge of #105468 - sunfishcode:sunfishcode/main-void-wasi, r=estebank
Mangle "main" as "__main_void" on wasm32-wasi

On wasm, the age-old C trick of having a main function which can either have no arguments or argc+argv doesn't work, because wasm requires caller and callee signatures to match. WASI's current strategy is to have compilers mangle main's name to indicate which signature they're using. Rust uses the no-argument form, which should be mangled as `__main_void`.

This is needed on wasm32-wasi as of #105395.
2022-12-09 22:31:57 +01:00
Matthias Krüger
5156fbdc74
Rollup merge of #105453 - scottmcm:vecdeque_from_iter, r=the8472
Make `VecDeque::from_iter` O(1) from `vec(_deque)::IntoIter`

As suggested in https://github.com/rust-lang/rust/pull/105046#issuecomment-1330371695 by
r? ``@the8472``

`Vec` & `VecDeque`'s `IntoIter`s own the allocations, and even if advanced can be turned into `VecDeque`s in O(1).

This is just a specialization, not an API or doc commitment, so I don't think it needs an FCP.
2022-12-09 22:31:56 +01:00
Matthias Krüger
c44326e8b5
Rollup merge of #105385 - uweigand:s390x-test-lld, r=Mark-Simulacrum
Skip test on s390x as LLD does not support the platform

test/run-make/issue-71519 requires use of lld as linker, but lld does not currently support the s390x architecture.
2022-12-09 22:31:56 +01:00
Matthias Krüger
856027a73a
Rollup merge of #105265 - aDotInTheVoid:sum-product-on-unimplemented, r=estebank
Add `rustc_on_unimplemented` to `Sum` and `Product` trait.

Helps with #105184, but I don't think it fully fixes it.
2022-12-09 22:31:55 +01:00
Matthias Krüger
4fae5891d0
Rollup merge of #102406 - mejrs:missing_copy, r=wesleywiser
Make `missing_copy_implementations` more cautious

- Fixes https://github.com/rust-lang/rust/issues/98348
- Also makes the lint not fire on large types and types containing raw pointers. Thoughts?
2022-12-09 22:31:54 +01:00
bors
0d5573e6da Auto merge of #105363 - WaffleLapkin:thin2win_box_next_argument, r=nnethercote
Shrink `rustc_parse_format::Piece`

This makes both variants closer together in size (previously they were different by 208 bytes -- 16 vs 224). This may make things worse, but it's worth a try.

r? `@nnethercote`
2022-12-09 21:27:35 +00:00
bors
dfe3fe7101 Auto merge of #105499 - pietroalbini:pa-bump-version, r=pietroalbini
Bump version to 1.68

cc `@rust-lang/release`
2022-12-09 18:46:42 +00:00
Esteban Küber
b3b17bde31 Tweak rustc_must_implement_one_of diagnostic output 2022-12-09 10:44:11 -08:00
Maybe Waffle
84a46352ac Don't warn about unused parens when they are used by yeet expr 2022-12-09 18:32:06 +00:00
Michael Howell
d60967bef2 rustdoc: make stability badge CSS more consistent
* They all get rounded corners now. A test case has been added for this, too.

* There are now broadly two kinds of stability badge, where there used to be
  three: item-info "fat badge", and the "thin badge" in both item tables and
  in docblocks (which got merged). The fat badges can have icons, while the
  thin badges can't.
2022-12-09 10:54:44 -07:00
Pietro Albini
25e3093e1f
bump version to 1.68 2022-12-09 17:49:45 +01:00
bors
f058493307 Auto merge of #105262 - eduardosm:more-inline-always, r=thomcc
Make some trivial functions `#[inline(always)]`

This is some kind of follow-up of PRs like https://github.com/rust-lang/rust/pull/85218, https://github.com/rust-lang/rust/pull/84061, https://github.com/rust-lang/rust/pull/87150. Functions that do very basic operations are made `#[inline(always)]` to avoid pessimizing them in debug builds when compared to using built-in operations directly.
2022-12-09 15:42:18 +00:00
Oli Scherer
75ff5c7dd3 Fold Definitions into the untracked data 2022-12-09 14:59:39 +00:00
Oli Scherer
1c1d3570ee Move the untracked cstore and source_span into a struct 2022-12-09 14:53:24 +00:00
Oli Scherer
2cd36f2c89 Generate crate loaders on the fly 2022-12-09 14:53:23 +00:00
Oli Scherer
4b08fbaea8 ResolverTree does not require access to the crate loader, only the store 2022-12-09 14:50:09 +00:00
Arthur Carcano
24cd863a38 Replace hand-made masking by call to masked() method in FileType 2022-12-09 15:04:36 +01:00
bors
e10201c9bb Auto merge of #104572 - pkubaj:patch-1, r=cuviper
Fix build on powerpc-unknown-freebsd

Probably also fixes build on arm and mips*. Related to https://github.com/rust-lang/rust/issues/104220
2022-12-09 12:00:58 +00:00
bors
14ca83a04b Auto merge of #105486 - matthiaskrgr:rollup-o7c4l1c, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #105216 (Remove unused GUI test)
 - #105245 (attempt to clarify align_to docs)
 - #105387 (Improve Rustdoc scrape-examples UI)
 - #105389 (Enable profiler in dist-powerpc64le-linux)
 - #105427 (Dont silently ignore rustdoc errors)
 - #105442 (rustdoc: clean up docblock table CSS)
 - #105443 (Move some queries and methods)
 - #105455 (use the correct `Reveal` during validation)
 - #105470 (Clippy: backport ICE fix before beta branch)
 - #105474 (lib docs: fix typo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-09 09:19:26 +00:00
Ikko Ashimine
f41576bd3d
Fix typo in apple_base.rs
erronous -> erroneous
2022-12-09 18:09:32 +09:00
Matthias Krüger
3d727315c5
Rollup merge of #105474 - RalfJung:typo, r=dtolnay
lib docs: fix typo

r? `@thomcc`
2022-12-09 07:25:48 +01:00
Matthias Krüger
3e7aadc009
Rollup merge of #105470 - flip1995:clippy_backport, r=Manishearth
Clippy: backport ICE fix before beta branch

r? `@Manishearth`

Before beta is branched tomorrow we should backport the fix from https://github.com/rust-lang/rust-clippy/pull/10027 for an ICE. That way we'll get this into stable one release sooner.

This only cherry-picks the fix, not the tests for it. The proper sync of this will be done next week Thursday.
2022-12-09 07:25:47 +01:00
Matthias Krüger
04dac4285a
Rollup merge of #105455 - lcnr:correct-reveal-in-validate, r=jackh726
use the correct `Reveal` during validation

supersedes #105454. Deals with https://github.com/rust-lang/rust/issues/105009#issuecomment-1342395333, not closing #105009 as the ICE may leak into beta

The issue was the following:
- we optimize the mir, using `Reveal::All`
- some optimization relies on the hidden type of an opaque type
- we then validate using `Reveal::UserFacing` again which is not able to observe the hidden type

r? `@jackh726`
2022-12-09 07:25:47 +01:00
Matthias Krüger
6111a7345b
Rollup merge of #105443 - compiler-errors:move-more, r=oli-obk
Move some queries and methods

Each commit's title should be self-explanatory. Motivated to break up some large, general files and move queries into leaf crates.
2022-12-09 07:25:46 +01:00
Matthias Krüger
441669c382
Rollup merge of #105442 - notriddle:notriddle/docblock-table-css, r=GuillaumeGomez
rustdoc: clean up docblock table CSS

# Preview

http://notriddle.com/notriddle-rustdoc-demos/table-2/test_dingus/fn.test.html

# Before

![image](https://user-images.githubusercontent.com/1593513/206364287-1b80eaaf-2e0e-4138-8b56-4aa8ff39abac.png)

# After

![image](https://user-images.githubusercontent.com/1593513/206364209-d287d165-31be-4de1-9b43-05b35ce2a86b.png)

# Details

* The rule `display: block` had no noticeable effect. Technically, because markdown tables have a tbody and thead, they get wrapped in an [anonymous table box] in the CSS tree, nested within the `<table>` element's block layout box.

  This rule was added in #87230 to make the table side-scrolling, but this same issue was doubly fixed in #88742 by wrapping it in an explicit `<div>` tag. Since accessibility advocates recommend the wrapper div over marking the table as `display: block`, we'll stick with that.

  https://adrianroselli.com/2020/11/under-engineered-responsive-tables.html

* The rule `width: calc(100% - 2px)` had no visible effect, because the anonymous table box was not affected.

* The style is tweaked to basically be the same style GitHub uses. In particular, it adds zebra stripes, and removes dotted borders.

  https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Markdown.20table.20styling

[anonymous table box]: https://www.w3.org/TR/CSS2/tables.html#anonymous-boxes
2022-12-09 07:25:46 +01:00
Matthias Krüger
4b09861a68
Rollup merge of #105427 - GuillaumeGomez:dont-silently-ignore-rustdoc-errors, r=notriddle
Dont silently ignore rustdoc errors

I applied the suggestions from https://github.com/rust-lang/rust/pull/104995 and also checked the rustdoc-ui error but couldn't reproduce it.

r? `@notriddle`
2022-12-09 07:25:45 +01:00
Matthias Krüger
5b4723f154
Rollup merge of #105389 - ogarokpeter:patch-1, r=Mark-Simulacrum
Enable profiler in dist-powerpc64le-linux

Build the profiler runtime to allow using -C profile-generate and -C instrument-coverage on POWER little endian systems.

I have verified locally that the runtime builds and the profiler is working fine on the platform.

Similar pull request for a different system: https://github.com/rust-lang/rust/pull/104304
2022-12-09 07:25:45 +01:00
Matthias Krüger
5fd540b8fe
Rollup merge of #105387 - willcrichton:scrape-examples-ui-improvements, r=notriddle
Improve Rustdoc scrape-examples UI

This PR combines a few different improvements to the scrape-examples UI. See a live demo here: https://willcrichton.net/misc/scrape-examples/small-first-example/clap/struct.Arg.html

### 1. The first scraped example now takes up significantly less screen height.
Inserting the first scraped example takes up a lot of vertical screen space. I don't want this addition to overwhelm users, so I decided to reduce the height of the initial example in two ways: (A) the default un-expanded height is reduced from 240px (10 LOC) to 120px (5 LOC), and (B) the link to the example is now positioned *over* the example instead of *atop* the example (only on desktop though, not mobile). The changes to `scrape-examples.js` and `rustdoc.css` implement this fix.

Here is what an example docblock now looks like:

![Screen Shot 2022-12-06 at 10 02 21 AM](https://user-images.githubusercontent.com/663326/205987450-3940063c-5973-4a34-8579-baff6a43aa9b.png)

### 2. Expanding all docblocks will not expand "More examples".
The "More examples blocks" are huge, so fully expanding everything on the page would take up too much vertical space. The changes to `main.js` implement this fix. This is tested in `scrape-examples-toggle.goml`.

### 3. Examples from binary crates are sorted higher than examples from library crates.
Code that is written as an example of an API is probably better for learning than code that happens to use an API, but isn't intended for pedagogic purposes. Unfortunately Rustc doesn't know whether a particular crate comes from an example target (only Cargo knows this). But we can at least create a proxy that prefers examples from binary crates over library crates, which we know from `--crate-type`.

This change is implemented by adding a new field `bin_crate` in `Options` (see `config.rs`). An `is_bin` field has been added to the scraped examples metadata (see `scrape_examples.rs`). Then the example sorting metric uses `is_bin` as the first entry of a lexicographic sort on `(is_bin, example_size, display_name)` (see `render/mod.rs`).

Note that in the future we can consider adding another flag like `--scrape-examples-cargo-target` that would pass target information from Cargo into the example metadata. But I'm proposing a less intrusive change for now.

### 4. The scrape-examples help page has been updated to reflect the latest Cargo interface.

See `scrape-examples-help.md`.

r? `@notriddle`

P.S. once this PR and rust-lang/cargo#11450 are merged, then I think the scrape-examples feature is officially ready for deployment on docs.rs!
2022-12-09 07:25:44 +01:00