Commit Graph

162277 Commits

Author SHA1 Message Date
Fabian Wolff
0363f11ff0 Add match on Vec<_> to ui/typeck/issue-91328.rs test 2022-01-31 19:04:22 +01:00
Fabian Wolff
c15ef58f4f Fix suggestion to slice if scrutinee is a Result or Option 2022-01-31 19:04:22 +01:00
bors
498eeb72f5 Auto merge of #93348 - spastorino:fix-perf-overlap-mode2, r=nikomatsakis
Move overlap_mode into trait level attribute

r? `@nikomatsakis`

Should fix some performance regressions noted on https://github.com/rust-lang/rust/pull/93175
2022-01-31 17:36:11 +00:00
5225225
ec3b711a4b Write UI tests, tweak message 2022-01-31 17:34:10 +00:00
bjorn3
0b8f3729fb Remove two unnecessary transmutes from opaque Encoder and Decoder 2022-01-31 18:25:05 +01:00
Santiago Pastorino
0decf14ef1
Do not store overlap_mode, just pass it down on insert 2022-01-31 11:51:34 -03:00
Santiago Pastorino
a9bfb5d837
Move overlap_mode into trait level attribute + feature flag 2022-01-31 11:50:43 -03:00
bors
24b8bb13bf Auto merge of #93373 - spastorino:def_id_to_hir_id_refactor, r=oli-obk
Store def_id_to_hir_id as variant in hir_owner.

If hir_owner is Owner(_), the LocalDefId is pointing to an owner, so the ItemLocalId is 0.
If the HIR node does not exist, we store Phantom.
Otherwise, we store the HirId associated to the LocalDefId.

Related to #89278

r? `@oli-obk`
2022-01-31 14:23:44 +00:00
bors
86f5e177bc Auto merge of #93498 - matthiaskrgr:rollup-k5shwrc, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #90277 (Improve terminology around "after typeck")
 - #92918 (Allow eliding GATs in expression position)
 - #93039 (Don't suggest inaccessible fields)
 - #93155 (Switch pretty printer to block-based indentation)
 - #93214 (Respect doc(hidden) when suggesting available fields)
 - #93347 (Make `char::DecodeUtf16::size_hist` more precise)
 - #93392 (Clarify documentation on char::MAX)
 - #93444 (Fix some CSS warnings and errors from VS Code)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-31 11:24:03 +00:00
Jacob Hoffman-Andrews
c790128c3c Improve wrapping on settings page
Previously, the radio button choices for themes would wrap awkwardly on
narrow screens. With this change, the group of choices will prefer
bumping down to the next line together, leaving the setting name on its
own line.

Also fix some minor spacing issues:

 - Align the setting name vertically with the radio button choices.
 - Use margin instead of padding for most spacing choices.
 - Use no margin/padding on the right-hand side.
2022-01-31 01:46:10 -08:00
Tomoaki Kawada
1a77d6227c kmc-solid: Increase the default stack size 2022-01-31 17:39:38 +09:00
bors
415c9f9588 Auto merge of #93499 - matthiaskrgr:rollup-icdex11, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #93395 (Improve suggestion for escaping reserved keywords)
 - #93403 (review the total_cmp documentation)
 - #93461 (Accommodate yield points in the format_args expansion)
 - #93462 (Document `SystemTime` platform precision)
 - #93471 (unix: Use metadata for `DirEntry::file_type` fallback)
 - #93480 (Remove deprecated and unstable slice_partition_at_index functions)
 - #93485 (core: Remove some redundant {}s from the sorting code)
 - #93494 (kmc-solid: Inherit the calling task's base priority in `Thread::new`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-31 08:12:10 +00:00
Matthias Krüger
4757a931cd
Rollup merge of #93494 - solid-rs:fix-kmc-solid-spawned-task-priority, r=Mark-Simulacrum
kmc-solid: Inherit the calling task's base priority in `Thread::new`

This PR fixes the initial priority calculation of spawned threads on the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets.

Fixes a spawned task (an RTOS object on top of which threads are implemented for this target; unrelated to async tasks) getting an unexpectedly higher priority if it's spawned by a task whose priority is temporarily boosted by a priority-protection mutex.
2022-01-31 07:00:47 +01:00
Matthias Krüger
24737bd1ab
Rollup merge of #93485 - est31:remove_curly, r=joshtriplett
core: Remove some redundant {}s from the sorting code
2022-01-31 07:00:46 +01:00
Matthias Krüger
b0cdf7e995
Rollup merge of #93480 - est31:remove_unstable_deprecated, r=Mark-Simulacrum
Remove deprecated and unstable slice_partition_at_index functions

