Commit Graph

2210 Commits

Author SHA1 Message Date
Nicholas Nethercote
5c462a32bd Remove support for compiler plugins.
They've been deprecated for four years.

This commit includes the following changes.
- It eliminates the `rustc_plugin_impl` crate.
- It changes the language used for lints in
  `compiler/rustc_driver_impl/src/lib.rs` and
  `compiler/rustc_lint/src/context.rs`. External lints are now called
  "loaded" lints, rather than "plugins" to avoid confusion with the old
  plugins. This only has a tiny effect on the output of `-W help`.
- E0457 and E0498 are no longer used.
- E0463 is narrowed, now only relating to unfound crates, not plugins.
- The `plugin` feature was moved from "active" to "removed".
- It removes the entire plugins chapter from the unstable book.
- It removes quite a few tests, mostly all of those in
  `tests/ui-fulldeps/plugin/`.

Closes #29597.
2023-11-04 08:50:46 +11:00
Philipp Krones
02562bfdf8
Update Cargo.lock 2023-11-02 17:50:52 +01:00
bors
62270fb4d6 Auto merge of #117204 - nnethercote:rustc_ast_passes, r=compiler-errors
Minor improvements to `rustc_ast_passes`

Some improvements I found while looking at this code.

r? `@compiler-errors`
2023-11-02 10:08:53 +00:00
Matthias Krüger
effc27dea4
Rollup merge of #117488 - GuillaumeGomez:update-minifier, r=notriddle
Update minifier-rs version to 0.3.0

It fixes https://github.com/GuillaumeGomez/minifier-rs/issues/105.

r? ```@notriddle```
2023-11-01 21:40:06 +01:00
Guillaume Gomez
d6666e2ccc Update minifier-rs version to 0.3.0 2023-11-01 15:18:41 +01:00
Michael Goulet
de83057ac4 Use derivative for Clone 2023-10-31 13:16:37 +00:00
Nicholas Nethercote
bb3e09f144 Streamline gate_feature_* macros.
The debug probably isn't useful, and assigning all the `$foo`
metavariables to `foo` variables is verbose and weird. Also, `$x:expr`
usually doesn't have a space after the `:`.
2023-10-31 08:00:53 +11:00
Nicholas Nethercote
28e60de487 Remove memoffset dependency from rustc_query_impl.
The comment explains it's for `unstable_offset_of`, but `offset_of` is
now stable.
2023-10-30 08:25:51 +11:00
Jubilee
48a3865218
Rollup merge of #117268 - nnethercote:rustc_interface, r=oli-obk
`rustc_interface` cleanups

Particularly in and around `--cfg` and `--check-cfg` handling.

r? `@oli-obk`
2023-10-28 01:07:38 -07:00
bors
6f349cdbfa Auto merge of #116471 - notriddle:notriddle/js-trait-alias, r=GuillaumeGomez
rustdoc: use JS to inline target type impl docs into alias

Preview docs:

- https://notriddle.com/rustdoc-html-demo-5/js-trait-alias/std/io/type.Result.html

- https://notriddle.com/rustdoc-html-demo-5/js-trait-alias-compiler/rustc_middle/ty/type.PolyTraitRef.html

