]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #96757 - jyn514:fewer-clippy-rebuilds, r=Mark-Simulacrum
Matthias Krüger [Sat, 7 May 2022 20:44:42 +0000 (22:44 +0200)]
Rollup merge of #96757 - jyn514:fewer-clippy-rebuilds, r=Mark-Simulacrum

Don't constantly rebuild clippy on `x test src/tools/clippy`.

This happened because the `SYSROOT` variable was set for `x test`, but not `x build`.
Set it consistently for both to avoid unnecessary rebuilds.

This is a very small step towards https://github.com/rust-lang/rust/issues/76495.

2 years agoRollup merge of #96756 - jyn514:compiler-docs-default, r=Mark-Simulacrum
Matthias Krüger [Sat, 7 May 2022 20:44:41 +0000 (22:44 +0200)]
Rollup merge of #96756 - jyn514:compiler-docs-default, r=Mark-Simulacrum

Enable compiler-docs by default for `compiler`, `codegen`, and `tools` profiles

I had this overridden locally for a while and realized just now it should probably just be a default.

2 years agoRollup merge of #96726 - oli-obk:no_cross_inference, r=Mark-Simulacrum
Matthias Krüger [Sat, 7 May 2022 20:44:40 +0000 (22:44 +0200)]
Rollup merge of #96726 - oli-obk:no_cross_inference, r=Mark-Simulacrum

Add regression and bug tests

this tracks the behaviour from https://github.com/rust-lang/rust/issues/96572 in our test suite

2 years agoRollup merge of #96671 - mgeisler:current-exe-docstring, r=Mark-Simulacrum
Matthias Krüger [Sat, 7 May 2022 20:44:39 +0000 (22:44 +0200)]
Rollup merge of #96671 - mgeisler:current-exe-docstring, r=Mark-Simulacrum

Remove hard links from `env::current_exe` security example

The security example shows that `env::current_exe` will return the path used when the program was started. This is not really surprising considering how hard links work: after `ln foo bar`, the two files are _equivalent_. It is _not_ the case that `bar` is a “link” to `foo`, nor is `foo` a link to `bar`. They are simply two names for the same underlying data.

The security vulnerability linked to seems to be different: there an attacker would start a SUID binary from a directory under the control of the attacker. The binary would respawn itself by executing the program found at `/proc/self/exe` (which the attacker can control). This is a real problem. In my opinion, the example given here doesn’t really show the same problem, it just shows a misunderstanding of what hard links are.

I looked through the history a bit and found that the example was introduced in https://github.com/rust-lang/rust/pull/33526. That PR actually has two commits, and the first (https://github.com/rust-lang/rust/commit/8478d48dad949b3b1374569a5391089a49094eeb) explains the race condition at the root of the linked security vulnerability. The second commit proceeds to replace the explanation with the example we have today.

This commit reverts most of the second commit from https://github.com/rust-lang/rust/pull/33526.

2 years agoRollup merge of #96667 - oli-obk:collect_hidden_types, r=Mark-Simulacrum
Matthias Krüger [Sat, 7 May 2022 20:44:38 +0000 (22:44 +0200)]
Rollup merge of #96667 - oli-obk:collect_hidden_types, r=Mark-Simulacrum

Add regression test

fixes #69785

This issue seems to have been fixed in the meantime.

2 years agoRollup merge of #96586 - ear7h:master, r=joshtriplett
Matthias Krüger [Sat, 7 May 2022 20:44:37 +0000 (22:44 +0200)]
Rollup merge of #96586 - ear7h:master, r=joshtriplett

Add aliases for std::fs::canonicalize

The aliases are `realpath` and `GetFinalPathNameByHandle` which are explicitly mentioned in `canonicalize`'s documentation.

2 years agoRollup merge of #96336 - Nilstrieb:link-to-correct-as_mut-in-ptr-as_ref, r=JohnTitor
Matthias Krüger [Sat, 7 May 2022 20:44:36 +0000 (22:44 +0200)]
Rollup merge of #96336 - Nilstrieb:link-to-correct-as_mut-in-ptr-as_ref, r=JohnTitor

Link to correct `as_mut` in docs for `pointer::as_ref`

It previously linked to the unstable const-mut-cast method instead of
the `mut` counterpart for `as_ref`.

Closes #96327

2 years agoAuto merge of #96657 - cuviper:time64, r=joshtriplett
bors [Sat, 7 May 2022 17:53:59 +0000 (17:53 +0000)]
Auto merge of #96657 - cuviper:time64, r=joshtriplett

Use 64-bit time on 32-bit linux-gnu

The standard library suffered the [Year 2038 problem][Y2038] in two main places on targets with 32-bit `time_t`:

- In `std::time::SystemTime`, we stored a `timespec` that has `time_t` seconds. This is now changed to directly store 64-bit seconds and nanoseconds, and on 32-bit linux-gnu we try to use `__clock_gettime64` (glibc 2.34+) to get the larger timestamp.

- In `std::fs::Metadata`, we store a `stat64`, which has 64-bit `off_t` but still 32-bit `time_t`, and unfortunately that is baked in the API by the (deprecated) `MetadataExt::as_raw_stat()`. However, we can use `statx` for 64-bit `statx_timestamp` to store in addition to the `stat64`, as we already do to support creation time, and the rest of the `MetadataExt` methods can return those full values. Note that some filesystems may still be limited in their actual timestamp support, but that's not something Rust can change.

There remain a few places that need `timespec` for system call timeouts -- I leave that to future work.

[Y2038]: https://en.wikipedia.org/wiki/Year_2038_problem

2 years agoAuto merge of #96816 - GuillaumeGomez:rollup-oumn95i, r=GuillaumeGomez
bors [Sat, 7 May 2022 13:31:04 +0000 (13:31 +0000)]
Auto merge of #96816 - GuillaumeGomez:rollup-oumn95i, r=GuillaumeGomez

Rollup of 7 pull requests