They have been deprecated since commit 01ac5a97c9
which was part of the 1.49.0 release, so from the point of nightly,
11 releases ago.
2022-01-31 07:00:45 +01:00
Matthias Krüger
cd27f1b56e
Rollup merge of #93471 - cuviper:direntry-file_type-stat, r=the8472
unix: Use metadata for `DirEntry::file_type` fallback

When `DirEntry::file_type` fails to match a known `d_type`, we should
fall back to `DirEntry::metadata` instead of a bare `lstat`, because
this is faster and more reliable on targets with `fstatat`.
2022-01-31 07:00:44 +01:00
Matthias Krüger
bc2c4feaeb
Rollup merge of #93462 - ChrisDenton:systime-doc, r=joshtriplett
Document `SystemTime` platform precision

Fixes #88822
2022-01-31 07:00:43 +01:00
Matthias Krüger
c1e2948c21
Rollup merge of #93461 - dtolnay:fmtyield, r=davidtwco
Accommodate yield points in the format_args expansion

Fixes #93274.

For the case `println!("{} {:?}", "", async {}.await)` in the issue, the expansion before:

```rust
::std::io::_print(
    ::core::fmt::Arguments::new_v1(
        &["", " ", "\n"],
        &[
            ::core::fmt::ArgumentV1::new(&"", ::core::fmt::Display::fmt),
            ::core::fmt::ArgumentV1::new(&async {}.await, ::core::fmt::Debug::fmt),
        ],
    ),
);
```

After:

```rust
::std::io::_print(
    ::core::fmt::Arguments::new_v1(
        &["", " ", "\n"],
        &match (&"", &async {}.await) {
            _args => [
                ::core::fmt::ArgumentV1::new(_args.0, ::core::fmt::Display::fmt),
                ::core::fmt::ArgumentV1::new(_args.1, ::core::fmt::Debug::fmt),
            ],
        },
    ),
);
```
2022-01-31 07:00:42 +01:00
Matthias Krüger
8fd2ff57fa
Rollup merge of #93403 - nagisa:total-cmp-review, r=joshtriplett
review the total_cmp documentation

The documentation has been restructured to split out a brief summary
paragraph out from the following elaborating paragraphs.

I also attempted my hand at wording improvements and adding articles
where I felt them missing, but being non-native english speaker these
may need more thorough review.

cc https://github.com/rust-lang/rust/issues/72599
2022-01-31 07:00:41 +01:00
Matthias Krüger
2f4602a64c
Rollup merge of #93395 - camelid:reserved-sugg, r=davidtwco
Improve suggestion for escaping reserved keywords

r? `@davidtwco`
2022-01-31 07:00:40 +01:00
Matthias Krüger
2070b22116
Rollup merge of #93444 - camelid:rustdoc-css-cleanup, r=GuillaumeGomez,jsha
Fix some CSS warnings and errors from VS Code

There's no such CSS rule as `box-shadow-color`, so I instead copied the
whole `box-shadow` property to each rule to make it actually apply.

r? `@jsha`
2022-01-31 06:58:33 +01:00
Matthias Krüger
c03bf54dd1
Rollup merge of #93392 - GKFX:char-docs, r=scottmcm
Clarify documentation on char::MAX

As mentioned in https://github.com/rust-lang/rust/issues/91836#issuecomment-994106874, the documentation on `char::MAX` is not quite correct – USVs are not "only ones within a certain range", they are code points _outside_ a certain range. I have corrected this and given the actual numbers as there is no reason to hide them.
2022-01-31 06:58:32 +01:00
Matthias Krüger
76857fb3fb
Rollup merge of #93347 - WaffleLapkin:better_char_decode_utf16_size_hint, r=dtolnay
Make `char::DecodeUtf16::size_hist` more precise

New implementation takes into account contents of `self.buf` and rounds lower bound up instead of down.

Fixes #88762
Revival of #88763
2022-01-31 06:58:31 +01:00
Matthias Krüger
7de90d5b65
Rollup merge of #93214 - ibraheemdev:issue-93210, r=davidtwco
Respect doc(hidden) when suggesting available fields

Resolves #93210
2022-01-31 06:58:30 +01:00
Matthias Krüger
1cb22e4138
Rollup merge of #93155 - dtolnay:blockindent, r=nagisa
Switch pretty printer to block-based indentation