This pull request also includes a bug fix for trait alias inlining across crates. This means more documentation is generated, and is why ripgrep runs slower (it's a thin wrapper on top of the `grep` crate, so 5% of its docs are now the Result type).

- Before, built with rustdoc 1.75.0-nightly (aa1a71e9e 2023-10-26), Result type alias method docs are missing: http://notriddle.com/rustdoc-html-demo-5/ripgrep-js-nightly/rg/type.Result.html
- After, built with this branch, all the methods on Result are shown: http://notriddle.com/rustdoc-html-demo-5/ripgrep-js-trait-alias/rg/type.Result.html

*Review note: This is mostly just reverting https://github.com/rust-lang/rust/pull/115201. The last commit has the new work in it.*

Fixes #115718

This is an attempt to balance three problems, each of which would
be violated by a simpler implementation:

- A type alias should show all the `impl` blocks for the target
  type, and vice versa, if they're applicable. If nothing was
  done, and rustdoc continues to match them up in HIR, this
  would not work.

- Copying the target type's docs into its aliases' HTML pages
  directly causes far too much redundant HTML text to be generated
  when a crate has large numbers of methods and large numbers
  of type aliases.

- Using JavaScript exclusively for type alias impl docs would
  be a functional regression, and could make some docs very hard
  to find for non-JS readers.

- Making sure that only applicable docs are show in the
  resulting page requires a type checkers. Do not reimplement
  the type checker in JavaScript.

So, to make it work, rustdoc stashes these type-alias-inlined docs
in a JSONP "database-lite". The file is generated in `write_shared.rs`,
included in a `<script>` tag added in `print_item.rs`, and `main.js`
takes care of patching the additional docs into the DOM.

The format of `trait.impl` and `type.impl` JS files are superficially
similar. Each line, except the JSONP wrapper itself, belongs to a crate,
and they are otherwise separate (rustdoc should be idempotent). The
"meat" of the file is HTML strings, so the frontend code is very simple.
Links are relative to the doc root, though, so the frontend needs to fix
that up, and inlined docs can reuse these files.

However, there are a few differences, caused by the sophisticated
features that type aliases have. Consider this crate graph:

```text
 ---------------------------------
 | crate A: struct Foo<T>        |
 |          type Bar = Foo<i32>  |
 |          impl X for Foo<i8>   |
 |          impl Y for Foo<i32>  |
 ---------------------------------
     |
 ----------------------------------
 | crate B: type Baz = A::Foo<i8> |
 |          type Xyy = A::Foo<i8> |
 |          impl Z for Xyy        |
 ----------------------------------
```

The type.impl/A/struct.Foo.js JS file has a structure kinda like this:

```js
JSONP({
"A": [["impl Y for Foo<i32>", "Y", "A::Bar"]],
"B": [["impl X for Foo<i8>", "X", "B::Baz", "B::Xyy"], ["impl Z for Xyy", "Z", "B::Baz"]],
});
```

When the type.impl file is loaded, only the current crate's docs are
actually used. The main reason to bundle them together is that there's
enough duplication in them for DEFLATE to remove the redundancy.

The contents of a crate are a list of impl blocks, themselves
represented as lists. The first item in the sublist is the HTML block,
the second item is the name of the trait (which goes in the sidebar),
and all others are the names of type aliases that successfully match.

This way:

- There's no need to generate these files for types that have no aliases
  in the current crate. If a dependent crate makes a type alias, it'll
  take care of generating its own docs.
- There's no need to reimplement parts of the type checker in
  JavaScript. The Rust backend does the checking, and includes its
  results in the file.
- Docs defined directly on the type alias are dropped directly in the
  HTML by `render_assoc_items`, and are accessible without JavaScript.
  The JSONP file will not list impl items that are known to be part
  of the main HTML file already.

[JSONP]: https://en.wikipedia.org/wiki/JSONP
2023-10-27 23:08:24 +00:00
Nicholas Nethercote
98c469ce93 Remove an unneeded dependency. 2023-10-28 09:03:51 +11:00
Matthias Krüger
df8852a934
Rollup merge of #116834 - nnethercote:rustc_symbol_mangling, r=davidtwco
Remove `rustc_symbol_mangling/messages.ftl`.

It contains a single message that (a) doesn't contain any natural language, and (b) is only used in tests.

r? `@davidtwco`
2023-10-27 19:46:06 +02:00
Matthias Krüger
f131a0a771
Rollup merge of #117010 - celinval:smir-internal, r=oli-obk
Add method to convert internal to stable constructs

This is an alternative implementation to https://github.com/rust-lang/rust/pull/116999. I believe we can still improve the logic a bit here, but I wanted to see which direction we should go first.

In this implementation, the API is simpler and we keep Tables somewhat private. The definition is still public though, since we have to expose the Stable trait. However, there's a cost of keeping another thread-local and using `Rc`, but I'm hoping it will be a small cost.

r? ``@oli-obk``
r? ``@spastorino``
2023-10-24 19:29:56 +02:00
Celina G. Val
66a554b045 Add method to convert internal to stable constructs 2023-10-23 12:01:39 -07:00
bors
1322f92634 Auto merge of #107009 - cjgillot:jump-threading, r=pnkfelix
Implement jump threading MIR opt

This pass is an attempt to generalize `ConstGoto` and `SeparateConstSwitch` passes into a more complete jump threading pass.

This pass is rather heavy, as it performs a truncated backwards DFS on MIR starting from each `SwitchInt` terminator. This backwards DFS remains very limited, as it only walks through `Goto` terminators.

It is build to support constants and discriminants, and a propagating through a very limited set of operations.

The pass successfully manages to disentangle the `Some(x?)` use case and the DFA use case. It still needs a few tests before being ready.
2023-10-23 18:05:44 +00:00
Oli Scherer
4a5fecb187 Avoid having rustc_smir depend on rustc_interface or rustc_driver 2023-10-23 09:48:15 +00:00
Matthias Krüger
dde77f7a33
Rollup merge of #117042 - Zalathar:file-table, r=cjgillot
coverage: Emit the filenames section before encoding per-function mappings

When embedding coverage information in LLVM IR (and ultimately in the resulting binary), there are two main things that each CGU needs to emit:

- A single `__llvm_covmap` record containing a coverage header, which mostly consists of a list of filenames used by the CGU's coverage mappings.
- Several `__llvm_covfun` records, one for each instrumented function, each of which contains the hash of the list of filenames in the header.

There is a kind of loose cyclic dependency between the two: we need the hash of the file table before we can emit the covfun records, but we need to traverse all of the instrumented functions in order to build the file table.

The existing code works by processing the individual functions first. It lazily adds filenames to the file table, and stores the mostly-complete function records in a temporary list. After this it hashes the file table, emits the header (containing the file table), and then uses the hash to emit all of the function records.

This PR reverses that order: first we traverse all of the functions (without trying to prepare their function records) to build a *complete* file table, and then emit it immediately. At this point we have the file table hash, so we can then proceed to build and emit all of the function records, without needing to store them in an intermediate list.

---

Along the way, this PR makes some necessary changes that are also worthwhile in their own right:
- We split `FunctionCoverage` into distinct collector/finished phases, which neatly avoids some borrow-checker hassles when extracting a function's final expression/mapping data.
- We avoid having to re-sort a function's mappings when preparing the list of filenames that it uses.
2023-10-23 08:12:39 +02:00
Caleb Cartwright
35400e8c16 bump rustfmt version 2023-10-22 20:34:12 -05:00
Michael Howell
fa10e4d667 rustdoc: use JS to inline target type impl docs into alias
This is an attempt to balance three problems, each of which would
be violated by a simpler implementation:

- A type alias should show all the `impl` blocks for the target
  type, and vice versa, if they're applicable. If nothing was
  done, and rustdoc continues to match them up in HIR, this
  would not work.

- Copying the target type's docs into its aliases' HTML pages
  directly causes far too much redundant HTML text to be generated
  when a crate has large numbers of methods and large numbers
  of type aliases.

- Using JavaScript exclusively for type alias impl docs would
  be a functional regression, and could make some docs very hard
  to find for non-JS readers.

- Making sure that only applicable docs are show in the
  resulting page requires a type checkers. Do not reimplement
  the type checker in JavaScript.

So, to make it work, rustdoc stashes these type-alias-inlined docs
in a JSONP "database-lite". The file is generated in `write_shared.rs`,
included in a `<script>` tag added in `print_item.rs`, and `main.js`
takes care of patching the additional docs into the DOM.

The format of `trait.impl` and `type.impl` JS files are superficially
similar. Each line, except the JSONP wrapper itself, belongs to a crate,
and they are otherwise separate (rustdoc should be idempotent). The
"meat" of the file is HTML strings, so the frontend code is very simple.
Links are relative to the doc root, though, so the frontend needs to fix
that up, and inlined docs can reuse these files.

However, there are a few differences, caused by the sophisticated
features that type aliases have. Consider this crate graph:

```text
 ---------------------------------
 | crate A: struct Foo<T>        |
 |          type Bar = Foo<i32>  |
 |          impl X for Foo<i8>   |
 |          impl Y for Foo<i32>  |
 ---------------------------------
     |
 ----------------------------------
 | crate B: type Baz = A::Foo<i8> |
 |          type Xyy = A::Foo<i8> |
 |          impl Z for Xyy        |
 ----------------------------------
```

The type.impl/A/struct.Foo.js JS file has a structure kinda like this:

```js
JSONP({
"A": [["impl Y for Foo<i32>", "Y", "A::Bar"]],
"B": [["impl X for Foo<i8>", "X", "B::Baz", "B::Xyy"], ["impl Z for Xyy", "Z", "B::Baz"]],
});
```

When the type.impl file is loaded, only the current crate's docs are
actually used. The main reason to bundle them together is that there's
enough duplication in them for DEFLATE to remove the redundancy.

The contents of a crate are a list of impl blocks, themselves
represented as lists. The first item in the sublist is the HTML block,
the second item is the name of the trait (which goes in the sidebar),
and all others are the names of type aliases that successfully match.

This way:

- There's no need to generate these files for types that have no aliases
  in the current crate. If a dependent crate makes a type alias, it'll
  take care of generating its own docs.
- There's no need to reimplement parts of the type checker in
  JavaScript. The Rust backend does the checking, and includes its
  results in the file.
- Docs defined directly on the type alias are dropped directly in the
  HTML by `render_assoc_items`, and are accessible without JavaScript.
  The JSONP file will not list impl items that are known to be part
  of the main HTML file already.

[JSONP]: https://en.wikipedia.org/wiki/JSONP
2023-10-22 15:56:14 -07:00
Zalathar
e985ae5a45 coverage: Build the global file table ahead of time 2023-10-22 20:37:37 +11:00
bors
cc3dce5bd0 Auto merge of #116956 - Amanieu:hashbrown-0.14.2, r=Mark-Simulacrum
Update hashbrown to 0.14.2

Fixes #116880
2023-10-22 03:55:24 +00:00
Matthias Krüger
d6ac149b4f
Rollup merge of #116312 - c410-f3r:try, r=Mark-Simulacrum
Initiate the inner usage of `cfg_match` (Compiler)

cc #115585

Dogfood to test the implementation and remove dependencies.
2023-10-21 21:22:59 +02:00
Philipp Krones
b8b55fe316
Update Cargo.lock (ui_test update) 2023-10-21 14:16:27 +02:00
Camille GILLOT
751a079413 Implement JumpThreading pass. 2023-10-21 06:58:38 +00:00
Ralf Jung
49e8acbfe9 update lockfile 2023-10-21 08:41:45 +02:00
bors
c7f3948028 Auto merge of #116946 - compiler-errors:movability-and-mutability, r=lcnr
Uplift movability and mutability, the simple way

Just make type_ir a dependency of ast. This can be relaxed later if we want to make the dependency less heavy. Part of rust-lang/types-team#124.

r? `@lcnr` or `@jackh726`
2023-10-20 08:19:54 +00:00
Ralf Jung
20fe485c57 Merge from rustc 2023-10-20 08:03:38 +02:00
bors
5cee4f305a Auto merge of #116875 - nnethercote:rustc_monomorphize, r=wesleywiser
`rustc_monomorphize` cleanups

Just some small improvements I found while looking over this code.

r? `@wesleywiser`
2023-10-20 00:03:47 +00:00
Caio
6379013876 Initiate the inner usage of cfg_match 2023-10-19 20:18:51 -03:00
Amanieu d'Antras
eeea74785d Update hashbrown to 0.14.2
Fixes #116880
2023-10-19 21:44:23 +01:00
bors
94c4e5c411 Auto merge of #115214 - Urgau:rfc-3127-trim-paths, r=compiler-errors
Implement rustc part of RFC 3127 trim-paths

This PR implements (or at least tries to) [RFC 3127 trim-paths](https://github.com/rust-lang/rust/issues/111540), the rustc part. That is `-Zremap-path-scope` with all of it's components/scopes.

`@rustbot` label: +F-trim-paths
2023-10-19 19:09:29 +00:00
Michael Goulet
e8e9f6a32a Uplift movability and mutability, the simple way 2023-10-19 16:42:58 +00:00
Ralf Jung
d5d8a515ce Merge from rustc 2023-10-19 17:57:38 +02:00
Michael Goulet
60c95448c3 Use v0.0.0 in compiler crates 2023-10-18 21:55:15 +00:00
Nicholas Nethercote
025eb20a86 Remove unneeded dependencies from rustc_monomorphize. 2023-10-18 14:23:51 +11: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
Urgau
30f94717ca [RFC 3127 - Trim Paths]: Add unstable option and parsing 2023-10-17 10:11:30 +02:00
Nicholas Nethercote
f4a9d29c50 Remove rustc_symbol_mangling/messages.ftl.
It contains a single message that (a) doesn't contain any natural
language, and (b) is only used in tests.
2023-10-17 16:15:36 +11: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
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
Camille GILLOT
02424e4bc5 Normalize alloc-id in tests. 2023-10-16 16:29:35 +00:00
klensy
83425967cb opt-dist: disable unused features for tabled crate 2023-10-16 12:59:15 +03:00
bors
d60d63fbf7 Auto merge of #116527 - sthibaul:libc, r=Mark-Simulacrum
Bump libc dependency

To get GNU/Hurd support, so that CI of external repositories (e.g. getrandom) can build std.
2023-10-15 15:17:17 +00:00
bors
ab73de7d7f Auto merge of #116691 - chenx97:rustix-0.38.19, r=Mark-Simulacrum
Update rustix to 0.38.19

addresses [rustix/#856](https://github.com/bytecodealliance/rustix/pull/856).

Commands that do the update:

`cargo +nightly update rustix`

r? `@Mark-Simulacrum`
2023-10-15 09:36:49 +00:00
Guillaume Gomez
87ae477af0 Update minifier version to 0.2.3 2023-10-14 00:17:27 +02:00
Peter Jaszkowiak
49aa5a23ca Revert "Invoke backtrace-rs buildscript in std buildscript"
This reverts commit 93677276bc
because it caused issues for projects building the standard
library with non-cargo build systems.
2023-10-13 13:43:00 -06:00
chenx97
b1d64c6c30 Update rustix to 0.38.19 2023-10-13 18:14:07 +08:00
bors
130ff8cb6c Auto merge of #115964 - bjorn3:cgu_reuse_tracker_global_state, r=cjgillot
Remove cgu_reuse_tracker from Session

This removes a bit of global mutable state.

It will now miss post-lto cgu reuse when ThinLTO determines that a cgu doesn't get changed, but there weren't any tests for this anyway and a test for it would be fragile to the exact implementation of ThinLTO in LLVM.
2023-10-13 00:09:30 +00:00
bors
5aa23be6b6 Auto merge of #116014 - lqd:mcp510-2-electric-boogaloo, r=petrochenkov
Implement `-Clink-self-contained=-linker` opt out

This implements the `-Clink-self-contained` opt out necessary to switch to lld by changing rustc's defaults instead of cargo's.

Components that are enabled and disabled on the CLI are recorded, for the purpose of being merged with the ones which the target spec will declare (I'll open another PR for that tomorrow, for easier review).

For MCP510, we now check whether using the self-contained linker is disabled on the CLI. Right now it would only be sensible to with `-Zgcc-ld=lld` (and I'll add some checks that we don't both enable and disable a component on the CLI in a future PR), but the goal is to simplify adding the check of the target's enabled components here in the follow-up PRs.

r? `@petrochenkov`
2023-10-11 12:11:39 +00:00
bjorn3
e9fa2ca6ad Remove cgu_reuse_tracker from Session
This removes a bit of global mutable state
2023-10-09 18:39:41 +00:00