Successful merges:

 - #96581 (make Size and Align debug-printing a bit more compact)
 - #96636 (Fix jump to def regression)
 - #96760 (diagnostics: port more diagnostics to derive + add support for `Vec` fields)
 - #96788 (Improve validator around field projections and checked bin ops)
 - #96805 (Change eslint rules from configuration comments to configuration file)
 - #96807 (update Miri)
 - #96811 (Fix a minor typo in the description of Formatter)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #96811 - createyourpersonalaccount:doc-typofix, r=JohnTitor
Guillaume Gomez [Sat, 7 May 2022 13:23:50 +0000 (15:23 +0200)]
Rollup merge of #96811 - createyourpersonalaccount:doc-typofix, r=JohnTitor

Fix a minor typo in the description of Formatter

2 years agoRollup merge of #96807 - RalfJung:miri, r=RalfJung
Guillaume Gomez [Sat, 7 May 2022 13:23:49 +0000 (15:23 +0200)]
Rollup merge of #96807 - RalfJung:miri, r=RalfJung

update Miri

Fixes https://github.com/rust-lang/rust/issues/96773
r? ``@ghost``

2 years agoRollup merge of #96805 - Folyd:eslint, r=GuillaumeGomez
Guillaume Gomez [Sat, 7 May 2022 13:23:48 +0000 (15:23 +0200)]
Rollup merge of #96805 - Folyd:eslint, r=GuillaumeGomez

Change eslint rules from configuration comments to configuration file

Repeatedly declaring eslint rules in source files is an annoying thing, we should move those rules into the eslint configuration file.

r? ``@GuillaumeGomez``

2 years agoRollup merge of #96788 - JakobDegen:checked-binop, r=oli-obk
Guillaume Gomez [Sat, 7 May 2022 13:23:47 +0000 (15:23 +0200)]
Rollup merge of #96788 - JakobDegen:checked-binop, r=oli-obk

Improve validator around field projections and checked bin ops

The two commits are unrelated. In both cases, these rules were already documented in MIR docs.

2 years agoRollup merge of #96760 - davidtwco:diagnostic-translation-vec, r=oli-obk
Guillaume Gomez [Sat, 7 May 2022 13:23:46 +0000 (15:23 +0200)]
Rollup merge of #96760 - davidtwco:diagnostic-translation-vec, r=oli-obk

diagnostics: port more diagnostics to derive + add support for `Vec` fields

- Port "unconstrained opaque type" diagnostic to using the derive.
- Allow `Vec` fields in diagnostic derive - enables support for diagnostics that have multiple primary spans, or have subdiagnostics repeated at multiple locations. `Vec<..>` fields in the diagnostic derive become loops in the generated code.
- Add `create_{err,warning}` - there wasn't a way to create a diagnostic from a struct and not emit it straight away.
- Port "explicit generic args w/ impl trait" diagnostic to using the derive.

r? `````@oli-obk`````
cc `````@pvdrz`````

2 years agoRollup merge of #96636 - GuillaumeGomez:fix-jump-to-def-regression, r=notriddle
Guillaume Gomez [Sat, 7 May 2022 13:23:45 +0000 (15:23 +0200)]
Rollup merge of #96636 - GuillaumeGomez:fix-jump-to-def-regression, r=notriddle

Fix jump to def regression

https://github.com/rust-lang/rust/pull/93803 introduced a regression in the "jump to def" feature. This fixes it.

Nice side-effect: it adds a new regression test. :)

I also used this opportunity to add documentation about this unstable feature in the rustdoc book.

cc ``@cjgillot``
r? ``@notriddle``

2 years agoRollup merge of #96581 - RalfJung:debug-size-align, r=oli-obk
Guillaume Gomez [Sat, 7 May 2022 13:23:44 +0000 (15:23 +0200)]
Rollup merge of #96581 - RalfJung:debug-size-align, r=oli-obk

make Size and Align debug-printing a bit more compact

In particular in `{:#?}`-mode, these take up a lot of space, so I think this is the better alternative (even though it is a bit longer in `{:?}` mode, I think it is still more readable).

We could make it even smaller by deviating further from what the actual code looks like, e.g. via something like `Size(4 bytes)`. Not sure what people would think about that?

Cc `````@oli-obk`````

2 years agoFix a minor typo in the description of Formatter
Nikolaos Chatzikonstantinou [Sat, 7 May 2022 10:32:54 +0000 (19:32 +0900)]
Fix a minor typo in the description of Formatter

2 years agoAuto merge of #96780 - Kobzol:ci-llvm-upgrade-osx-windows, r=Mark-Simulacrum
bors [Sat, 7 May 2022 09:11:12 +0000 (09:11 +0000)]
Auto merge of #96780 - Kobzol:ci-llvm-upgrade-osx-windows, r=Mark-Simulacrum

Update LLVM version used to build OS X and Windows artifacts to 14.0.2

Let's see what breaks.

r? `@Mark-Simulacrum`

2 years agoupdate Miri
Ralf Jung [Sat, 7 May 2022 08:14:16 +0000 (10:14 +0200)]
update Miri

2 years agoAuto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errors
bors [Sat, 7 May 2022 06:30:29 +0000 (06:30 +0000)]
Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errors

Begin fixing all the broken doctests in `compiler/`

Begins to fix #95994.
All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are.
There are also a few that I marked `ignore` that could maybe be made to work but seem less important.
Each `ignore` has a rough "reason" for ignoring after it parentheses, with

- `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax"
- `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy.
- `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR.
- `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup.

Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful.

I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool

2 years agoAuto merge of #96804 - compiler-errors:rollup-1mc6aw3, r=compiler-errors
bors [Sat, 7 May 2022 04:15:52 +0000 (04:15 +0000)]
Auto merge of #96804 - compiler-errors:rollup-1mc6aw3, r=compiler-errors

Rollup of 8 pull requests

