Commit graph

170422 commits

Author SHA1 Message Date
bors 349bda2051 Auto merge of #98181 - JohnTitor:rollup-65ztwnz, r=JohnTitor
Rollup of 5 pull requests

Successful merges:

 - #97377 (Do not suggest adding semicolon/changing delimiters for macros in item position that originates in macros)
 - #97675 (Make `std::mem::needs_drop` accept `?Sized`)
 - #98118 (Test NLL fix of bad lifetime inference for reference captured in closure.)
 - #98166 (Add rustdoc-json regression test for #98009)
 - #98169 (Keyword docs: Link to wikipedia article for dynamic dispatch)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-06-16 23:50:20 +00:00
Yuki Okushi 6ac93185f4
Rollup merge of #98169 - pierwill:dyn-disp, r=JohnTitor
Keyword docs: Link to wikipedia article for dynamic dispatch
2022-06-17 07:16:58 +09:00
Yuki Okushi 81b00b80f3
Rollup merge of #98166 - GuillaumeGomez:regression-test-98009, r=matthiaskrgr
Add rustdoc-json regression test for #98009

Fixes #98009.

There was apparently nothing to be done...

cc `@matthiaskrgr`
r? `@notriddle`
2022-06-17 07:16:57 +09:00
Yuki Okushi 1f3023ca8a
Rollup merge of #98118 - steffahn:scoped-threads-nll-test, r=m-ou-se
Test NLL fix of bad lifetime inference for reference captured in closure.

This came up as a use-case for `thread::scope` API that only compiles successfully since `feature(nll)` got stabilized recently.

Closes #93203 which had been re-opened for tracking this very test case to be added.
2022-06-17 07:16:56 +09:00
Yuki Okushi cf68fd7e8d
Rollup merge of #97675 - nvzqz:unsized-needs-drop, r=dtolnay
Make `std::mem::needs_drop` accept `?Sized`

This change attempts to make `needs_drop` work with types like `[u8]` and `str`.

This enables code in types like `Arc<T>` that was not possible before, such as https://github.com/rust-lang/rust/pull/97676.
2022-06-17 07:16:55 +09:00
Yuki Okushi 5cd8679dd2
Rollup merge of #97377 - ChayimFriedman2:issue-91800, r=estebank
Do not suggest adding semicolon/changing delimiters for macros in item position that originates in macros

Fixes #91800.
2022-06-17 07:16:54 +09:00
bors cacc75c82e Auto merge of #97936 - nnethercote:compile-unicode_normalization-faster, r=oli-obk
Compile `unicode-normalization` faster

Various optimizations and cleanups aimed at improving compilation of `unicode-normalization`, which is notable for having several very large `match`es with many char ranges.

Best reviewed one commit at a time.

r? `@oli-obk`
2022-06-16 21:09:30 +00:00
bors 3bebee7339 Auto merge of #98173 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`
2022-06-16 18:13:02 +00:00
flip1995 37cdd7e372
Update Cargo.lock 2022-06-16 17:39:29 +02:00
flip1995 7f605496e7
Merge commit 'd7b5cbf065b88830ca519adcb73fad4c0d24b1c7' into clippyup 2022-06-16 17:39:06 +02:00
pierwill dd0f5d8be0 Keyword docs: Link to wikipedia article for dynamic dispatch 2022-06-16 09:58:57 -05:00
bors d7b5cbf065 Auto merge of #9007 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2022-06-16 14:07:23 +00:00
flip1995 280797ecb0
Bump nightly version -> 2022-06-16 2022-06-16 16:04:12 +02:00
flip1995 c5c8f6122f
Merge remote-tracking branch 'upstream/master' into rustup 2022-06-16 16:04:06 +02:00
bors 9edd6412f1 Auto merge of #9005 - flip1995:book_ci_2, r=xFrednet
Build mdbook in remark workflow

r? `@xFrednet`

Supersedes #8959

