Commit Graph

212411 Commits

Author SHA1 Message Date
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
Jakob Degen
9fb8da8f8f Remove unneeded field from SwitchTargets 2022-12-09 04:53:10 -08: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
Matthias Krüger
0b4d57be53
Rollup merge of #105245 - RalfJung:align_to, r=Amanieu
attempt to clarify align_to docs

This is not intended the change the docs at all, but `@workingjubilee` said the current docs are incomprehensible to some people so this is an attempt to fix that. No idea if it helps, so -- feedback welcome.

(Please let's not use this to discuss *changing* the spec. Whoever wants to change the spec should please make a separate PR for that.)
2022-12-09 07:25:44 +01:00
Matthias Krüger
2b988588ce
Rollup merge of #105216 - GuillaumeGomez:rm-unused-gui-test, r=notriddle
Remove unused GUI test

It's not testing anything so better just remove it.

r? `@notriddle`
2022-12-09 07:25:43 +01:00
bors
badd6a5a03 Auto merge of #104449 - oli-obk:unhide_unknown_spans, r=estebank,RalfJung
Start emitting labels even if their pointed to file is not available locally

r? `@estebank`

cc `@RalfJung`

fixes #97699
2022-12-09 06:24:28 +00:00
Scott McMurray
6648134434 Apply review feedback; Fix no_global_oom_handling build 2022-12-08 22:08:55 -08:00
bors
7701a7e7d4 Auto merge of #105456 - matthiaskrgr:rollup-yennygf, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #104922 (Detect long types in E0308 and write them to disk)
 - #105120 (kmc-solid: `std::sys` code maintenance)
 - #105255 (Make nested RPIT inherit the parent opaque's generics.)
 - #105317 (make retagging work even with 'unstable' places)
 - #105405 (Stop passing -export-dynamic to wasm-ld.)
 - #105408 (Add help for `#![feature(impl_trait_in_fn_trait_return)]`)
 - #105423 (Use `Symbol` for the crate name instead of `String`/`str`)
 - #105433 (CI: add missing line continuation marker)
 - #105434 (Fix warning when libcore is compiled with no_fp_fmt_parse)
 - #105441 (Remove `UnsafetyState`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-09 03:05:27 +00:00
Wesley Wiser
7253057887 Don't generate pointer loads to spills unless necessary
In order for LLVM to correctly generate debuginfo for msvc, we sometimes
need to spill arguments to the stack and perform some direct & indirect
offsets into the value. Previously, this code always performed those
actions, even when not required as LLVM would clean it up during
optimization.

However, when MIR inlining is enabled, this can cause problems as the
operations occur prior to the spilled value being initialized. To solve
this, we first calculate the necessary offsets using just the type which
is side-effect free and does not alter the LLVM IR. Then, if we are in a
situation which requires us to generate the LLVM IR (and this situation
only occurs for arguments, not local variables) then we perform the same
calculation again, this time generating the appropriate LLVM IR as we
go.
2022-12-08 20:38:23 -05:00
Wesley Wiser
b33d1e26b2 Make debuginfo_offset_calcuation generic so we can resuse the logic
This will allow us to separate the act of calculating the offsets from
creating LLVM IR that performs the actions.
2022-12-08 20:38:23 -05:00
Wesley Wiser
525d0dd6e2 Factor out debuginfo offset calculation 2022-12-08 20:38:23 -05:00
Wesley Wiser
34246f89e2 Add test case for ub in generated LLVM IR 2022-12-08 20:38:18 -05:00
Ramon de C Valle
e1741baeed Add documentation for LLVM KCFI support
This commit adds initial documentation for LLVM Kernel Control Flow
Integrity (KCFI) support to the Rust compiler (see #105109 and #89653).

Co-authored-by: Miguel Ojeda <ojeda@users.noreply.github.com>
2022-12-08 17:24:43 -08:00
Ramon de C Valle
65698ae9f3 Add LLVM KCFI support to the Rust compiler
This commit 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.

Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2022-12-08 17:24:39 -08:00
pkubaj
32c777e891 Fix build on powerpc-unknown-freebsd
Probably also fixes build on mips*. Related to https://github.com/rust-lang/rust/issues/104220
2022-12-09 02:11:15 +01:00
Michael Howell
90da11d9af 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-08 17:38:07 -07:00
bors
b359ccf1b0 Auto merge of #105477 - tmiasko:make, r=ehuss
Ignore errors when including clear_expected_if_blessed

Include is there only for the effect executing the rule. The file is not intended to be remade successfully to be actually included.

I erroneously changed this in #100912.
2022-12-08 23:50:39 +00:00
Esteban Küber
132a140214 Point at LHS on binop type err if relevant 2022-12-08 15:30:57 -08:00
Nixon Enraght-Moony
5626df9c90 Add rustc_on_unimplemented to Sum and Product trait. 2022-12-08 23:07:54 +00:00
Tomasz Miąsko
c1d5a5a246 Ignore errors when including clear_expected_if_blessed
Include is there only for the effect executing the rule.
The file is not intended to be remade successfully to be
actually included.
2022-12-09 00:00:52 +01:00
Maybe Waffle
c44c82de2b Assert size of rustc_parse_format::Piece<'_> 2022-12-08 22:50:39 +00:00
Arpad Borsos
ecf812777a
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-08 23:27:57 +01:00
Ralf Jung
a25791ee61 lib docs: fix typo 2022-12-08 22:36:57 +01:00
Dan Gohman
98ae83daae 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-08 13:15:40 -08:00
Samuel Moelius
3c29e742d1
Fix #10021 2022-12-08 20:09:08 +01:00
Michael Howell
34700f6594 rustdoc: add GUI test case for docblock table colors 2022-12-08 10:37:03 -07:00
Santiago Pastorino
99d229095e
Make encode_info_for_trait_item use queries instead of accessing the HIR 2022-12-08 11:58:14 -03:00
Martin Kröning
6324e5cb6a Bump compiler-builtins to 0.1.85 2022-12-08 15:34:46 +01:00
Joshua Nelson
11798660ac Build rust-analyzer proc-macro server by default
This allows getting rid of some documentation and an extra step when building a custom toolchain: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html#creating-a-rustup-toolchain
and it seems likely that people will want to do this if they want rustdoc (which is also built by default).
2022-12-08 07:59:05 -06:00
Guillaume Gomez
b5a9f6a537 Update rustdoc test to check its error output 2022-12-08 14:08:58 +01:00
Guillaume Gomez
183a77093b Add regression test for #105404 2022-12-08 13:46:51 +01:00
Guillaume Gomez
680648625e Prevent to try to retrieve auto and blanket implementations if there were errors before this pass 2022-12-08 13:41:59 +01:00
Matthias Krüger
660795eee5
Rollup merge of #105441 - nnethercote:rm-UnsafetyState, r=lcnr
Remove `UnsafetyState`

r? `@lcnr`
2022-12-08 12:57:33 +01:00
Matthias Krüger
433189b742
Rollup merge of #105434 - nbdd0121:lib, r=thomcc
Fix warning when libcore is compiled with no_fp_fmt_parse

Discovered when trying to compile Rust-for-Linux with Rust 1.66 beta.

It'll be helpful if this is backported to beta (should be trivial enough for backporting), so Rust-for-Linux's rust version bump wouldn't need to do `--cap-lints allow` for libcore.
2022-12-08 12:57:33 +01:00
Matthias Krüger
d429e463c1
Rollup merge of #105433 - ComputerDruid:docker_continuation_fix, r=jyn514
CI: add missing line continuation marker

Resolves this docker warning:

```
[WARNING]: Empty continuation line found in:
    RUN apt-get update && apt-get install -y --no-install-recommends   g++   gcc-multilib   make   ninja-build   file   curl   ca-certificates   python2.7   python3.9   git   cmake   sudo   gdb   llvm-13-tools   llvm-13-dev   libedit-dev   libssl-dev   pkg-config   zlib1g-dev   xz-utils   nodejs     apt-transport-https software-properties-common &&     curl -s "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb" > packages-microsoft-prod.deb &&     dpkg -i packages-microsoft-prod.deb &&     apt-get update &&     apt-get install -y powershell     && rm -rf /var/lib/apt/lists/*
Warning: : Empty continuation lines will become errors in a future release.
```
2022-12-08 12:57:32 +01:00
Matthias Krüger
fbfc5ada02
Rollup merge of #105423 - oli-obk:symbols, r=jackh726
Use `Symbol` for the crate name instead of `String`/`str`

It always got converted to a symbol anyway
2022-12-08 12:57:32 +01:00
Matthias Krüger
2fbde2b028
Rollup merge of #105408 - cuviper:help-rpitirpit, r=compiler-errors
Add help for `#![feature(impl_trait_in_fn_trait_return)]`

This adds a new variant `ImplTraitContext::FeatureGated`, so we can
generalize the help for `return_position_impl_trait_in_trait` to also
work for `impl_trait_in_fn_trait_return`.

cc #99697
2022-12-08 12:57:31 +01:00
Matthias Krüger
4d5a2f3d81
Rollup merge of #105405 - sunfishcode:sunfishcode/export-dynamic, r=TaKO8Ki
Stop passing -export-dynamic to wasm-ld.

-export-dynamic was a temporary hack added in the early days of the Rust wasm32 target when Rust didn't have a way to specify wasm exports in the source code. This flag causes all global symbols, and some compiler-internal symbols, to be exported, which is often more than needed.

Rust now does have a way to specify exports in the source code: `#[export_name = "..."]`.

So as the original comment suggests, -export-dynamic can now be removed, allowing users to have smaller binaries and better encapsulation in their wasm32-unknown-unknown modules.

It's possible that this change will require existing wasm32-unknown-unknown users will to add explicit `#[export_name = "..."]` directives to exporrt the symbols that their programs depend on having exported.
2022-12-08 12:57:30 +01:00