Successful merges:

 - #96660 ([bootstrap] Give a better error when trying to run a path with no registered step)
 - #96701 (update `jemallocator` example to use 2018 edition import syntax)
 - #96746 (Fix an ICE on #96738)
 - #96758 (bootstrap: bsd platform flags for split debuginfo)
 - #96778 (Remove closures on `expect_local` to apply `#[track_caller]`)
 - #96781 (Fix an incorrect link in The Unstable Book)
 - #96783 (Link to correct issue in issue-95034 known-bug)
 - #96801 (Add regression test for #96319)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #96801 - Aaron1011:coinductive-cycle-test, r=compiler-errors
Michael Goulet [Sat, 7 May 2022 03:49:37 +0000 (20:49 -0700)]
Rollup merge of #96801 - Aaron1011:coinductive-cycle-test, r=compiler-errors

Add regression test for #96319

2 years agoRollup merge of #96783 - aliemjay:typo-issue-95034, r=compiler-errors
Michael Goulet [Sat, 7 May 2022 03:49:36 +0000 (20:49 -0700)]
Rollup merge of #96783 - aliemjay:typo-issue-95034, r=compiler-errors

Link to correct issue in issue-95034 known-bug

fix a typo is issue number: 94034 -> 95034

2 years agoRollup merge of #96781 - koic:fix_an_incorrect_link_in_the_unstable_book, r=ehuss
Michael Goulet [Sat, 7 May 2022 03:49:35 +0000 (20:49 -0700)]
Rollup merge of #96781 - koic:fix_an_incorrect_link_in_the_unstable_book, r=ehuss

Fix an incorrect link in The Unstable Book

https://github.com/rust-lang/rust/blob/master/src/librustc_session/lint/builtin.rs returns page not found.

The following is the background of the move.
First https://github.com/rust-lang/rust/pull/74862 moves from src/librustc_session/lint/builtin.rs to compiler/rustc_session/src/lint/builtin.rs.
Then https://github.com/rust-lang/rust/commit/23018a5 moves from compiler/rustc_session/src/lint/builtin.rs to compiler/rustc_lint_defs/src/builtin.rs.

So, the current correct link is https://github.com/rust-lang/rust/blob/master/compiler/rustc_lint_defs/src/builtin.rs.

This PR fixes a broken link on the following page:
https://doc.rust-lang.org/beta/unstable-book/language-features/plugin.html

2 years agoRollup merge of #96778 - JohnTitor:expect-local-track-caller-take-2, r=petrochenkov
Michael Goulet [Sat, 7 May 2022 03:49:35 +0000 (20:49 -0700)]
Rollup merge of #96778 - JohnTitor:expect-local-track-caller-take-2, r=petrochenkov

Remove closures on `expect_local` to apply `#[track_caller]`

Pointed out in https://github.com/rust-lang/rust/pull/96747#discussion_r866576196
Didn't change `expect_non_local` as I'm not sure if it's also the case.
r? ``@petrochenkov``

2 years agoRollup merge of #96758 - davidtwco:split-debuginfo-bootstrap-bsd, r=Mark-Simulacrum
Michael Goulet [Sat, 7 May 2022 03:49:34 +0000 (20:49 -0700)]
Rollup merge of #96758 - davidtwco:split-debuginfo-bootstrap-bsd, r=Mark-Simulacrum

bootstrap: bsd platform flags for split debuginfo

Addresses https://github.com/rust-lang/rust/pull/96597#issuecomment-1118905025.

Bootstrap currently provides `-Zunstable-options` for OpenBSD when using split debuginfo - this commit provides it for all BSD targets.

We should probably work out a better way of handling the stability of the split debuginfo flag - all options for the flag are unstable but one of them is the default for each platform already.

cc `@m-ou-se`
r? `@Mark-Simulacrum`

2 years agoRollup merge of #96746 - JohnTitor:issue-96738, r=petrochenkov
Michael Goulet [Sat, 7 May 2022 03:49:32 +0000 (20:49 -0700)]
Rollup merge of #96746 - JohnTitor:issue-96738, r=petrochenkov

Fix an ICE on #96738

In the block we don't know if the method actually exists thus `expect_local` panics.
Fixes #96738
Fixes #96583

2 years agoRollup merge of #96701 - kraktus:alloc_example_2018_edition, r=Mark-Simulacrum
Michael Goulet [Sat, 7 May 2022 03:49:31 +0000 (20:49 -0700)]
Rollup merge of #96701 - kraktus:alloc_example_2018_edition, r=Mark-Simulacrum

update `jemallocator` example to use 2018 edition import syntax

2 years agoRollup merge of #96660 - jyn514:better-missing-path-error, r=Mark-Simulacrum
Michael Goulet [Sat, 7 May 2022 03:49:30 +0000 (20:49 -0700)]
Rollup merge of #96660 - jyn514:better-missing-path-error, r=Mark-Simulacrum

[bootstrap] Give a better error when trying to run a path with no registered step