changelog: none
2022-06-16 12:49:20 +00:00
Guillaume Gomez d7513140ca Add rustdonc-json regression test for #98009 2022-06-16 14:13:57 +02:00
flip1995 980d88e25c
Build mdbook in remark workflow
This is just to ensure that the book builds all time to not get in trouble when syncing with rust-lang/rust
2022-06-16 14:10:35 +02:00
bors 6ec3993ef4 Auto merge of #97842 - notriddle:notriddle/tuple-docs, r=jsha,GuillaumeGomez
Improve the tuple and unit trait docs

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

Here's the new version:

* <https://notriddle.com/notriddle-rustdoc-test/std/primitive.tuple.html>
* <https://notriddle.com/notriddle-rustdoc-test/std/primitive.unit.html>
2022-06-16 11:13:30 +00:00
bors d40f24e956 Auto merge of #98161 - matthiaskrgr:rollup-8csenk9, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #97757 (Support lint expectations for `--force-warn` lints (RFC 2383))
 - #98125 (Entry and_modify doc)
 - #98137 (debuginfo: Fix NatVis for Rc and Arc with unsized pointees.)
 - #98147 (Make #[cfg(bootstrap)] not error in proc macros on later stages )

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-06-16 07:45:03 +00:00
Matthias Krüger 97a7a3c9ea
Rollup merge of #98147 - est31:bootstrap_cfg_flag, r=Mark-Simulacrum
Make #[cfg(bootstrap)] not error in proc macros on later stages

As was discovered in https://github.com/rust-lang/rust/pull/93628#issuecomment-1154697627,
adding #[cfg(bootstrap)] to a rust-internal proc macro crate
would yield an unexpected cfg name error, at least on later
stages wher the bootstrap cfg arg wasn't set.

rustc already passes arguments to mark bootstrap as expected,
however the means of delivery through the RUSTFLAGS env var
is unable to reach proc macro crates, as described
in the issue linked in the code this commit touches.

This wouldn't be an issue for cfg args that get passed through
RUSTFLAGS, as they would never become *active* either, so
any usage of one of these flags in a proc macro's code would
legitimately yield a lint warning. But since dc30258,
rust takes extra measures to pass --cfg=bootstrap even in
proc macros, by passing it via the wrapper. Thus, we need
to send the flags to mark bootstrap as expected also from the
wrapper, so that #[cfg(bootstrap)] also works from proc macros.

I want to thank `Urgau` and `jplatte` for helping me find the cause of this. ❤️
2022-06-16 09:10:23 +02:00
Matthias Krüger ae58a55d03
Rollup merge of #98137 - michaelwoerister:fix-unsized-rc-arc-natvis, r=wesleywiser
debuginfo: Fix NatVis for Rc and Arc with unsized pointees.

Currently, the NatVis for `Rc<T>` and `Arc<T>` does not support unsized `T`. For both `Rc<T>` and `Rc<dyn SomeTrait>` the visualizers fail:

```txt
    [Reference count] : -> must be used on pointers and . on structures
    [Weak reference count] : -> must be used on pointers and . on structures
```

This PR fixes the visualizers. For slices we can even give show the elements, so one now gets something like:

```txt
slice_rc         : { len=3 }
    [Length]         : 3
    [Reference count] : 41
    [Weak reference count] : 2
    [0]              : 1
    [1]              : 2
    [2]              : 3
```

r? `@wesleywiser`
2022-06-16 09:10:22 +02:00
Matthias Krüger f4297b06e8
Rollup merge of #98125 - KarlWithK:entry_add_modify_doc, r=Dylan-DPC
Entry and_modify doc