This PR backports 401d60c042 from the `prettyplease` crate into `rustc_ast_pretty`.

A before and after:

```diff
- let res =
-     ((::alloc::fmt::format as
-          for<'r> fn(Arguments<'r>) -> String {format})(((::core::fmt::Arguments::new_v1
-                                                             as
-                                                             fn(&[&'static str], &[ArgumentV1]) -> Arguments {Arguments::new_v1})((&([("test"
-                                                                                                                                          as
-                                                                                                                                          &str)]
-                                                                                                                                        as
-                                                                                                                                        [&str; 1])
-                                                                                                                                      as
-                                                                                                                                      &[&str; 1]),
-                                                                                                                                  (&([]
-                                                                                                                                        as
-                                                                                                                                        [ArgumentV1; 0])
-                                                                                                                                      as
-                                                                                                                                      &[ArgumentV1; 0]))
-                                                            as
-                                                            Arguments))
-         as String);
+ let res =
+     ((::alloc::fmt::format as
+             for<'r> fn(Arguments<'r>) -> String {format})(((::core::fmt::Arguments::new_v1
+                 as
+                 fn(&[&'static str], &[ArgumentV1]) -> Arguments {Arguments::new_v1})((&([("test"
+                             as &str)] as [&str; 1]) as
+                 &[&str; 1]),
+             (&([] as [ArgumentV1; 0]) as &[ArgumentV1; 0])) as
+             Arguments)) as String);
```

Previously the pretty printer would compute indentation always relative to whatever column a block begins at, like this:

```rust
fn demo(arg1: usize,
        arg2: usize);
```

This is never the thing to do in the dominant contemporary Rust style. Rustfmt's default and the style used by the vast majority of Rust codebases is block indentation:

```rust
fn demo(
    arg1: usize,
    arg2: usize,
);
```

where every indentation level is a multiple of 4 spaces and each level is indented relative to the indentation of the previous line, not the position that the block starts in.

By itself this PR doesn't get perfect formatting in all cases, but it is the smallest possible step in clearly the right direction. More backports from `prettyplease` to tune the ibox/cbox indent levels around various AST node types are upcoming.
2022-01-31 06:58:29 +01:00
Matthias Krüger
71efe90889
Rollup merge of #93039 - terrarier2111:fix-field-help, r=nagisa
Don't suggest inaccessible fields

Fixes: https://github.com/rust-lang/rust/issues/92999
2022-01-31 06:58:28 +01:00
Matthias Krüger
55d5513662
Rollup merge of #92918 - compiler-errors:gat-expr-lifetime-elision, r=jackh726
Allow eliding GATs in expression position

Thoughts on whether this is worthwhile?

Fixes #92836

r? ``@jackh726``
2022-01-31 06:58:27 +01:00
Matthias Krüger
6749f32c33
Rollup merge of #90277 - pierwill:fix-70258-inference-terms, r=jackh726
Improve terminology around "after typeck"

Closes #70258.
2022-01-31 06:58:26 +01:00
bors
bb549e5afe Auto merge of #93270 - klensy:sec-up, r=Mark-Simulacrum
update vulnerable/yanked deps

tokio v1.8.2 -> v1.8.4: https://rustsec.org/advisories/RUSTSEC-2021-0124
ammonia v3.1.0 -> v3.1.3: https://rustsec.org/advisories/RUSTSEC-2022-0003
thread_local v1.0.1 -> v1.1.4: https://rustsec.org/advisories/RUSTSEC-2022-0006

pin-project-lite v0.2.4 -> v0.2.8: yanked: https://github.com/taiki-e/pin-project-lite/blob/main/CHANGELOG.md#024---2021-01-11
2022-01-31 04:23:21 +00:00
David Tolnay
125c729e05
Restore a visual alignment mode for block comments 2022-01-30 19:50:54 -08:00
David Tolnay
402f322940
Bless all pretty printer tests and ui tests 2022-01-30 19:50:51 -08:00
David Tolnay
8ac05b9766
Fix some double indents on exprs containing blocks
The `print_expr` method already places an `ibox(INDENT_UNIT)` around
every expr that gets printed. Some exprs were then using `self.head`
inside of that, which does its own `cbox(INDENT_UNIT)`, resulting in two
levels of indentation:

    while true {
            stuff;
        }

This commit fixes those cases to produce the expected single level of
indentation within every expression containing a block.

    while true {
        stuff;
    }