Before:
```
thread 'main' panicked at 'error: no rules matched invalid', src/bootstrap/builder.rs:287:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

After:
```
error: no `check` rules matched 'invalid'
help: run `x.py check --help --verbose` to show a list of available paths
note: if you are adding a new Step to bootstrap itself, make sure you register it with `describe!`
```

2 years agoChange eslint rules from configuration comments to configuration files
Folyd [Sat, 7 May 2022 03:47:30 +0000 (11:47 +0800)]
Change eslint rules from configuration comments to configuration files

2 years agoAdd regression test for #96319
Aaron Hill [Sat, 7 May 2022 02:28:22 +0000 (22:28 -0400)]
Add regression test for #96319

2 years agoAuto merge of #96531 - kckeiks:remove-item-like-visitor-from-rustc-typeck, r=cjgillot
bors [Sat, 7 May 2022 01:59:11 +0000 (01:59 +0000)]
Auto merge of #96531 - kckeiks:remove-item-like-visitor-from-rustc-typeck, r=cjgillot

Remove ItemLikeVisitor impls from rustc_typeck

Issue #95004
cc `@cjgillot`

2 years agoAuto merge of #96458 - Aaron1011:no-cycle-caching, r=jackh726,cjgillot
bors [Fri, 6 May 2022 22:41:16 +0000 (22:41 +0000)]
Auto merge of #96458 - Aaron1011:no-cycle-caching, r=jackh726,cjgillot

Don't cache results of coinductive cycle

2 years agoCheck that field projections have the correct type
Jakob Degen [Fri, 6 May 2022 20:09:59 +0000 (16:09 -0400)]
Check that field projections have the correct type

2 years agoAuto merge of #96785 - GuillaumeGomez:rollup-rgiwa57, r=GuillaumeGomez
bors [Fri, 6 May 2022 20:14:01 +0000 (20:14 +0000)]
Auto merge of #96785 - GuillaumeGomez:rollup-rgiwa57, r=GuillaumeGomez

Rollup of 10 pull requests

Successful merges:

 - #96557 (Allow inline consts to reference generic params)
 - #96590 (rustdoc: when running a function-signature search, tweak the tab bar)
 - #96650 (Collect function instance used in `global_asm!` sym operand)
 - #96733 (turn `append_place_to_string` from recursion into iteration)
 - #96748 (Fixes reexports in search)
 - #96752 (Put the incompatible_closure_captures lint messages in alphabetical order)
 - #96754 (rustdoc: ensure HTML/JS side implementors don't have dups)
 - #96772 (Suggest fully qualified path with appropriate params)
 - #96776 (Fix two minor issues in hir.rs)
 - #96782 (a small `mirror_expr` cleanup)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoAdd rustdoc documentation about unstable feature "jump to def"
Guillaume Gomez [Mon, 2 May 2022 13:11:15 +0000 (15:11 +0200)]
Add rustdoc documentation about unstable feature "jump to def"

2 years agoAdd regression test for jump-to-def
Guillaume Gomez [Mon, 2 May 2022 13:07:11 +0000 (15:07 +0200)]
Add regression test for jump-to-def

2 years agoRemove unneeded SpanMapVisitor::visit_generics function
Guillaume Gomez [Fri, 6 May 2022 19:54:31 +0000 (21:54 +0200)]
Remove unneeded SpanMapVisitor::visit_generics function

2 years agoExpand validator to be more precise on checked binary ops
Jakob Degen [Fri, 6 May 2022 01:15:20 +0000 (21:15 -0400)]
Expand validator to be more precise on checked binary ops

2 years agoShare more unix SystemTime code
Josh Stone [Fri, 6 May 2022 18:45:59 +0000 (11:45 -0700)]
Share more unix SystemTime code

2 years agoRollup merge of #96782 - lcnr:mirror-expr, r=compiler-errors
Guillaume Gomez [Fri, 6 May 2022 18:05:45 +0000 (20:05 +0200)]
Rollup merge of #96782 - lcnr:mirror-expr, r=compiler-errors

a small `mirror_expr` cleanup

2 years agoRollup merge of #96776 - liuw:hir, r=oli-obk
Guillaume Gomez [Fri, 6 May 2022 18:05:45 +0000 (20:05 +0200)]
Rollup merge of #96776 - liuw:hir, r=oli-obk

Fix two minor issues in hir.rs

I found these two places in hir.rs which could use a bit of improvements while going through the code.

No functional change.

2 years agoRollup merge of #96772 - TaKO8Ki:suggest-fully-qualified-path-with-appropriate-params...
Guillaume Gomez [Fri, 6 May 2022 18:05:44 +0000 (20:05 +0200)]
Rollup merge of #96772 - TaKO8Ki:suggest-fully-qualified-path-with-appropriate-params, r=compiler-errors

Suggest fully qualified path with appropriate params

closes #96291

2 years agoRollup merge of #96754 - notriddle:notriddle/impl-dups, r=GuillaumeGomez
Guillaume Gomez [Fri, 6 May 2022 18:05:43 +0000 (20:05 +0200)]
Rollup merge of #96754 - notriddle:notriddle/impl-dups, r=GuillaumeGomez

rustdoc: ensure HTML/JS side implementors don't have dups

Fixes #94641

Rendered:

- https://notriddle.com/notriddle-rustdoc-test/impl-dups/std/iter/trait.Iterator.html
- https://notriddle.com/notriddle-rustdoc-test/impl-dups/core/iter/trait.Iterator.html

2 years agoRollup merge of #96752 - scottmcm:error-sorting, r=compiler-errors
Guillaume Gomez [Fri, 6 May 2022 18:05:42 +0000 (20:05 +0200)]
Rollup merge of #96752 - scottmcm:error-sorting, r=compiler-errors

Put the incompatible_closure_captures lint messages in alphabetical order

Looks like they were in hash order before, which was causing me trouble in #94598, so this PR sorts the errors by trait name.

2 years agoRollup merge of #96748 - GuillaumeGomez:reexports-in-search, r=notriddle
Guillaume Gomez [Fri, 6 May 2022 18:05:41 +0000 (20:05 +0200)]
Rollup merge of #96748 - GuillaumeGomez:reexports-in-search, r=notriddle

Fixes reexports in search

Fixes #96681.

At some point we stopped reexporting items in search so this PR fixes it.

It also adds a regression test.

r? ```@notriddle```

2 years agoRollup merge of #96733 - SparrowLii:place_to_string, r=davidtwco
Guillaume Gomez [Fri, 6 May 2022 18:05:40 +0000 (20:05 +0200)]
Rollup merge of #96733 - SparrowLii:place_to_string, r=davidtwco

turn `append_place_to_string` from recursion into iteration

This PR fixes the FIXME in the impl of `append_place_to_string` which turns `append_place_to_string` from recursion into iteration, meanwhile simplifying the code relatively.

2 years agoRollup merge of #96650 - tmiasko:global-asm-sym-fn, r=Amanieu
Guillaume Gomez [Fri, 6 May 2022 18:05:39 +0000 (20:05 +0200)]
Rollup merge of #96650 - tmiasko:global-asm-sym-fn, r=Amanieu

Collect function instance used in `global_asm!` sym operand

The constants used in SymFn operands have FnDef type,
so the type of the constant identifies the function.

Fixes #96623.

2 years agoRollup merge of #96590 - notriddle:notriddle/tab-bar-fn-search, r=GuillaumeGomez...
Guillaume Gomez [Fri, 6 May 2022 18:05:38 +0000 (20:05 +0200)]
Rollup merge of #96590 - notriddle:notriddle/tab-bar-fn-search, r=GuillaumeGomez,jsha

rustdoc: when running a function-signature search, tweak the tab bar

# Before

![In Names (7) / In Parameters (0) / In Return types (0)](https://user-images.githubusercontent.com/1593513/166122875-ffdeafe6-8d4d-4e61-84a6-f5986b50ac35.png)

# After

![In Function Signature (7)](https://user-images.githubusercontent.com/1593513/166122883-9a3d7515-3235-4ee3-8c4b-5401d109e099.png)

2 years agoRollup merge of #96557 - nbdd0121:const, r=oli-obk
Guillaume Gomez [Fri, 6 May 2022 18:05:37 +0000 (20:05 +0200)]
Rollup merge of #96557 - nbdd0121:const, r=oli-obk

Allow inline consts to reference generic params

Tracking issue: #76001

The RFC says that inline consts cannot reference to generic parameters (for now), same as array length expressions. And expresses that it's desirable for it to reference in-scope generics, when array length expressions gain that feature as well.

However it is possible to implement this for inline consts before doing this for all anon consts, because inline consts are only used as values and they won't be used in the type system. So we can have:
```rust
fn foo<T>() {
    let x = [4i32; std::mem::size_of::<T>()];   // NOT ALLOWED (for now)
    let x = const { std::mem::size_of::<T>() }; // ALLOWED with this PR!
    let x = [4i32; const { std::mem::size_of::<T>() }];   // NOT ALLOWED (for now)
}
```

This would make inline consts super useful for compile-time checks and assertions:
```rust
fn assert_zst<T>() {
    const { assert!(std::mem::size_of::<T>() == 0) };
}
```

This would create an error during monomorphization when `assert_zst` is instantiated with non-ZST `T`s. A error during mono might sound scary, but this is exactly what a "desugared" inline const would do:
```rust
fn assert_zst<T>() {
    struct F<T>(T);
    impl<T> F<T> {
        const V: () = assert!(std::mem::size_of::<T>() == 0);
    }
    let _ = F::<T>::V;
}
```

It should also be noted that the current inline const implementation can already reference the type params via type inference, so this resolver-level restriction is not any useful either:
```rust
fn foo<T>() -> usize {
    let (_, size): (PhantomData<T>, usize) = const {
        const fn my_size_of<T>() -> (PhantomData<T>, usize) {
            (PhantomData, std::mem::size_of::<T>())
        }
        my_size_of()
    };
    size
}
```

```@rustbot``` label: F-inline_const

2 years agoAuto merge of #95454 - randomicon00:fix95444, r=wesleywiser
bors [Fri, 6 May 2022 17:52:47 +0000 (17:52 +0000)]
Auto merge of #95454 - randomicon00:fix95444, r=wesleywiser

Fixing #95444 by only displaying passes that take more than 5 millise…

As discussed in #95444, I have added the code to test and only display prints that are greater than 5 milliseconds.

r? `@jyn514`

2 years agoLink to correct issue in issue-95034 test
Ali MJ Al-Nasrawy [Fri, 6 May 2022 17:35:06 +0000 (20:35 +0300)]
Link to correct issue in issue-95034 test

2 years agoFix an incorrect link in The Unstable Book
Koichi ITO [Fri, 6 May 2022 16:21:40 +0000 (01:21 +0900)]
Fix an incorrect link in The Unstable Book

https://github.com/rust-lang/rust/blob/master/src/librustc_session/lint/builtin.rs
returns page not found.

The following is the background of the move.
First https://github.com/rust-lang/rust/pull/74862 moves from src/librustc_session/lint/builtin.rs
to compiler/rustc_session/src/lint/builtin.rs
Then https://github.com/rust-lang/rust/commit/23018a5 moves from compiler/rustc_session/src/lint/builtin.rs
to compiler/rustc_lint_defs/src/builtin.rs

So, the current correct link is https://github.com/rust-lang/rust/blob/master/compiler/rustc_lint_defs/src/builtin.rs

This PR fixes a broken link on the following page:
https://doc.rust-lang.org/beta/unstable-book/language-features/plugin.html

2 years ago`mirror_expr` cleanup
lcnr [Fri, 6 May 2022 17:00:37 +0000 (19:00 +0200)]
`mirror_expr` cleanup

2 years agoUpdate LLVM version used to build OS X and Windows artifacts to 14.0.2
Jakub Beránek [Fri, 6 May 2022 16:25:27 +0000 (18:25 +0200)]
Update LLVM version used to build OS X and Windows artifacts to 14.0.2

2 years agoRemove closures on `expect_local` to apply `#[track_caller]`
Yuki Okushi [Fri, 6 May 2022 16:11:32 +0000 (01:11 +0900)]
Remove closures on `expect_local` to apply `#[track_caller]`