This PR modifies the documentation for [HashMap](https://doc.rust-lang.org/std/collections/struct.HashMap.html#) and [BTreeMap](https://doc.rust-lang.org/std/collections/struct.BTreeMap.html#) by introducing examples for `and_modify`. `and_modify` is a function that tends to give more idiomatic rust code when dealing with these data structures -- yet it lacked examples and was hidden away. This PR adds that and addresses #98122.

I've made some choices which I tried to explain in my commits. This is my first time contributing to rust, so hopefully, I made the right choices.
2022-06-16 09:10:21 +02:00
Matthias Krüger 95be954af4
Rollup merge of #97757 - xFrednet:rfc-2383-expect-with-force-warn, r=wesleywiser,flip1995
Support lint expectations for `--force-warn` lints (RFC 2383)

Rustc has a `--force-warn` flag, which overrides lint level attributes and forces the diagnostics to always be warn. This means, that for lint expectations, the diagnostic can't be suppressed as usual. This also means that the expectation would not be fulfilled, even if a lint had been triggered in the expected scope.

This PR now also tracks the expectation ID in the `ForceWarn` level. I've also made some minor adjustments, to possibly catch more bugs and make the whole implementation more robust.

This will probably conflict with https://github.com/rust-lang/rust/pull/97718. That PR should ideally be reviewed and merged first. The conflict itself will be trivial to fix.

---

r? `@wesleywiser`

cc: `@flip1995` since you've helped with the initial review and also discussed this topic with me. 🙃

Follow-up of: https://github.com/rust-lang/rust/pull/87835

Issue: https://github.com/rust-lang/rust/issues/85549

Yeah, and that's it.
2022-06-16 09:10:20 +02:00
xFrednet 8527a3d369
Support lint expectations for --force-warn lints (RFC 2383) 2022-06-16 08:16:43 +02:00
bors 392d272868 Auto merge of #98108 - SpriteOvO:doc_auto_cfg-feature-rmv-fix, r=notriddle,GuillaumeGomez
Rustdoc: Fix stab disappearing and exclude cfg "doc" and "doctest"

Fixes #98065 Context: https://github.com/rust-lang/rust/issues/43781#issuecomment-1154226733

r? `@GuillaumeGomez`
2022-06-16 05:02:10 +00:00
Chayim Refael Friedman 0ef4098a54 Do not suggest adding semicolon/changing delimiters for macros in item position that originates in macros 2022-06-16 02:19:31 +00:00
bors 1b9daa6964 Auto merge of #98103 - exrook:btreemap-alloc, r=Amanieu
BTreeMap: Support custom allocators (v1.5)

Related:
https://github.com/rust-lang/wg-allocators/issues/7
https://github.com/TimDiekmann/alloc-wg

Blocked on:
~~#77187~~
~~#78459~~
~~#95036~~

previous: #77438
2022-06-16 02:15:55 +00:00
Nicholas Nethercote bdbf9b297b compare_const_vals: add a special case for certain ranges.
This commit removes the `a == b` early return, which isn't useful in
practice, and replaces it with one that helps matches with many ranges,
including char ranges.
2022-06-16 11:25:34 +10:00
Nicholas Nethercote 73c52b724a compare_const_vals: Use infallible evaluation.
Because these evaluations can never fail.
2022-06-16 10:52:58 +10:00
Nicholas Nethercote 246a5e08bf Remove ty arg from compare_const_vals.
It's now only used in no-longer-interesting assertion.
2022-06-16 10:52:58 +10:00
Nicholas Nethercote 3ab6ef1938 Remove from_bool closure.
The code is clearer and simpler without it. Note that the `a == b` early
return at the top of the function means the `a == b` test at the end of
the function could never succeed.
2022-06-16 10:52:58 +10:00
Nicholas Nethercote fab85ddbeb Inline and remove fallback closure. 2022-06-16 10:52:58 +10:00
Nicholas Nethercote b67635fdfd Remove one use of compare_const_vals.
A direct comparison has the same effect. This also avoids the need for a
type test within `compare_const_vals`.
2022-06-16 10:52:58 +10:00
Nicholas Nethercote 9b4b34a0a6 Assert type equality of a and b in compare_const_vals.
Because they're always equal.
2022-06-16 10:52:58 +10:00
Nicholas Nethercote d5a13e2ca0 Remove dead code from compare_const_vals.
It's never executed when running the entire test suite. I think it's
because of the early return at the top of the function if `a.ty() != ty`
succeeds.
2022-06-16 10:52:56 +10:00
Nicholas Nethercote be6c364142 simplify_match_pair: avoid the second comparison if possible.
Also, the `try_to_bits` always succeeds, so use `unwrap`.
2022-06-16 10:52:19 +10:00
Nicholas Nethercote c4cd04480b sort_candidates: avoid the second comparison if possible.
This is a performance win for `unicode-normalization`.

The commit also removes the closure, which isn't necessary. And
reformulates the comparison into a form I find easier to read.
2022-06-16 10:52:19 +10:00
Nicholas Nethercote 7e4ec35d0c const_range_contains: avoid the second comparison if possible.
This is a performance win for `unicode-normalization`.

Also, I find the new formulation easier to read.
2022-06-16 10:52:19 +10:00
bors 5bc82c0b94 Auto merge of #98152 - JohnTitor:rollup-osr17j6, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #97202 (os str capacity documentation)
 - #97964 (Fix suggestions for `&a: T` parameters)
 - #98053 (Fix generic impl rustdoc json output)
 - #98059 (Inline `const_eval_select`)
 - #98092 (Fix sidebar items expand collapse)
 - #98119 (Refactor path segment parameter error)
 - #98135 (Add regression test for #93775)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-06-15 23:49:06 +00:00
Wesley Wiser 95adaa22e0 The type of the slice length field is architecture dependent 2022-06-15 18:35:41 -04:00
Yuki Okushi 4ab704e12b
Rollup merge of #98135 - JohnTitor:issue-93022-93775, r=compiler-errors
Add regression test for #93775

Closes #93775, also closes #93022 as it should have the same root cause
r? ```@compiler-errors```

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-06-16 07:24:44 +09:00
Yuki Okushi bfc6c90115
Rollup merge of #98119 - EdwinRy:path-parenthesized-type-error, r=estebank
Refactor path segment parameter error

This PR attempts to rewrite the error handling for an unexpected parenthesised type parameters to:
- Use provided data instead of re-parsing the whole span
- Add a multipart suggestion to reflect on the changes with an underline
- Remove the unnecessary "if" nesting
2022-06-16 07:24:43 +09:00
Yuki Okushi ad61ae59bf
Rollup merge of #98092 - GuillaumeGomez:fix-sidebar-items-expand-collapse, r=notriddle
Fix sidebar items expand collapse

The collapse/expand event was not working for the items in the source code viewer sidebar (talking about these items:

![Screenshot from 2022-06-14 11-21-58](https://user-images.githubusercontent.com/3050060/173543346-af056928-e921-458f-b918-60f6fd0ecbde.png)

).

This PR fixes it and adds a GUI test to prevent another regression.

r? ```@notriddle```
2022-06-16 07:24:42 +09:00
Yuki Okushi b91c4d5b45
Rollup merge of #98059 - tmiasko:inline-const-eval-select, r=Amanieu
Inline `const_eval_select`

To avoid circular link time dependency between core and compiler
builtins when building with `-Zshare-generics`.

r? ```@Amanieu```
2022-06-16 07:24:41 +09:00
Yuki Okushi 4ee78a686f
Rollup merge of #98053 - GuillaumeGomez:fix-generic-impl-json-ice, r=notriddle
Fix generic impl rustdoc json output

Fixes #97986.

The problem in case of generic trait impl is that the trait's items are the same for all the types afterward. But since they're the same, it's safe for rustdoc-json to just ignore them.

A little representation of what's going on:

```rust
trait T {
    fn f(); // <- defid 0
}

impl<Y> T for Y {
    fn f() {} // <- defid 1
}

struct S; // <- defid 1 (since it matches `impl<Y> T for Y`
```

cc ```@Urgau```

r? ```@CraftSpider```
2022-06-16 07:24:40 +09:00
Yuki Okushi 52afa3a70c
Rollup merge of #97964 - WaffleLapkin:fix_borrow_par_suggestions, r=compiler-errors
Fix suggestions for `&a: T` parameters

I've accidentally discovered that we have broken suggestions for `&a: T` parameters:
```rust
fn f(&mut bar: u32) {}

fn main() {
    let _ = |&mut a| ();
}
```
```text
error[E0308]: mismatched types
 --> ./t.rs:1:6
  |
1 | fn f(&mut bar: u32) {}
  |      ^^^^^^^^-----
  |      |         |
  |      |         expected due to this
  |      expected `u32`, found `&mut _`
  |      help: did you mean `bar`: `&u32`
  |
  = note:           expected type `u32`
          found mutable reference `&mut _`

error[E0308]: mismatched types
 --> ./t.rs:4:23
  |
4 |     let _: fn(u32) = |&mut a| ();
  |                       ^^^^^--
  |                       |    |
  |                       |    expected due to this
  |                       expected `u32`, found `&mut _`
  |                       help: did you mean `a`: `&u32`
  |
  = note:           expected type `u32`
          found mutable reference `&mut _`
```

It's hard to see, but
1. The help span is overlapping with "expected" spans
2. It suggests `fn f( &u32) {}` (no `mut` and lost parameter name) and `|&u32 ()` (no closing `|` and lost parameter name)

I've tried to fix this.

r? ``@compiler-errors``
2022-06-16 07:24:39 +09:00
Yuki Okushi b37e4e043e
Rollup merge of #97202 - joshtriplett:os-str-capacity-documentation, r=dtolnay
os str capacity documentation

This is based on https://github.com/rust-lang/rust/pull/95394 , with expansion and consolidation
to address comments from `@dtolnay` and other `@rust-lang/libs-api` team members.
2022-06-16 07:24:38 +09:00
est31 471fa05fef Make #[cfg(bootstrap)] not error in proc macros on later stages
As was discovered in https://github.com/rust-lang/rust/pull/93628#issuecomment-1154697627 ,
adding #[cfg(bootstrap)] to a rust-internal proc macro crate
would yield an unexpected cfg name error, at least on later
stages wher the bootstrap cfg arg wasn't set.

rustc already passes arguments to mark bootstrap as expected,
however the means of delivery through the RUSTFLAGS env var
is unable to reach proc macro crates, as described
in the issue linked in the code this commit touches.

This wouldn't be an issue for cfg args that get passed through
RUSTFLAGS, as they would never become *active* either, so
any usage of one of these flags in a proc macro's code would
legitimately yield a lint warning. But since dc302587e2,
rust takes extra measures to pass --cfg=bootstrap even in
proc macros, by passing it via the wrapper. Thus, we need
to send the flags to mark bootstrap as expected also from the
wrapper, so that #[cfg(bootstrap)] also works from proc macros.

I want to thank Urgau and jplatte for helping me find the cause of this. ❤️
2022-06-16 00:03:27 +02:00
bors b31f9cc22b Auto merge of #97178 - sunfishcode:ownedfd-and-dup, r=joshtriplett
Add a `BorrowedFd::try_clone_to_owned` and accompanying documentation

Add a `BorrowedFd::try_clone_to_owned`, which returns a new `OwnedFd` sharing the underlying file description. And similar for `BorrowedHandle` and `BorrowedSocket` on WIndows.

This is similar to the existing `OwnedFd::try_clone`, but it's named differently to reflect that it doesn't return `Result<Self, ...>`. I'm open to suggestions for better names.

Also, extend the `unix::io` documentation to mention that `dup` is permitted on `BorrowedFd`.

This was originally requsted [here](https://github.com/rust-lang/rust/issues/88564#issuecomment-910786081). At the time I wasn't sure whether it was desirable, but it does have uses and it helps clarify the API. The documentation previously didn't rule out using `dup` on a `BorrowedFd`, but the API only offered convenient ways to do it from an `OwnedFd`. With this patch, the API allows one to do `try_clone` on any type where it's permitted.
2022-06-15 21:08:08 +00:00
bors 71f2de96ee Auto merge of #9002 - andylizi:fix-never-loop, r=Manishearth
Fix false positive for `never_loop` struct expression fields

Fixes #9001.

changelog: [`never_loop`]: Now checks for `continue` in struct expression
2022-06-15 18:36:32 +00:00