2022-01-30 19:45:00 -08:00
David Tolnay
cb93e9c0ec
Compute indent never relative to current column
Previously the pretty printer would compute indentation always relative
to whatever column a block begins at, like this:

    fn demo(arg1: usize,
            arg2: usize);

This is never the thing to do in the dominant contemporary Rust style.
Rustfmt's default and the style used by the vast majority of Rust
codebases is block indentation:

    fn demo(
        arg1: usize,
        arg2: usize,
    );

where every indentation level is a multiple of 4 spaces and each level
is indented relative to the indentation of the previous line, not the
position that the block starts in.
2022-01-30 19:44:59 -08:00
Tomoaki Kawada
09233ce3c0 kmc-solid: Inherit the calling task's base priority in Thread::new
Fixes a spawned task getting an unexpectedly higher priority if it's
spawned by a task whose priority is temporarily boosted by a priority-
protection mutex.
2022-01-31 11:31:55 +09:00
bors
e58e7b10e1 Auto merge of #90891 - nbdd0121:format, r=Mark-Simulacrum
Create `core::fmt::ArgumentV1` with generics instead of fn pointer

Split from (and prerequisite of) #90488, as this seems to have perf implication.

`@rustbot` label: +T-libs
2022-01-31 00:04:46 +00:00
George Bateman
9aaf52b66a
(#93392) Update char::MAX docs and core::char::MAX 2022-01-30 23:10:24 +00:00
Mark Rousskov
9bf6a5de77 Hide failed command unless in verbose mode
This is particularly intended for invoking compiletest; the command line there
is long (3,350 characters on my system) and takes up a lot of screen real estate
for little benefit to the majority of those running bootstrap. This moves
printing it to verbose mode (-v must be passed) which means that it's still
possible to access when needed for debugging.

The main downside is that CI logs will by-default become less usable for
debugging (particularly) spurious failures, but it is pretty rare for us to
really need the information there -- it's usually fairly obvious what is being
run with a little investigation.
2022-01-30 17:37:11 -05:00
George Bateman
4d4ec97e0a
Document char validity 2022-01-30 22:16:41 +00:00
Simonas Kazlauskas
78efb075d9 review the total_cmp documentation
The documentation has been restructured to split out a brief summary
paragraph out from the following elaborating paragraphs.

I also attempted my hand at wording improvements and adding articles
where I felt them missing, but being non-native english speaker these
may need more thorough review.
2022-01-30 23:20:54 +02:00
bors
08df8b81d6 Auto merge of #92711 - zredb:issue-90187-fix, r=notriddle
rustdoc: Remove `def_id_no_primitives`

Fixes #90187.
2022-01-30 20:57:34 +00:00
David Tolnay
858d6a0711
Mac calls 2022-01-30 11:53:12 -08:00
David Tolnay
47f92a58a4
Accommodate yield points in the format_args expansion 2022-01-30 11:53:11 -08:00
David Tolnay
1dd02e32a3
Add regression test for issue 93274
Currently fails with:

    error: future cannot be sent between threads safely
      --> $DIR/src/test/ui/fmt/format-with-yield-point.rs:21:17
       |
    LL |     assert_send(with_await());
       |                 ^^^^^^^^^^^^ future returned by `with_await` is not `Send`
       |
       = help: the trait `Sync` is not implemented for `core::fmt::Opaque`
    note: future is not `Send` as this value is used across an await
      --> $DIR/src/test/ui/fmt/format-with-yield-point.rs:11:37
       |
    LL |     println!("{} {:?}", "", async {}.await);
       |     --------------------------------^^^^^^-
       |     |                               |
       |     |                               await occurs here, with `$crate::format_args_nl!($($arg)*)` maybe used later
       |     has type `ArgumentV1<'_>` which is not `Send`
       |     `$crate::format_args_nl!($($arg)*)` is later dropped here
    note: required by a bound in `assert_send`
      --> $DIR/src/test/ui/fmt/format-with-yield-point.rs:18:24
       |
    LL | fn assert_send(_: impl Send) {}
       |                        ^^^^ required by this bound in `assert_send`

    error: future cannot be sent between threads safely
      --> $DIR/src/test/ui/fmt/format-with-yield-point.rs:22:17
       |
    LL |     assert_send(with_macro_call());
       |                 ^^^^^^^^^^^^^^^^^ future returned by `with_macro_call` is not `Send`
       |
       = help: the trait `Sync` is not implemented for `core::fmt::Opaque`
    note: future is not `Send` as this value is used across an await
      --> $DIR/src/test/ui/fmt/format-with-yield-point.rs:6:17
       |
    LL |         async {}.await
       |                 ^^^^^^ await occurs here, with `$crate::format_args_nl!($($arg)*)` maybe used later
    ...
    LL |     println!("{} {:?}", "", m!());
       |     -----------------------------
       |     |                       |
       |     |                       in this macro invocation
       |     has type `ArgumentV1<'_>` which is not `Send`
       |     `$crate::format_args_nl!($($arg)*)` is later dropped here
    note: required by a bound in `assert_send`
      --> $DIR/src/test/ui/fmt/format-with-yield-point.rs:18:24
       |
    LL | fn assert_send(_: impl Send) {}
       |                        ^^^^ required by this bound in `assert_send`
       = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: aborting due to 2 previous errors
2022-01-30 11:53:11 -08:00
bors
8c7f2bf44f Auto merge of #93482 - ehuss:rollup-qjyppci, r=ehuss
Rollup of 5 pull requests

Successful merges:

 - #92887 (Bootstrap compiler update)
 - #92908 (Render more readable macro matcher tokens in rustdoc)
 - #93183 (rustdoc: mobile nav fixes)
 - #93192 (Add VS 2022 into error message)
 - #93475 (Add test to ensure that theme is applied correctly when going back in history)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-30 18:12:08 +00:00
est31
cde240c1e8 core: Remove some redundant {}s from the sorting code 2022-01-30 18:32:24 +01:00
Eric Huss
5e4837840e
Rollup merge of #93475 - GuillaumeGomez:theme-in-history, r=jsha
Add test to ensure that theme is applied correctly when going back in history

Fixes #93258.

r? `@jsha`
2022-01-30 08:37:51 -08:00
Eric Huss
cee571e606
Rollup merge of #93192 - theidexisted:patch-1, r=wesleywiser
Add VS 2022 into error message
2022-01-30 08:37:50 -08:00
Eric Huss
4ddf986d68
Rollup merge of #93183 - jsha:mobile-nav-fixes, r=GuillaumeGomez
rustdoc: mobile nav fixes

- Make sure the mobile-topbar doesn't overflow its height if the user sets a bigger font.

- Make sure the sidebar can be scrolled all the way to the bottom by shortening it to accommodate the mobile-topbar.

- Make the item name in the mobile-topbar clickable to go to the top of the page.

- Remove excess padding sidebar in mobile mode.

Demo https://rustdoc.crud.net/jsha/mobile-nav-fixes/std/string/struct.String.html

r? `@GuillaumeGomez`
2022-01-30 08:37:49 -08:00
Eric Huss
ba013373d8
Rollup merge of #92908 - dtolnay:rustdoc, r=GuillaumeGomez
Render more readable macro matcher tokens in rustdoc

Follow-up to #92334.

This PR lifts some of the token rendering logic from https://github.com/dtolnay/prettyplease into rustdoc so that even the matchers for which a source code snippet is not available (because they are macro-generated, or any other reason) follow some baseline good assumptions about where the tokens in the macro matcher are appropriate to space.

The below screenshots show an example of the difference using one of the gnarliest macros I could find. Some things to notice:

- In the **before**, notice how a couple places break in between `$(....)`↵`*`, which is just about the worst possible place that it could break.

- In the **before**, the lines that wrapped are weirdly indented by 1 space of indentation relative to column 0. In the **after**, we use the typical way of block indenting in Rust syntax which is put the open/close delimiters on their own line and indent their contents by 4 spaces relative to the previous line (so 8 spaces relative to column 0, because the matcher itself is indented by 4 relative to the `macro_rules` header).

- In the **after**, macro_rules metavariables like `$tokens:tt` are kept together, which is how just about everybody writing Rust today writes them.

## Before

![Screenshot from 2022-01-14 13-05-53](https://user-images.githubusercontent.com/1940490/149585105-1f182b78-751f-421f-a234-9dbc04fa3bbd.png)

## After

![Screenshot from 2022-01-14 13-06-04](https://user-images.githubusercontent.com/1940490/149585118-d4b52ea7-3e67-4b6e-a12b-31dfb8172f86.png)

r? `@camelid`
2022-01-30 08:37:47 -08:00
Eric Huss
0610d4fa66
Rollup merge of #92887 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrum
Bootstrap compiler update

r? ``@Mark-Simulacrum``
2022-01-30 08:37:46 -08:00