2 years agoremove all usages of hir().def_kind
Miguel Guarniz [Fri, 29 Apr 2022 20:45:48 +0000 (16:45 -0400)]
remove all usages of hir().def_kind

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2 years agouse def_span and def_kind queries instead of calling tcx.hir() methods
Miguel Guarniz [Fri, 29 Apr 2022 17:11:22 +0000 (13:11 -0400)]
use def_span and def_kind queries instead of calling tcx.hir() methods

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2 years agopass ItemId to check_item_type instead of Item
Miguel Guarniz [Fri, 29 Apr 2022 17:09:03 +0000 (13:09 -0400)]
pass ItemId to check_item_type instead of Item

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2 years agoremove ImplWfCheck
Miguel Guarniz [Fri, 29 Apr 2022 16:26:15 +0000 (12:26 -0400)]
remove ImplWfCheck

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2 years agoremove CheckItemTypesVisitor
Miguel Guarniz [Fri, 29 Apr 2022 16:24:39 +0000 (12:24 -0400)]
remove CheckItemTypesVisitor

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2 years agouse hir_module_items in check_mod_item_types query
Miguel Guarniz [Fri, 29 Apr 2022 16:22:40 +0000 (12:22 -0400)]
use hir_module_items in check_mod_item_types query

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2 years agouse hir_module_items instead of visit_all_item_likes in check_mod_impl_wf query
Miguel Guarniz [Fri, 29 Apr 2022 15:57:01 +0000 (11:57 -0400)]
use hir_module_items instead of visit_all_item_likes in check_mod_impl_wf query

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2 years agoremove UnsafetyChecker
Miguel Guarniz [Thu, 28 Apr 2022 17:34:49 +0000 (13:34 -0400)]
remove UnsafetyChecker

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2 years agoremove ItemLikeVisitor impl for InherentOverlapChecker
Miguel Guarniz [Thu, 28 Apr 2022 17:03:17 +0000 (13:03 -0400)]
remove ItemLikeVisitor impl for InherentOverlapChecker

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2 years agoremove ItemLikeVisitor impl for InherentCollect
Miguel Guarniz [Thu, 28 Apr 2022 15:00:12 +0000 (11:00 -0400)]
remove ItemLikeVisitor impl for InherentCollect

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2 years agoremove OutlivesTest
Miguel Guarniz [Thu, 28 Apr 2022 14:47:13 +0000 (10:47 -0400)]
remove OutlivesTest

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2 years agoremove VarianceTest
Miguel Guarniz [Thu, 28 Apr 2022 02:03:57 +0000 (22:03 -0400)]
remove VarianceTest

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2 years agouse DefKind::Fn instead of DefKind::AsscFn for foreign items
Miguel Guarniz [Thu, 28 Apr 2022 01:52:51 +0000 (21:52 -0400)]
use DefKind::Fn instead of DefKind::AsscFn for foreign items

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2 years agoremove ItemLikeVisitor impl for TermsContext
Miguel Guarniz [Thu, 28 Apr 2022 00:14:53 +0000 (20:14 -0400)]
remove ItemLikeVisitor impl for TermsContext

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2 years agoremove ItemLikeVisitor impl for ContraintContext
Miguel Guarniz [Wed, 27 Apr 2022 21:22:58 +0000 (17:22 -0400)]
remove ItemLikeVisitor impl for ContraintContext

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2 years agoUse statx's 64-bit times on 32-bit linux-gnu
Josh Stone [Thu, 10 Mar 2022 01:05:16 +0000 (17:05 -0800)]
Use statx's 64-bit times on 32-bit linux-gnu

