Commit Graph

682 Commits

Author SHA1 Message Date
David Wood
6f0b8f1a4b attr/passes: comment -> doc comment
Change some regular comments into documentation comments.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-20 11:29:56 +01:00
bors
9a7b7d5e50 Auto merge of #98180 - notriddle:notriddle/rustdoc-fn, r=petrochenkov,GuillaumeGomez
Improve the function pointer docs

This is #97842 but for function pointers instead of tuples. The concept is basically the same.

* Reduce duplicate impls; show `fn (T₁, T₂, …, Tₙ)` and include a sentence saying that there exists up to twelve of them.
* Show `Copy` and `Clone`.
* Show auto traits like `Send` and `Sync`, and blanket impls like `Any`.

https://notriddle.com/notriddle-rustdoc-test/std/primitive.fn.html
2022-07-19 19:36:57 +00:00
Matthias Krüger
4815f94c51
Rollup merge of #99401 - TaKO8Ki:avoid-symbol-to-&str-conversions, r=nnethercote
Avoid `Symbol` to `&str` conversions

`Symbol::as_str` is a slowish operation, so this patch removes some usages of it.
2022-07-19 13:30:46 +02:00
Takayuki Maeda
a22934bea1 avoid Symbol to &str conversions 2022-07-18 14:25:34 +09:00
Michael Howell
1169832f2f rustdoc: extend #[doc(tuple_variadic)] to fn pointers
The attribute is also renamed `fake_variadic`.
2022-07-17 16:32:06 -07:00
Caio
3266460749 Stabilize let_chains 2022-07-16 20:17:58 -03:00
David Wood
78b19a90b7 passes: migrate half of check_attr
Migrate half of the `rustc_passes::check_attr` diagnostics to using
diagnostic derives and being translatable.
2022-07-15 16:13:49 +01:00
bors
24699bcbad Auto merge of #95956 - yaahc:stable-in-unstable, r=cjgillot
Support unstable moves via stable in unstable items

part of https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/moving.20items.20to.20core.20unstably and a blocker of https://github.com/rust-lang/rust/pull/90328.

The libs-api team needs the ability to move an already stable item to a new location unstably, in this case for Error in core. Otherwise these changes are insta-stable making them much harder to merge.

This PR attempts to solve the problem by checking the stability of path segments as well as the last item in the path itself, which is currently the only thing checked.
2022-07-14 13:42:09 +00:00
bors
f1a8854f9b Auto merge of #99231 - Dylan-DPC:rollup-0tl8c0o, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #97720 (Always create elided lifetime parameters for functions)
 - #98315 (Stabilize `core::ffi:c_*` and rexport in `std::ffi`)
 - #98705 (Implement `for<>` lifetime binder for closures)
 - #99126 (remove allow(rustc::potential_query_instability) in rustc_span)
 - #99139 (Give a better error when `x dist` fails for an optional tool)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-14 11:00:30 +00:00
Dylan DPC
e5a86d7358
Rollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillot
Implement `for<>` lifetime binder for closures