2 years agoUse __clock_gettime64 on 32-bit linux-gnu
Josh Stone [Wed, 9 Mar 2022 20:41:47 +0000 (12:41 -0800)]
Use __clock_gettime64 on 32-bit linux-gnu

2 years agounix: always use 64-bit Timespec
Josh Stone [Wed, 9 Mar 2022 20:25:46 +0000 (12:25 -0800)]
unix: always use 64-bit Timespec

2 years agoAlso suggest calling constructors for external DefIds
Yuki Okushi [Fri, 6 May 2022 15:43:50 +0000 (00:43 +0900)]
Also suggest calling constructors for external DefIds

2 years agoUse matches! for YieldSource::is_await
Wei Liu [Fri, 6 May 2022 15:00:48 +0000 (15:00 +0000)]
Use matches! for YieldSource::is_await

2 years agoFix comment for async closure variant
Wei Liu [Fri, 6 May 2022 14:59:40 +0000 (14:59 +0000)]
Fix comment for async closure variant

2 years agoAuto merge of #95183 - ibraheemdev:arc-count-acquire, r=Amanieu
bors [Fri, 6 May 2022 14:53:24 +0000 (14:53 +0000)]
Auto merge of #95183 - ibraheemdev:arc-count-acquire, r=Amanieu

Weaken needlessly restrictive orderings on `Arc::*_count`