This PR implements RFC 3216 ([TI](https://github.com/rust-lang/rust/issues/97362)) and allows code like the following:

```rust
let _f = for<'a, 'b> |a: &'a A, b: &'b B| -> &'b C { b.c(a) };
//       ^^^^^^^^^^^--- new!
```

cc ``@Aaron1011`` ``@cjgillot``
2022-07-14 14:14:21 +05:30
bors
0ed9c64c3e Auto merge of #98975 - jyn514:unstable_opts, r=wesleywiser
Rename `debugging_opts` to `unstable_opts`

This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`).
Rename it to be more clear.

cc https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Codegen.20options.20.2F.20debugging.20options

r? `@Amanieu` cc `@nikic` `@joshtriplett`
2022-07-14 08:14:31 +00:00
Joshua Nelson
3c9765cff1 Rename debugging_opts to unstable_opts
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`).
Rename it to be more clear.
2022-07-13 17:47:06 -05:00
Ralf Jung
5bf6017b87 remove untagged_union feature gate 2022-07-13 18:27:28 -04:00
Ralf Jung
6dfede3b9d also allow arrays of allowed types 2022-07-13 18:27:28 -04:00
Ralf Jung
ec7152cdf6 allow unions with mutable references and tuples of allowed types 2022-07-13 18:27:28 -04:00
Ralf Jung
848d23b57b factor 'is this type allowed as union field on stable' into separate function 2022-07-13 18:27:28 -04:00
Dylan DPC
1e7d04b23b
Rollup merge of #99011 - oli-obk:UnsoundCell, r=eddyb
`UnsafeCell` blocks niches inside its nested type from being available outside

fixes #87341

This implements the plan by `@eddyb` in https://github.com/rust-lang/rust/issues/87341#issuecomment-886083646

Somewhat related PR (not strictly necessary, but that cleanup made this PR simpler): #94527
2022-07-13 19:32:34 +05:30
Maybe Waffle
df4fee9841 Add an indirection for closures in hir::ExprKind
This helps bring `hir::Expr` size down, `Closure` was the biggest
variant, especially after `for<>` additions.
2022-07-12 21:00:13 +04:00
Ding Xiang Fei
1cd30e7b32
move else block into the Local struct 2022-07-11 23:20:37 +02:00
Ding Xiang Fei
6c529ded86
lower let-else in MIR instead 2022-07-11 23:20:36 +02:00
Jane Losare-Lusby
e4e6b1ebc6 fixes post rebase 2022-07-08 21:18:16 +00:00
Jane Lusby
b55453dbad add opt in attribute for stable-in-unstable items 2022-07-08 21:18:15 +00:00
Jane Lusby
a13f30036a clarify comment 2022-07-08 21:18:15 +00:00
Jane Lusby
67fe8423a3 update comment 2022-07-08 21:18:15 +00:00
Jane Lusby
e7fe5456c5 Support unstable moves via stable in unstable items 2022-07-08 21:18:13 +00:00
Camille GILLOT
111df9e6ed Reword comments and rename HIR visiting methods. 2022-07-07 16:01:43 +02:00
Oli Scherer
2a899dc1cf UnsafeCell now has no niches, ever. 2022-07-07 10:46:22 +00:00
bors
c461f7a16e Auto merge of #98841 - Kobzol:hir-validator-bitset, r=cjgillot
Use a bitset instead of a hash map in HIR ID validator

The hashset insertion was slightly hot in incr patched runs, but it seems unnecessary to use a hashset here, as it just checks that a dense set of N integers was seen.

I'm not sure if it's possible to know the amount of items beforehand to preallocate the bitset? I suppose not.
2022-07-07 07:38:08 +00:00
Dylan DPC
291df97fae
Rollup merge of #98624 - davidtwco:translation-on-lints, r=compiler-errors
lints: mostly translatable diagnostics

As lints are created slightly differently than other diagnostics, intended to try make them translatable first and then look into the applicability of diagnostic structs but ended up just making most of the diagnostics in the crate translatable (which will still be useful if I do make a lot of them structs later anyway).

r? ``@compiler-errors``
2022-07-05 16:04:32 +05:30
Jakub Beránek
928c17203a
Only validate HIR with debug_assertions on 2022-07-04 11:38:11 +02:00
Jakub Beránek
2a57e5efed
Use a bitset instead of a hash map in HIR ID validator 2022-07-04 08:30:13 +02:00
Matthias Krüger
7352c7b6cd
Rollup merge of #98501 - Enselic:err_if_attr_found, r=compiler-errors
rustc_passes/src/entry.rs: De-duplicate more code with `fn throw_attr_err()`

So we can more easily re-use the code for other attributes later. More specifically [`#[unix_sigpipe]`](https://github.com/rust-lang/rust/pull/97802). This refactoring is covered by this test:
8aab472d52/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs (L120)
(Well, only `#[start]`, but the code for `#[rustc_main]` is identical.)
2022-07-04 06:08:07 +02:00
bors
5b9775fe17 Auto merge of #98402 - cjgillot:undead, r=michaelwoerister
Rewrite dead-code pass to avoid fetching HIR.

This allows to get a more uniform handling of spans, and to simplify the grouping of diagnostics for variants and fields.
2022-07-01 14:43:15 +00:00
David Wood
7d2eba6311 middle: translation in LintDiagnosticBuilder
Accept `DiagnosticMessage` in `LintDiagnosticBuilder::build` so that
lints can be built with translatable diagnostic messages.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30 08:58:41 +01:00
Takayuki Maeda
6212e6b339 avoid many &str to String conversions with MultiSpan::push_span_label 2022-06-29 21:16:43 +09:00
Martin Nordholts
4731d4b6d3 rustc_passes: De-duplicate more code with fn throw_attr_err()
So we can re-use the code for other attributes later.
2022-06-25 21:43:33 +02:00
Yuki Okushi
f3078d0f44
Rollup merge of #98394 - Enselic:fixup-rustc_main-renames, r=petrochenkov
Fixup missing renames from `#[main]` to `#[rustc_main]`

In #84217 `#[main]` was removed and replaced with `#[rustc_main]`. In some places the rename was forgotten, which makes the current code confusing, because at first glance it seems that `#[main]` is still around. Perform the renames also in these places.

I noticed this (after first being confused by it) when working on #97802.

r? `@petrochenkov`

(since you reviewed the other PR)
2022-06-24 16:43:47 +09:00
Yuki Okushi
33eb3c05c5
Rollup merge of #98214 - petrochenkov:islike, r=compiler-errors
rustc_target: Remove some redundant target properties

`is_like_emscripten` is equivalent to `os == "emscripten"`, so it's removed.
`is_like_fuchsia` is equivalent to `os == "fuchsia"`, so it's removed.
`is_like_osx` also falls into the same category and is equivalent to `vendor == "apple"`, but it's commonly used so I kept it as is for now.

`is_like_(solaris,windows,wasm)` are combinations of different operating systems or architectures (see compiler/rustc_target/src/spec/tests/tests_impl.rs) so they are also kept as is.

I think `is_like_wasm` (and maybe `is_like_osx`) are sufficiently closed sets, so we can remove these fields as well and replace them with methods like `fn is_like_wasm() { arch == "wasm32" || arch == "wasm64" }`.
On other hand, `is_like_solaris` and `is_like_windows` are sufficiently open and I can imagine custom targets introducing other values for `os`.
This is kind of a gray area.
2022-06-24 16:43:45 +09:00
Camille GILLOT
02a42ff83d Rewrite dead-code pass to avoid fetching HIR. 2022-06-22 20:48:18 +02:00
Camille GILLOT
a319f3c992 Uniform spans in dead code lint. 2022-06-22 20:40:42 +02:00
Camille GILLOT
0b2837dc07 Simplify match. 2022-06-22 19:16:17 +02:00
Camille GILLOT
8276dac081 Mark inherent impls as using the type during liveness collection. 2022-06-22 19:16:15 +02:00
Martin Nordholts
94477e3323 Fixup missing renames from #[main] to #[rustc_main]
In fc357039f9 `#[main]` was removed and replaced with `#[rustc_main]`.
In some place the rename was forgotten, which makes the current code
confusing, because at first glance it seems that `#[main]` is still
around. Perform the renames also in these places.
2022-06-22 18:24:09 +02:00
bors
3d829a0922 Auto merge of #97853 - TaKO8Ki:emit-only-one-note-per-unused-struct-field, r=estebank
Collapse multiple dead code warnings into a single diagnostic

closes #97643
2022-06-22 02:51:55 +00:00
León Orell Valerian Liehr
67508f3714 Remove #[doc(hidden)] logic from unused_attributes lint 2022-06-21 14:06:32 +02:00
Takayuki Maeda
3a023e7e58 collapse dead code warnings into a single diagnostic
add comments in `store_dead_field_or_variant`

support multiple log level

add a item ident label

fix ui tests

fix a ui test

fix a rustdoc ui test

use let chain

refactor: remove `store_dead_field_or_variant`

fix a tiny bug
2022-06-19 18:32:56 +09:00
Takayuki Maeda
da27551f3a emit only one note per unused struct field 2022-06-19 18:32:56 +09:00
bors
cdcc53b7dc Auto merge of #98153 - nnethercote:fix-MissingDoc-quadratic-behaviour, r=cjgillot
Fix `MissingDoc` quadratic behaviour

Best reviewed one commit at a time.

r? `@cjgillot`
2022-06-18 09:57:00 +00:00
Vadim Petrochenkov
37fd2941a1 rustc_target: Remove some redundant target properties 2022-06-18 01:09:20 +03:00
Yuki Okushi
71d7f414a6
Remove a possible unnecessary assignment
The reference issue has been closed (the feature has been stabilized)
and things work fine without fine, it seems.

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-06-18 01:51:38 +09:00