There is no apparent reason for these to be `SeqCst`. For reference, [the Boost C++ implementation relies on acquire semantics](https://github.com/boostorg/smart_ptr/blob/f2cc84a23c64b8a73c9b72b34799d0854d7e0787/include/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp#L137-L140).

2 years agosuggest fully qualified path with appropriate params
Takayuki Maeda [Fri, 6 May 2022 14:14:11 +0000 (23:14 +0900)]
suggest fully qualified path with appropriate params

2 years agoAuto merge of #96268 - jackh726:remove-mutable_borrow_reservation_conflict-lint,...
bors [Fri, 6 May 2022 12:32:44 +0000 (12:32 +0000)]
Auto merge of #96268 - jackh726:remove-mutable_borrow_reservation_conflict-lint, r=nikomatsakis

Remove mutable_borrow_reservation_conflict lint and allow the code pattern

This was the only breaking issue with the NLL stabilization PR. Lang team decided to go ahead and allow this.

r? `@nikomatsakis`
Closes #59159
Closes #56254

2 years agoAdd missing newline
Michael Howell [Fri, 6 May 2022 12:18:32 +0000 (05:18 -0700)]
Add missing newline

2 years agoAdd GUI test for search reexports
Guillaume Gomez [Thu, 5 May 2022 19:56:40 +0000 (21:56 +0200)]
Add GUI test for search reexports

2 years agoFix reexports missing from the search index
Guillaume Gomez [Thu, 5 May 2022 19:56:03 +0000 (21:56 +0200)]
Fix reexports missing from the search index

2 years agoAuto merge of #94598 - scottmcm:prefix-free-hasher-methods, r=Amanieu
bors [Fri, 6 May 2022 09:43:57 +0000 (09:43 +0000)]
Auto merge of #94598 - scottmcm:prefix-free-hasher-methods, r=Amanieu

Add a dedicated length-prefixing method to `Hasher`

This accomplishes two main goals:
- Make it clear who is responsible for prefix-freedom, including how they should do it
- Make it feasible for a `Hasher` that *doesn't* care about Hash-DoS resistance to get better performance by not hashing lengths

This does not change rustc-hash, since that's in an external crate, but that could potentially use it in future.

Fixes #94026

r? rust-lang/libs

---

The core of this change is the following two new methods on `Hasher`:

```rust
pub trait Hasher {
    /// Writes a length prefix into this hasher, as part of being prefix-free.
    ///
    /// If you're implementing [`Hash`] for a custom collection, call this before
    /// writing its contents to this `Hasher`.  That way
    /// `(collection![1, 2, 3], collection![4, 5])` and
    /// `(collection![1, 2], collection![3, 4, 5])` will provide different
    /// sequences of values to the `Hasher`
    ///
    /// The `impl<T> Hash for [T]` includes a call to this method, so if you're
    /// hashing a slice (or array or vector) via its `Hash::hash` method,
    /// you should **not** call this yourself.
    ///
    /// This method is only for providing domain separation.  If you want to
    /// hash a `usize` that represents part of the *data*, then it's important
    /// that you pass it to [`Hasher::write_usize`] instead of to this method.
    ///
    /// # Examples
    ///
    /// ```
    /// #![feature(hasher_prefixfree_extras)]
    /// # // Stubs to make the `impl` below pass the compiler
    /// # struct MyCollection<T>(Option<T>);
    /// # impl<T> MyCollection<T> {
    /// #     fn len(&self) -> usize { todo!() }
    /// # }
    /// # impl<'a, T> IntoIterator for &'a MyCollection<T> {
    /// #     type Item = T;
    /// #     type IntoIter = std::iter::Empty<T>;
    /// #     fn into_iter(self) -> Self::IntoIter { todo!() }
    /// # }
    ///
    /// use std::hash::{Hash, Hasher};
    /// impl<T: Hash> Hash for MyCollection<T> {
    ///     fn hash<H: Hasher>(&self, state: &mut H) {
    ///         state.write_length_prefix(self.len());
    ///         for elt in self {
    ///             elt.hash(state);
    ///         }
    ///     }
    /// }
    /// ```
    ///
    /// # Note to Implementers
    ///
    /// If you've decided that your `Hasher` is willing to be susceptible to
    /// Hash-DoS attacks, then you might consider skipping hashing some or all
    /// of the `len` provided in the name of increased performance.
    #[inline]
    #[unstable(feature = "hasher_prefixfree_extras", issue = "88888888")]
    fn write_length_prefix(&mut self, len: usize) {
        self.write_usize(len);
    }

    /// Writes a single `str` into this hasher.
    ///
    /// If you're implementing [`Hash`], you generally do not need to call this,
    /// as the `impl Hash for str` does, so you can just use that.
    ///
    /// This includes the domain separator for prefix-freedom, so you should
    /// **not** call `Self::write_length_prefix` before calling this.
    ///
    /// # Note to Implementers
    ///
    /// The default implementation of this method includes a call to
    /// [`Self::write_length_prefix`], so if your implementation of `Hasher`
    /// doesn't care about prefix-freedom and you've thus overridden
    /// that method to do nothing, there's no need to override this one.
    ///
    /// This method is available to be overridden separately from the others
    /// as `str` being UTF-8 means that it never contains `0xFF` bytes, which
    /// can be used to provide prefix-freedom cheaper than hashing a length.
    ///
    /// For example, if your `Hasher` works byte-by-byte (perhaps by accumulating
    /// them into a buffer), then you can hash the bytes of the `str` followed
    /// by a single `0xFF` byte.
    ///
    /// If your `Hasher` works in chunks, you can also do this by being careful
    /// about how you pad partial chunks.  If the chunks are padded with `0x00`
    /// bytes then just hashing an extra `0xFF` byte doesn't necessarily
    /// provide prefix-freedom, as `"ab"` and `"ab\u{0}"` would likely hash
    /// the same sequence of chunks.  But if you pad with `0xFF` bytes instead,
    /// ensuring at least one padding byte, then it can often provide
    /// prefix-freedom cheaper than hashing the length would.
    #[inline]
    #[unstable(feature = "hasher_prefixfree_extras", issue = "88888888")]
    fn write_str(&mut self, s: &str) {
        self.write_length_prefix(s.len());
        self.write(s.as_bytes());
    }
}
```

With updates to the `Hash` implementations for slices and containers to call `write_length_prefix` instead of `write_usize`.

`write_str` defaults to using `write_length_prefix` since, as was pointed out in the issue, the `write_u8(0xFF)` approach is insufficient for hashers that work in chunks, as those would hash `"a\u{0}"` and `"a"` to the same thing.  But since `SipHash` works byte-wise (there's an internal buffer to accumulate bytes until a full chunk is available) it overrides `write_str` to continue to use the add-non-UTF-8-byte approach.

---

Compatibility:

Because the default implementation of `write_length_prefix` calls `write_usize`, the changed hash implementation for slices will do the same thing the old one did on existing `Hasher`s.

2 years agobless mir-opt
Ralf Jung [Fri, 6 May 2022 08:58:54 +0000 (10:58 +0200)]
bless mir-opt

2 years agodon't debug-print ConstValue in MIR pretty-printer
Ralf Jung [Fri, 6 May 2022 08:30:29 +0000 (10:30 +0200)]
don't debug-print ConstValue in MIR pretty-printer

2 years agomake Size and Align debug-printing a bit more compact
Ralf Jung [Sat, 30 Apr 2022 16:30:11 +0000 (18:30 +0200)]
make Size and Align debug-printing a bit more compact

2 years agoAuto merge of #96510 - m-ou-se:futex-bsd, r=Amanieu
bors [Fri, 6 May 2022 07:20:04 +0000 (07:20 +0000)]
Auto merge of #96510 - m-ou-se:futex-bsd, r=Amanieu

Use futex-based locks and thread parker on {Free, Open, DragonFly}BSD.

This switches *BSD to our futex-based locks and thread parker.

Tracking issue: https://github.com/rust-lang/rust/issues/93740

This is a draft, because this still needs a new version of the `libc` crate to be published that includes https://github.com/rust-lang/libc/pull/2770.

r? `@Amanieu`

2 years agofix unmatched braces
Elliot Roberts [Fri, 6 May 2022 07:17:02 +0000 (00:17 -0700)]
fix unmatched braces

2 years agoFor now, don't change the details of hashing a `str`
Scott McMurray [Fri, 6 May 2022 06:18:11 +0000 (23:18 -0700)]
For now, don't change the details of hashing a `str`

We might want to change the default before stabilizing (or maybe even after), but for getting in the new unstable methods, leave it as-is for now.  That way it won't break cargo and such.

2 years agoAdd a dedicated length-prefixing method to `Hasher`
Scott McMurray [Fri, 4 Mar 2022 08:17:26 +0000 (00:17 -0800)]
Add a dedicated length-prefixing method to `Hasher`

This accomplishes two main goals:
- Make it clear who is responsible for prefix-freedom, including how they should do it
- Make it feasible for a `Hasher` that *doesn't* care about Hash-DoS resistance to get better performance by not hashing lengths

This does not change rustc-hash, since that's in an external crate, but that could potentially use it in future.

2 years agoAuto merge of #96759 - compiler-errors:rollup-p4jtm92, r=compiler-errors
bors [Fri, 6 May 2022 04:56:23 +0000 (04:56 +0000)]
Auto merge of #96759 - compiler-errors:rollup-p4jtm92, r=compiler-errors

Rollup of 7 pull requests

Successful merges:

 - #96174 (mark ptr-int-transmute test as no_run)
 - #96639 (Fix typo in `offset_from` documentation)
 - #96704 (Add rotation animation on settings button when loading)
 - #96730 (Add a regression test for #64173 and #66152)
 - #96741 (Improve settings loading strategy)
 - #96744 (Implement [OsStr]::join)
 - #96747 (Add `track_caller` to `DefId::expect_local()`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoturn `append_place_to_string` from recursion into iteration
SparrowLii [Fri, 6 May 2022 04:11:42 +0000 (12:11 +0800)]
turn `append_place_to_string` from recursion into iteration

2 years agotypeck: port "explicit generic args w/ impl trait"
David Wood [Fri, 6 May 2022 02:46:12 +0000 (03:46 +0100)]
typeck: port "explicit generic args w/ impl trait"

Port the "explicit generic arguments with impl trait" diagnostic to
using the diagnostic derive.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agosess: add `create_{err,warning}`
David Wood [Fri, 6 May 2022 02:44:41 +0000 (03:44 +0100)]
sess: add `create_{err,warning}`

Currently, the only API for creating errors from a diagnostic derive
will emit it immediately. This makes it difficult to add subdiagnostics
to diagnostics from the derive, so add `create_{err,warning}` functions
that return the diagnostic without emitting it.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agomacros: allow `Vec` fields in diagnostic derive
David Wood [Fri, 6 May 2022 02:43:30 +0000 (03:43 +0100)]
macros: allow `Vec` fields in diagnostic derive

Diagnostics can have multiple primary spans, or have subdiagnostics
repeated at multiple locations, so support `Vec<..>` fields in the
diagnostic derive which become loops in the generated code.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoRollup merge of #96747 - JohnTitor:expect-local-track-caller, r=compiler-errors
Michael Goulet [Fri, 6 May 2022 02:34:27 +0000 (19:34 -0700)]
Rollup merge of #96747 - JohnTitor:expect-local-track-caller, r=compiler-errors

Add `track_caller` to `DefId::expect_local()`

Suggested in https://github.com/rust-lang/rust/issues/96738#issuecomment-1118961888.
`DefId::expect_local()` often causes ICEs (panics) and should be a good candidate to add `track_caller`.

2 years agoRollup merge of #96744 - est31:join_osstr, r=thomcc
Michael Goulet [Fri, 6 May 2022 02:34:26 +0000 (19:34 -0700)]
Rollup merge of #96744 - est31:join_osstr, r=thomcc

Implement [OsStr]::join

Implements join for `OsStr` and `OsString` slices:

```Rust
    let strings = [OsStr::new("hello"), OsStr::new("dear"), OsStr::new("world")];
    assert_eq!("hello dear world", strings.join(OsStr::new(" ")));
````

This saves one from converting to strings and back, or from implementing it manually.

2 years agoRollup merge of #96741 - GuillaumeGomez:improve-settings-loading-strategy, r=jsha
Michael Goulet [Fri, 6 May 2022 02:34:25 +0000 (19:34 -0700)]
Rollup merge of #96741 - GuillaumeGomez:improve-settings-loading-strategy, r=jsha

Improve settings loading strategy

I learned about this thanks to ```@jsha``` who suggested this approach:

It improves the settings loading strategy by loading CSS and JS at the same time to prevent the style to be applied afterwards on slow connections.

r? ```@jsha```

2 years agoRollup merge of #96730 - JohnTitor:unused-lifetimes-tests, r=compiler-errors
Michael Goulet [Fri, 6 May 2022 02:34:25 +0000 (19:34 -0700)]
Rollup merge of #96730 - JohnTitor:unused-lifetimes-tests, r=compiler-errors

Add a regression test for #64173 and #66152

Closes #64173
Closes #66152

Mixed the code as the root cause seems the same.