]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAuto merge of #96210 - nnethercote:speed-up-TokenCursor, r=petrochenkov
bors [Thu, 21 Apr 2022 15:42:50 +0000 (15:42 +0000)]
Auto merge of #96210 - nnethercote:speed-up-TokenCursor, r=petrochenkov

Speed up `TokenCursor`

Plus a few related clean-ups.

r? `@petrochenkov`

2 years agoAuto merge of #96003 - aswild:pr/bootstrap-subcommands-cleanup, r=jyn514
bors [Thu, 21 Apr 2022 10:38:43 +0000 (10:38 +0000)]
Auto merge of #96003 - aswild:pr/bootstrap-subcommands-cleanup, r=jyn514

bootstrap: consolidate subcommand parsing and matching

There's several places where the x.py command names are matched as
strings, leading to some inconsistencies and opportunities for cleanup.

* Add Format, Clean, and Setup variants to builder::Kind.
* Use Kind to parse the x.py subcommand name (including aliases)
* Match on the subcommand Kind rather than strings when handling
  options and help text.
* Several subcommands don't display any paths when run with `-h -v` even
  though the help text indicates that they should. Fix this and refactor
  so that manually keeping matches in sync isn't necessary.

Fixes #95937

2 years agoAuto merge of #95828 - vacuus:rustdoc-print-where-clause, r=notriddle
bors [Thu, 21 Apr 2022 08:12:38 +0000 (08:12 +0000)]
Auto merge of #95828 - vacuus:rustdoc-print-where-clause, r=notriddle

rustdoc: Clean up `html::format::print_where_clause`

(Arguably) closes https://github.com/rust-lang/rust/issues/95814

2 years agoAuto merge of #95612 - davidtwco:split-debuginfo-in-bootstrap, r=Mark-Simulacrum
bors [Thu, 21 Apr 2022 05:24:48 +0000 (05:24 +0000)]
Auto merge of #95612 - davidtwco:split-debuginfo-in-bootstrap, r=Mark-Simulacrum

bootstrap: add split-debuginfo config

Replace `run-dysutil` option with more general `split-debuginfo` option that works on all platforms.

r? `@Mark-Simulacrum`

2 years agoIntroduced `Cursor::next_with_spacing_ref`.
Nicholas Nethercote [Thu, 21 Apr 2022 03:49:40 +0000 (13:49 +1000)]
Introduced `Cursor::next_with_spacing_ref`.

This lets us clone just the parts within a `TokenTree` that need
cloning, rather than the entire thing. This is a surprisingly large
performance win, up to 4% on `async-std-1.10.0`.

2 years agoProduce `CloseDelim` and pop the stack at the same time.
Nicholas Nethercote [Thu, 21 Apr 2022 02:26:58 +0000 (12:26 +1000)]
Produce `CloseDelim` and pop the stack at the same time.

This makes `CloseDelim` handling more like `OpenDelim` handling, which
produces `OpenDelim` and pushes the stack at the same time. It requires
some adjustment to `parse_token_tree` now that we don't remain within
the frame after getting the `CloseDelim`.

2 years agoAuto merge of #96263 - Dylan-DPC:rollup-0eofl13, r=Dylan-DPC
bors [Thu, 21 Apr 2022 02:16:32 +0000 (02:16 +0000)]
Auto merge of #96263 - Dylan-DPC:rollup-0eofl13, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #90630 (Create real parser for search queries)
 - #96193 ([fuchsia] Add implementation for `current_exe`)
 - #96196 (Remove assertion that all paths in `ShouldRun` exist)
 - #96228 (Fix locations for intrinsics impls and change to links)
 - #96236 (Add an explicit `Span` field to `OutlivesConstraint`)

Failed merges:

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

2 years agorustdoc: Clean up `html::format::print_where_clause`
Roc Yu [Thu, 21 Apr 2022 00:45:30 +0000 (20:45 -0400)]
rustdoc: Clean up `html::format::print_where_clause`

2 years agoAuto merge of #96254 - RalfJung:miri, r=RalfJung
bors [Wed, 20 Apr 2022 23:51:40 +0000 (23:51 +0000)]
Auto merge of #96254 - RalfJung:miri, r=RalfJung

update Miri

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

2 years agoAvoid some tuple destructuring.
Nicholas Nethercote [Wed, 20 Apr 2022 06:34:33 +0000 (16:34 +1000)]
Avoid some tuple destructuring.

Surprisingly, this is a non-trivial performance win.

2 years agoRollup merge of #96236 - Aaron1011:constraint-debug, r=jackh726
Dylan DPC [Wed, 20 Apr 2022 23:14:17 +0000 (01:14 +0200)]
Rollup merge of #96236 - Aaron1011:constraint-debug, r=jackh726

Add an explicit `Span` field to `OutlivesConstraint`

Previously, we would retrieve the span from the `Body` using
the `locations` field. However, we may end up changing the
`locations` field when moving a constraint from a promoted
to a different body.

We now store the original `Span` in a dedication field, so that
changes to the `locations` do not affect the quality of our
diagnostics.

2 years agoRollup merge of #96228 - mbartlett21:patch-4, r=thomcc
Dylan DPC [Wed, 20 Apr 2022 23:14:16 +0000 (01:14 +0200)]
Rollup merge of #96228 - mbartlett21:patch-4, r=thomcc

Fix locations for intrinsics impls and change to links

These still referred to `rustc_mir`.

2 years agoRollup merge of #96196 - jyn514:no-assertion, r=Mark-Simulacrum
Dylan DPC [Wed, 20 Apr 2022 23:14:15 +0000 (01:14 +0200)]
Rollup merge of #96196 - jyn514:no-assertion, r=Mark-Simulacrum

Remove assertion that all paths in `ShouldRun` exist

This breaks on submodules (see #96188). Disable the assertion for now until I can think of a proper
fix.

This doesn't revert any of the changes in `Step`s themselves, only what
`ShouldRun::paths` does.

2 years agoRollup merge of #96193 - djkoloski:fuchsia_current_exe, r=tmandry
Dylan DPC [Wed, 20 Apr 2022 23:14:14 +0000 (01:14 +0200)]
Rollup merge of #96193 - djkoloski:fuchsia_current_exe, r=tmandry

[fuchsia] Add implementation for `current_exe`

This implementation returns a best attempt at the current exe path. On
fuchsia, fdio will always use `argv[0]` as the process name and if it is
not set then an error will be returned. Because this is not guaranteed
to be the case, this implementation returns an error if `argv` does not
contain any elements.

2 years agoRollup merge of #90630 - GuillaumeGomez:improve-rustdoc-search, r=notriddle
Dylan DPC [Wed, 20 Apr 2022 23:14:13 +0000 (01:14 +0200)]
Rollup merge of #90630 - GuillaumeGomez:improve-rustdoc-search, r=notriddle

Create real parser for search queries

You can test it [here](https://rustdoc.crud.net/imperio/improve-rustdoc-search/std/index.html).

This PR adds a real parser for the query engine in rustdoc. The parser is quite simple but it allows to makes query handling much easier. I added a new testsuite to ensure it works as expected and ran fuzzing checks on it for a few hours without problems.

So about the parser: as you can see in the screenshot, it handles recursive generics parsing. It also allows to set which item should use exact matching by adding double-quotes around it (look for `exact_search` in the screenshot).

Now about the query engine itself: I simplified it a lot thanks to the parsed query. It behaves mostly the same when there is only one argument, but is much more powerful when there are more than one.

When making this change, we also removed the support for multi-query.

PS: A big part of the PR is tests and test-related code. :)

r? `@camelid`

2 years agoupdate Miri
Ralf Jung [Wed, 20 Apr 2022 19:13:41 +0000 (15:13 -0400)]
update Miri

2 years agoAuto merge of #96187 - GuillaumeGomez:potential-intra-doc-links-filtering, r=notriddle
bors [Wed, 20 Apr 2022 21:32:01 +0000 (21:32 +0000)]
Auto merge of #96187 - GuillaumeGomez:potential-intra-doc-links-filtering, r=notriddle

Prevent `<>` links to be interpreted for intra-doc links

As discussed in [this thread](https://github.com/rust-lang/rust/pull/96135#discussion_r852107956). As mentioned, the intra-doc RFC states that `<>` links shouldn't be potential intra-doc links:  https://rust-lang.github.io/rfcs/1946-intra-rustdoc-links.html#no-autolinks-style.

I renamed `markdown_links` into `potential_intra_doc_markdown_links` to make it more obvious what it's doing.

cc `@petrochenkov`
r? `@notriddle`

2 years agoExtend `handleSingleArg` documentation
Guillaume Gomez [Wed, 20 Apr 2022 19:11:39 +0000 (21:11 +0200)]
Extend `handleSingleArg` documentation

2 years agoAuto merge of #96253 - Dylan-DPC:rollup-87hpds5, r=Dylan-DPC
bors [Wed, 20 Apr 2022 18:40:13 +0000 (18:40 +0000)]
Auto merge of #96253 - Dylan-DPC:rollup-87hpds5, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #93313 (Check if call return type is visibly uninhabited when building MIR)
 - #96160 (Miri/interpreter debugging tweaks)
 - #96167 (Replace sys/unix/weak AtomicUsize with AtomicPtr)
 - #96168 (Improve AddrParseError description)
 - #96206 (Use sys::unix::locks::futex* on wasm+atomics.)
 - #96234 (remove_dir_all_recursive: treat ELOOP the same as ENOTDIR)

Failed merges:

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

2 years agoRemove `<>` links to be potential intra-doc links
Guillaume Gomez [Wed, 20 Apr 2022 18:11:18 +0000 (20:11 +0200)]
Remove `<>` links to be potential intra-doc links

2 years agoRollup merge of #96234 - goffrie:eloop, r=thomcc
Dylan DPC [Wed, 20 Apr 2022 16:26:06 +0000 (18:26 +0200)]
Rollup merge of #96234 - goffrie:eloop, r=thomcc

remove_dir_all_recursive: treat ELOOP the same as ENOTDIR

On older Linux kernels (I tested on 4.4, corresponding to Ubuntu 16.04), opening a symlink using `O_DIRECTORY | O_NOFOLLOW` returns `ELOOP` instead of `ENOTDIR`. We should handle it the same, since a symlink is still not a directory and needs to be `unlink`ed.

2 years agoRollup merge of #96206 - m-ou-se:wasm-futex-locks, r=alexcrichton
Dylan DPC [Wed, 20 Apr 2022 16:26:05 +0000 (18:26 +0200)]
Rollup merge of #96206 - m-ou-se:wasm-futex-locks, r=alexcrichton

Use sys::unix::locks::futex* on wasm+atomics.

This removes the wasm-specific lock implementations and instead re-uses the implementations from sys::unix.

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

cc ``@alexcrichton``

2 years agoRollup merge of #96168 - chris-morgan:AddrParseError-description-improvements, r...
Dylan DPC [Wed, 20 Apr 2022 16:26:04 +0000 (18:26 +0200)]
Rollup merge of #96168 - chris-morgan:AddrParseError-description-improvements, r=joshtriplett

Improve AddrParseError description

The existing description was incorrect for socket addresses, and misleading: users would see “invalid IP address syntax” and suppose they were supposed to provide an IP address rather than a socket address.

I contemplated making it two variants (IP, socket), but realised we can do still better for the IPv4 and IPv6 types, so here it is as six.

I contemplated more precise error descriptions (e.g. “invalid IPv6 socket address syntax: expected a decimal scope ID after %”), but that’s a more invasive change, and probably not worthwhile anyway.

2 years agoRollup merge of #96167 - CAD97:weak-dlsym-less-ptr-crime, r=thomcc
Dylan DPC [Wed, 20 Apr 2022 16:26:03 +0000 (18:26 +0200)]
Rollup merge of #96167 - CAD97:weak-dlsym-less-ptr-crime, r=thomcc

Replace sys/unix/weak AtomicUsize with AtomicPtr

Should fix #96163. Can't easily test on Windows though...

2 years agoRollup merge of #96160 - RalfJung:interpret-debug, r=oli-obk
Dylan DPC [Wed, 20 Apr 2022 16:26:02 +0000 (18:26 +0200)]
Rollup merge of #96160 - RalfJung:interpret-debug, r=oli-obk

Miri/interpreter debugging tweaks

Some changes I made to make debugging Miri with trace logging less terrible.

r? ``@oli-obk``

2 years agoRollup merge of #93313 - tmiasko:uninhabited, r=tmandry
Dylan DPC [Wed, 20 Apr 2022 16:26:01 +0000 (18:26 +0200)]
Rollup merge of #93313 - tmiasko:uninhabited, r=tmandry

Check if call return type is visibly uninhabited when building MIR

The main motivation behind the change is to expose information about diverging
calls to the generator transform and match the precision of drop range tracking
which already understands that call expressions with visibly uninhabited types
diverges.

This change should also accept strictly more programs than before. That is
programs that were previously rejected due to errors raised by control-flow
sensitive checks in a code that is no longer considered reachable.

Fixes #93161.

2 years agoAuto merge of #96250 - ehuss:update-cargo, r=ehuss
bors [Wed, 20 Apr 2022 16:15:54 +0000 (16:15 +0000)]
Auto merge of #96250 - ehuss:update-cargo, r=ehuss

Update cargo

7 commits in dba5baf4345858c591517b24801902a062c399f8..edffc4ada3d77799e5a04eeafd9b2f843d29fc23
2022-04-13 21:58:27 +0000 to 2022-04-19 17:38:29 +0000
- Document cargo-add (rust-lang/cargo#10578)
- feat: Support '-F' as an alias for '--features' (rust-lang/cargo#10576)
- Completion support for `cargo-add` (rust-lang/cargo#10577)
- Add a link to the document in the timings report (rust-lang/cargo#10492)
- feat: Import cargo-add into cargo (rust-lang/cargo#10472)
- Part 8 of RFC2906 - Keep `InheritableFields` in a `LazyCell` inside `… (rust-lang/cargo#10568)
- Part 7 of RFC2906 - Add support for inheriting `exclude` and `include` (rust-lang/cargo#10565)

2 years agoUpdate cargo
Eric Huss [Wed, 20 Apr 2022 13:50:39 +0000 (06:50 -0700)]
Update cargo

2 years agoAuto merge of #96135 - petrochenkov:doclink6, r=GuillaumeGomez
bors [Wed, 20 Apr 2022 13:34:48 +0000 (13:34 +0000)]
Auto merge of #96135 - petrochenkov:doclink6, r=GuillaumeGomez

rustdoc: Optimize and refactor doc link resolution

One more subset of https://github.com/rust-lang/rust/pull/94857 that should bring perf improvements rather than regressions + a couple more optimizations on top of it.
It's better to read individual commits and their descriptions to understand the changes.
The `may_have_doc_links` optimization is not *very* useful here, but it's much more important for https://github.com/rust-lang/rust/pull/94857.

Closes https://github.com/rust-lang/rust/issues/96079

2 years agoAuto merge of #96022 - martingms:inline-const-getters, r=nnethercote
bors [Wed, 20 Apr 2022 11:12:55 +0000 (11:12 +0000)]
Auto merge of #96022 - martingms:inline-const-getters, r=nnethercote

Inline `ty::Const::ty()` and `ty::Const::val()` getters

These were not inlined into `super_relate_consts`, which is one of the hottest functions in a callgrind profile of compiling `bitmaps-3.1.0`.

Yields some small speedups across various benchmarks locally:

#### Primary benchmarks

Benchmark | Profile | Scenario | % Change | Significance Factor?
-- | -- | -- | -- | --
unicode-normalization-0.1.19 | check | full | -0.56% | 2.78x
unicode-normalization-0.1.19 | check | incr-full | -0.43% | 2.15x
unicode-normalization-0.1.19 | opt | full | -0.35% | 1.77x
unicode-normalization-0.1.19 | debug | incr-full | -0.31% | 1.56x
unicode-normalization-0.1.19 | debug | full | -0.30% | 1.51x

#### Secondary benchmarks

Benchmark | Profile | Scenario | % Change | Significance Factor?
-- | -- | -- | -- | --
bitmaps-3.1.0 | check | full | -1.88% | 9.39x
bitmaps-3.1.0 | debug | full | -1.79% | 8.96x
bitmaps-3.1.0 | opt | full | -1.69% | 8.43x
bitmaps-3.1.0 | check | incr-full | -1.54% | 7.68x
bitmaps-3.1.0 | debug | incr-full | -1.45% | 7.27x
bitmaps-3.1.0 | opt | incr-full | -1.39% | 6.96x
tt-muncher | opt | full | 1.28% | 6.38x
nalgebra-0.30.1 | check | full | -0.96% | 4.81x
nalgebra-0.30.1 | debug | full | -0.91% | 4.54x
nalgebra-0.30.1 | opt | full | -0.90% | 4.52x
nalgebra-0.30.1 | check | incr-full | -0.77% | 3.86x
nalgebra-0.30.1 | opt | incr-full | -0.76% | 3.79x
nalgebra-0.30.1 | debug | incr-full | -0.74% | 3.72x
hex-0.4.3 | check | full | -0.70% | 3.50x
hex-0.4.3 | debug | full | -0.59% | 2.95x
hex-0.4.3 | check | incr-full | -0.56% | 2.80x
hex-0.4.3 | opt | full | -0.56% | 2.78x
wf-projection-stress-65510 | opt | full | -0.48% | 2.42x
hex-0.4.3 | opt | incr-full | -0.48% | 2.40x
hex-0.4.3 | debug | incr-full | -0.45% | 2.24x
wf-projection-stress-65510 | check | full | -0.44% | 2.18x
wf-projection-stress-65510 | debug | full | -0.42% | 2.08x
wf-projection-stress-65510 | check | incr-full | -0.40% | 2.01x
deep-vector | debug | incr-patched: add vec item | -0.38% | 1.88x
wf-projection-stress-65510 | debug | incr-full | -0.37% | 1.86x
wf-projection-stress-65510 | opt | incr-full | -0.36% | 1.81x
deep-vector | debug | incr-patched: println | 0.33% | 1.63x

r? `@nnethercote`

2 years agoRemove `Eof` sanity check in `Parser::inlined_bump_with`.
Nicholas Nethercote [Wed, 20 Apr 2022 04:52:54 +0000 (14:52 +1000)]
Remove `Eof` sanity check in `Parser::inlined_bump_with`.

A Google search of the error message fails to return any relevant
resuts, suggesting this has never occurred in practice. And removeing it
reduces instruction counts by up to 2% on some benchmarks.

2 years agoInline `Parser::nonterminal_may_begin_with`.
Nicholas Nethercote [Wed, 20 Apr 2022 04:13:49 +0000 (14:13 +1000)]
Inline `Parser::nonterminal_may_begin_with`.

2 years agoInline `Parser::parse_nonterminal`.
Nicholas Nethercote [Wed, 20 Apr 2022 04:08:59 +0000 (14:08 +1000)]
Inline `Parser::parse_nonterminal`.

2 years agoOnly record `fallback_span` when necessary.
Nicholas Nethercote [Wed, 20 Apr 2022 04:04:22 +0000 (14:04 +1000)]
Only record `fallback_span` when necessary.

2 years agoAuto merge of #96082 - michaelwoerister:less_impl_stable_hash_via_hash, r=compiler...
bors [Wed, 20 Apr 2022 03:51:09 +0000 (03:51 +0000)]
Auto merge of #96082 - michaelwoerister:less_impl_stable_hash_via_hash, r=compiler-errors

incr. comp.: Don't export impl_stable_hash_via_hash!() and warn about using it.

Fixes https://github.com/rust-lang/rust/issues/96013.

2 years agoAdd an explicit `Span` field to `OutlivesConstraint`
Aaron Hill [Wed, 20 Apr 2022 00:53:35 +0000 (20:53 -0400)]
Add an explicit `Span` field to `OutlivesConstraint`

Previously, we would retrieve the span from the `Body` using
the `locations` field. However, we may end up changing the
`locations` field when moving a constraint from a promoted
to a different body.

We now store the original `Span` in a dedication field, so that
changes to the `locations` do not affect the quality of our
diagnostics.

2 years agoChange file locations to be links to GitHub
mbartlett21 [Wed, 20 Apr 2022 03:14:32 +0000 (13:14 +1000)]
Change file locations to be links to GitHub

2 years agoInline `Cursor::next_with_spacing`.
Nicholas Nethercote [Wed, 20 Apr 2022 02:43:25 +0000 (12:43 +1000)]
Inline `Cursor::next_with_spacing`.

2 years agoRemove the loop from `Parser::bump()`.
Nicholas Nethercote [Wed, 20 Apr 2022 02:22:42 +0000 (12:22 +1000)]
Remove the loop from `Parser::bump()`.

The loop is there to handle a `NoDelim` open/close token. This commit
changes `TokenCursor::inlined_next` so it never returns such a token.
This is a performance win because the conditional test in `bump()` is
removed.

If the parser needs changing in the future to handle `NoDelim` tokens,
then `inlined_next()` can easily be changed to return them.

2 years agoRemove `TokenCursorFrame::open_delim`.
Nicholas Nethercote [Wed, 20 Apr 2022 02:22:03 +0000 (12:22 +1000)]
Remove `TokenCursorFrame::open_delim`.

Because it's now always true.

2 years agoUse `true` for `open_delim`/`close_delim` in one spot.
Nicholas Nethercote [Wed, 20 Apr 2022 01:49:15 +0000 (11:49 +1000)]
Use `true` for `open_delim`/`close_delim` in one spot.

The `DelimToken` here is `NoDelim`, which means the returned delim
tokens will just be ignored by `Parser::bump()`. This commit changes
things so the delim tokens won't be returned.

2 years agobootstrap: non-bootstrap windows split debuginfo
David Wood [Tue, 19 Apr 2022 02:32:30 +0000 (03:32 +0100)]
bootstrap: non-bootstrap windows split debuginfo

Temporarily, only enable split debuginfo on Windows if not building with
the boostrap compiler as there is a bug that isn't fixed in the
bootstrap compiler which would result in `thorin` being run on Windows.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoAdd a size assertion for `Parser`.
Nicholas Nethercote [Tue, 19 Apr 2022 23:31:34 +0000 (09:31 +1000)]
Add a size assertion for `Parser`.

2 years agoAuto merge of #96224 - Dylan-DPC:rollup-h2h3j93, r=Dylan-DPC
bors [Wed, 20 Apr 2022 01:34:43 +0000 (01:34 +0000)]
Auto merge of #96224 - Dylan-DPC:rollup-h2h3j93, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #95740 (asm: Add a kreg0 register class on x86 which includes k0)
 - #95813 (Remove extra space before a where clause)
 - #96029 (Refactor loop into iterator; simplify negation logic.)
 - #96162 (interpret: Fix writing uninit to an allocation)
 - #96165 (Miri provenance cleanup)
 - #96205 (Use futex locks on emscripten.)

Failed merges:

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

2 years agoremove_dir_all_recursive: treat ELOOP the same as ENOTDIR
Geoffry Song [Wed, 20 Apr 2022 00:46:50 +0000 (00:46 +0000)]
remove_dir_all_recursive: treat ELOOP the same as ENOTDIR

2 years agoFix locations for intrinsics impls
mbartlett21 [Tue, 19 Apr 2022 23:28:07 +0000 (09:28 +1000)]
Fix locations for intrinsics impls

2 years agoMove desugaring code into its own function.
Nicholas Nethercote [Tue, 19 Apr 2022 07:01:26 +0000 (17:01 +1000)]
Move desugaring code into its own function.

It's not hot, so shouldn't be within the always inlined part.

2 years agoRollup merge of #96205 - m-ou-se:emscripten-futex-locks, r=thomcc
Dylan DPC [Tue, 19 Apr 2022 20:57:44 +0000 (22:57 +0200)]
Rollup merge of #96205 - m-ou-se:emscripten-futex-locks, r=thomcc

Use futex locks on emscripten.

This switches Emscripten to the futex-based lock implementations, away from pthread.

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

2 years agoRollup merge of #96165 - RalfJung:miri-provenance-cleanup, r=oli-obk
Dylan DPC [Tue, 19 Apr 2022 20:57:43 +0000 (22:57 +0200)]
Rollup merge of #96165 - RalfJung:miri-provenance-cleanup, r=oli-obk

Miri provenance cleanup

Reviewing https://github.com/rust-lang/rust/pull/95826 by ``@carbotaniuman`` made me realize that we could clean things up a little here.

``@carbotaniuman`` please let me know if you're okay with landing this (it will create a lot of conflicts with your PR), or if you'd prefer incorporating the ideas from this PR into yours. I think we want to end up in a situation where the function you called `ptr_reify_alloc` returns just two things, a concrete tag and an offset. Getting an `AllocId` from a concrete tag should be infallible like now. However a concrete tag and `Tag` don't have to be the same type.

r? ``@oli-obk``

2 years agoRollup merge of #96162 - RalfJung:mark-uninit, r=oli-obk
Dylan DPC [Tue, 19 Apr 2022 20:57:42 +0000 (22:57 +0200)]
Rollup merge of #96162 - RalfJung:mark-uninit, r=oli-obk

interpret: Fix writing uninit to an allocation

When calling `mark_init`, we need to also be mindful of what happens with the relocations! Specifically, when we de-init memory, we need to clear relocations in that range as well or else strange things will happen (and printing will not show the de-init, since relocations take precedence there).

Fixes https://github.com/rust-lang/miri/issues/2068.

Here's the Miri testcase that this fixes (requires `-Zmiri-disable-validation`):
```rust
use std::mem::MaybeUninit;

fn main() { unsafe {
    let mut x = MaybeUninit::<i64>::uninit();
    // Put in a ptr.
    x.as_mut_ptr().cast::<&i32>().write_unaligned(&0);
    // Overwrite parts of that pointer with 'uninit' through a Scalar.
    let ptr = x.as_mut_ptr().cast::<i32>();
    *ptr = MaybeUninit::uninit().assume_init();
    // Reading this back should hence work fine.
    let _c = *ptr;
} }
```
Previously this failed with
```
error: unsupported operation: unable to turn pointer into raw bytes
  --> ../miri/uninit.rs:11:14
   |
11 |     let _c = *ptr;
   |              ^^^^ unable to turn pointer into raw bytes
   |
   = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support

   = note: inside `main` at ../miri/uninit.rs:11:14
```

2 years agoRollup merge of #96029 - IsakNyberg:error-messages-fix, r=Dylan-DPC
Dylan DPC [Tue, 19 Apr 2022 20:57:41 +0000 (22:57 +0200)]
Rollup merge of #96029 - IsakNyberg:error-messages-fix, r=Dylan-DPC

Refactor loop into iterator; simplify negation logic.

is_dummy should return when a non-dummy is found, but instead is iterated until completion. With some inspiration from line 323 this was refactored to a single line that returns once a single counterexample is found.

2 years agoRollup merge of #95813 - Urgau:rustdoc-where-clause-space, r=GuillaumeGomez
Dylan DPC [Tue, 19 Apr 2022 20:57:40 +0000 (22:57 +0200)]
Rollup merge of #95813 - Urgau:rustdoc-where-clause-space, r=GuillaumeGomez

Remove extra space before a where clause

Remove extra space before where clause in the generated documentation.

The fix is to move the space before the break-line so that it doesn't appear visually but is still here. Removing it completely would create things like this `impl<D> Delta<D>where D: MyTrait` (missing a space before the where) which I don't think we want.

Added two regression test, first one test that the `<br>` is after the space and the second check that the `<br>` is before the spaces.

Before:
![image](https://user-images.githubusercontent.com/3616612/162475212-d4bb6727-ed66-4a55-a4a2-4f55189bf8bd.png)

After:
![image](https://user-images.githubusercontent.com/3616612/162475467-508fd082-60a7-4a8c-b693-8b188e8843e6.png)

r? ``@GuillaumeGomez``

2 years agoRollup merge of #95740 - Amanieu:kreg0, r=nagisa
Dylan DPC [Tue, 19 Apr 2022 20:57:39 +0000 (22:57 +0200)]
Rollup merge of #95740 - Amanieu:kreg0, r=nagisa

asm: Add a kreg0 register class on x86 which includes k0

Previously we only exposed a kreg register class which excludes the k0
register since it can't be used in many instructions. However k0 is a
valid register and we need to have a way of marking it as clobbered for
clobber_abi.

Fixes #94977

2 years ago[fuchsia] Add implementation for `current_exe`
David Koloski [Mon, 18 Apr 2022 22:22:32 +0000 (18:22 -0400)]
[fuchsia] Add implementation for `current_exe`

This implementation returns a best attempt at the current exe path. On
fuchsia, fdio will always use `argv[0]` as the process name and if it is
not set then an error will be returned. Because this is not guaranteed
to be the case, this implementation returns an error if `argv` does not
contain any elements.

2 years agoAdd regression test for #96079
Guillaume Gomez [Tue, 19 Apr 2022 14:08:22 +0000 (16:08 +0200)]
Add regression test for #96079

2 years agorustdoc: Sligthly optimize `Attributes` construction and processing before doc link...
Vadim Petrochenkov [Sat, 16 Apr 2022 23:01:46 +0000 (02:01 +0300)]
rustdoc: Sligthly optimize `Attributes` construction and processing before doc link resolution

2 years agorustdoc: Cache preprocessed markdown links
Vadim Petrochenkov [Sat, 16 Apr 2022 20:59:21 +0000 (23:59 +0300)]
rustdoc: Cache preprocessed markdown links

2 years agorustdoc: Optimize and refactor doc link resolution
Vadim Petrochenkov [Sat, 16 Apr 2022 20:53:13 +0000 (23:53 +0300)]
rustdoc: Optimize and refactor doc link resolution

- Cache doc link resolutions obtained early
- Cache markdown links retrieved from doc strings early
- Rename and restructure the code in early doc link resolution to be closer to #94857

2 years agorustc_metadata: Store a flag telling whether an item may have doc links in its attributes
Vadim Petrochenkov [Sat, 16 Apr 2022 20:49:37 +0000 (23:49 +0300)]
rustc_metadata: Store a flag telling whether an item may have doc links in its attributes

This should be cheap on rustc side, but it's significant optimization for rustdoc that won't need to decode and process attributes unnecessarily

2 years agoproc_macro: Add a workaround for rustdoc
Vadim Petrochenkov [Tue, 1 Feb 2022 12:30:32 +0000 (20:30 +0800)]
proc_macro: Add a workaround for rustdoc

2 years agoasm: Add a kreg0 register class on x86 which includes k0
Amanieu d'Antras [Wed, 6 Apr 2022 19:41:12 +0000 (20:41 +0100)]
asm: Add a kreg0 register class on x86 which includes k0

Previously we only exposed a kreg register class which excludes the k0
register since it can't be used in many instructions. However k0 is a
valid register and we need to have a way of marking it as clobbered for
clobber_abi.

Fixes #94977

2 years agoAuto merge of #96214 - Dylan-DPC:rollup-a5b4fow, r=Dylan-DPC
bors [Tue, 19 Apr 2022 13:10:12 +0000 (13:10 +0000)]
Auto merge of #96214 - Dylan-DPC:rollup-a5b4fow, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #94493 (Improved diagnostic on failure to meet send bound on future in a foreign crate)
 - #95809 (Fix typo in bootstrap.py)
 - #96086 (Remove `--extern-location` and all associated code)
 - #96089 (`alloc`: make `vec!` unavailable under `no_global_oom_handling`)
 - #96122 (Fix an invalid error for a suggestion to add a slice in pattern-matching)
 - #96142 (Stop using CRATE_DEF_INDEX outside of metadata encoding.)

Failed merges:

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

2 years agoRollup merge of #96142 - cjgillot:no-crate-def-index, r=petrochenkov
Dylan DPC [Tue, 19 Apr 2022 12:43:21 +0000 (14:43 +0200)]
Rollup merge of #96142 - cjgillot:no-crate-def-index, r=petrochenkov

Stop using CRATE_DEF_INDEX outside of metadata encoding.

`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.  We should not manipulate raw `DefIndex` outside of metadata encoding.

2 years agoRollup merge of #96122 - TaKO8Ki:fix-invalid-error-for-suggestion-to-add-slice-in...
Dylan DPC [Tue, 19 Apr 2022 12:43:20 +0000 (14:43 +0200)]
Rollup merge of #96122 - TaKO8Ki:fix-invalid-error-for-suggestion-to-add-slice-in-pattern-matching, r=nagisa

Fix an invalid error for a suggestion to add a slice in pattern-matching

closes #96103

2 years agoRollup merge of #96089 - ojeda:no-vec-no_global_oom_handling, r=Mark-Simulacrum
Dylan DPC [Tue, 19 Apr 2022 12:43:19 +0000 (14:43 +0200)]
Rollup merge of #96089 - ojeda:no-vec-no_global_oom_handling, r=Mark-Simulacrum

`alloc`: make `vec!` unavailable under `no_global_oom_handling`

`alloc`: make `vec!` unavailable under `no_global_oom_handling`

The `vec!` macro has 3 rules, but two are not usable under
`no_global_oom_handling` builds of the standard library
(even with a zero size):

```rust
let _ = vec![42];    // Error: requires `exchange_malloc` lang_item.
let _ = vec![42; 0]; // Error: cannot find function `from_elem`.
```

Thus those two rules should not be available to begin with.

The remaining one, with an empty matcher, is just a shorthand for
`new()` and may not make as much sense to have alone, since the
idea behind `vec!` is to enable `Vec`s to be defined with the same
syntax as array expressions. Furthermore, the documentation can be
confusing since it shows the other rules.

Thus perhaps it is better and simpler to disable `vec!` entirely
under `no_global_oom_handling` environments, and let users call
`new()` instead:

```rust
let _: Vec<i32> = vec![];
let _: Vec<i32> = Vec::new();
```

Notwithstanding this, a `try_vec!` macro would be useful, such as
the one introduced in https://github.com/rust-lang/rust/pull/95051.

If the shorthand for `new()` is deemed worth keeping on its own,
then it may be interesting to have a separate `vec!` macro with
a single rule and different, simpler documentation.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2 years agoRollup merge of #96086 - jsgf:remove-extern-location, r=davidtwco
Dylan DPC [Tue, 19 Apr 2022 12:43:17 +0000 (14:43 +0200)]
Rollup merge of #96086 - jsgf:remove-extern-location, r=davidtwco

Remove `--extern-location` and all associated code

`--extern-location` was an experiment to investigate the best way to
generate useful diagnostics for unused dependency warnings by enabling a
build system to identify the corresponding build config.

While I did successfully use this, I've since been convinced the
alternative `--json unused-externs` mechanism is the way to go, and
there's no point in having two mechanisms with basically the same
functionality.

This effectively reverts https://github.com/rust-lang/rust/pull/72603

2 years agoRollup merge of #95809 - ytmimi:llvm_stamp_typo, r=Mark-Simulacrum
Dylan DPC [Tue, 19 Apr 2022 12:43:15 +0000 (14:43 +0200)]
Rollup merge of #95809 - ytmimi:llvm_stamp_typo, r=Mark-Simulacrum

Fix typo in bootstrap.py

2 years agoRollup merge of #94493 - oribenshir:feature/ISSUE-78543_async_fn_in_foreign_crate_dia...
Dylan DPC [Tue, 19 Apr 2022 12:43:15 +0000 (14:43 +0200)]
Rollup merge of #94493 - oribenshir:feature/ISSUE-78543_async_fn_in_foreign_crate_diag_2, r=davidtwco

Improved diagnostic on failure to meet send bound on future in a foreign crate

Provide a better diagnostic on failure to meet send bound on futures in a foreign crate.

fixes #78543

2 years agoAuto merge of #96020 - martingms:optimize-relate_substs, r=nnethercote
bors [Tue, 19 Apr 2022 10:53:53 +0000 (10:53 +0000)]
Auto merge of #96020 - martingms:optimize-relate_substs, r=nnethercote

Micro-optimize `ty::relate::relate_substs` by avoiding `match`

Was a top-20 hot function in a callgrind profile of compiling `bitmaps-3.1.0`.

Yields some small speedups on that crate and some others according to local benching:

Benchmark | Profile | Scenario | % Change | Significance Factor?
-- | -- | -- | -- | --
bitmaps-3.1.0 | check | full | -1.88% | 9.42x
bitmaps-3.1.0 | debug | full | -1.80% | 8.99x
bitmaps-3.1.0 | opt | full | -1.70% | 8.49x
bitmaps-3.1.0 | check | incr-full | -1.54% | 7.68x
deep-vector | debug | full | 1.52% | 7.61x
bitmaps-3.1.0 | debug | incr-full | -1.45% | 7.26x
bitmaps-3.1.0 | opt | incr-full | -1.39% | 6.95x
nalgebra-0.30.1 | check | full | -0.68% | 3.42x
nalgebra-0.30.1 | debug | full | -0.64% | 3.22x
nalgebra-0.30.1 | opt | full | -0.64% | 3.20x
projection-caching | check | full | -0.61% | 3.05x
nalgebra-0.30.1 | check | incr-full | -0.56% | 2.78x
nalgebra-0.30.1 | opt | incr-full | -0.54% | 2.72x
nalgebra-0.30.1 | debug | incr-full | -0.54% | 2.69x
projection-caching | check | incr-full | -0.50% | 2.51x
tt-muncher | opt | full | -0.48% | 2.42x
projection-caching | opt | full | -0.47% | 2.37x
projection-caching | debug | full | -0.47% | 2.35x
projection-caching | opt | incr-full | -0.44% | 2.21x
projection-caching | debug | incr-full | -0.42% | 2.08x
deeply-nested-multi | check | incr-full | 0.37% | 1.87x
wf-projection-stress-65510 | opt | full | -0.37% | 1.84x
deep-vector | debug | incr-patched: add vec item | -0.32% | 1.61x
projection-caching | debug | incr-unchanged | -0.32% | 1.60x
wf-projection-stress-65510 | check | full | -0.31% | 1.55x
projection-caching | opt | incr-unchanged | -0.31% | 1.53x
wf-projection-stress-65510 | debug | incr-full | -0.30% | 1.51x
wf-projection-stress-65510 | opt | incr-full | -0.30% | 1.51x

r? `@nnethercote`

2 years agoincr. comp.: Don't export impl_stable_hash_via_hash!() and warn about using it.
Michael Woerister [Tue, 19 Apr 2022 08:43:09 +0000 (10:43 +0200)]
incr. comp.: Don't export impl_stable_hash_via_hash!() and warn about using it.

2 years agoUse futex locks on emscripten.
Mara Bos [Tue, 19 Apr 2022 07:20:06 +0000 (09:20 +0200)]
Use futex locks on emscripten.

2 years agoUse futex locks on wasm+atomics.
Mara Bos [Tue, 19 Apr 2022 07:21:11 +0000 (09:21 +0200)]
Use futex locks on wasm+atomics.

2 years agoMake std::sys::wasm::futex consistent with unix::futex.
Mara Bos [Tue, 19 Apr 2022 07:20:51 +0000 (09:20 +0200)]
Make std::sys::wasm::futex consistent with unix::futex.

2 years agoMake std::sys::unix::futex consistent on emscripten.
Mara Bos [Tue, 19 Apr 2022 07:19:29 +0000 (09:19 +0200)]
Make std::sys::unix::futex consistent on emscripten.

2 years agoHandle `Delimited` opening immediately.
Nicholas Nethercote [Tue, 19 Apr 2022 03:53:05 +0000 (13:53 +1000)]
Handle `Delimited` opening immediately.

Instead of letting the next iteration of the loop handle it.

2 years agoAdd {open,close}_delim arguments to `TokenCursorFrame::new()`.
Nicholas Nethercote [Tue, 19 Apr 2022 03:51:12 +0000 (13:51 +1000)]
Add {open,close}_delim arguments to `TokenCursorFrame::new()`.

This will facilitate the change in the next commit.

`boolean` arguments aren't great, but the function is only used in three
places within this one file.

2 years agoRearrange `TokenCursor::inlined_next()`.
Nicholas Nethercote [Tue, 19 Apr 2022 03:41:02 +0000 (13:41 +1000)]
Rearrange `TokenCursor::inlined_next()`.

In particular, avoid wrapping a token within `TokenTree::Token` and then
immediately matching it and returning the token within. Just return the
token immediately.

2 years agoMerge `TokenCursor::{next,next_desugared}`.
Nicholas Nethercote [Tue, 19 Apr 2022 01:36:13 +0000 (11:36 +1000)]
Merge `TokenCursor::{next,next_desugared}`.

And likewise for the inlined variants.

I did this for simplicity, but interesting it was a performance win as
well.

2 years agoInline and remove `Parser::next_tok()`.
Nicholas Nethercote [Thu, 14 Apr 2022 01:13:20 +0000 (11:13 +1000)]
Inline and remove `Parser::next_tok()`.

It has a single call site.

2 years agoInline and remove `TokenTree::{open_tt,close_tt}`.
Nicholas Nethercote [Wed, 13 Apr 2022 06:18:01 +0000 (16:18 +1000)]
Inline and remove `TokenTree::{open_tt,close_tt}`.

They both have a single call site.

2 years agoTweak `Cursor::next_with_spacing`.
Nicholas Nethercote [Tue, 19 Apr 2022 04:15:30 +0000 (14:15 +1000)]
Tweak `Cursor::next_with_spacing`.

This makes it more like `CursorRef::next_with_spacing`. There is no
performance effect, just a consistency improvement.

2 years agoImprove AddrParseError description
Chris Morgan [Tue, 19 Apr 2022 03:02:20 +0000 (13:02 +1000)]
Improve AddrParseError description

The existing description was incorrect for socket addresses, and
misleading: users would see “invalid IP address syntax” and suppose they
were supposed to provide an IP address rather than a socket address.

I contemplated making it two variants (IP, socket), but realised we can
do still better for the IPv4 and IPv6 types, so here it is as six.

I contemplated more precise error descriptions (e.g. “invalid IPv6
socket address syntax: expected a decimal scope ID after %”), but that’s
a more invasive change, and probably not worthwhile anyway.

2 years agoAuto merge of #95379 - icewind1991:suggest-associated-type-more, r=jackh726
bors [Tue, 19 Apr 2022 01:59:35 +0000 (01:59 +0000)]
Auto merge of #95379 - icewind1991:suggest-associated-type-more, r=jackh726

show suggestion to replace generic bounds with associated types in more cases

Moves the hint to replace generic parameters with associated type bounds from the "not all associated type bounds are specified"(`E0191`) to "to many generic type parameters provided"(`E0107`).

Since `E0191` is only emitted in places where all associated types must be specified (when creating `dyn` types), the suggesting is currently not shown for other generic type uses (such as in generic type bounds). With this change the suggesting is always emitted when the number of excess generic parameters matches the number of unbound associated types.

Main motivation for the change was a lack of useful suggesting when doing

```rust
fn foo<I: Iterator<usize>>(i: I) {}
```

2 years agoRemove assertion that all paths in `ShouldRun` exist
Joshua Nelson [Tue, 19 Apr 2022 01:21:19 +0000 (20:21 -0500)]
Remove assertion that all paths in `ShouldRun` exist

This breaks on submodules (see #96188). Disable the assertion for now until I can think of a proper
fix.

This doesn't revert any of the changes in `Step`s themselves, only what
`ShouldRun::paths` does.

2 years agoAuto merge of #92287 - JulianKnodt:slice_remainder, r=yaahc
bors [Mon, 18 Apr 2022 23:34:24 +0000 (23:34 +0000)]
Auto merge of #92287 - JulianKnodt:slice_remainder, r=yaahc

Add slice::remainder

This adds a remainder function to the Slice iterator, so that a caller can access unused
elements if iteration stops.

Addresses #91733

2 years agoCorrectly handle single `:`
Guillaume Gomez [Mon, 18 Apr 2022 21:11:42 +0000 (23:11 +0200)]
Correctly handle single `:`

2 years agoAuto merge of #96171 - nikic:llvm-update-2, r=cuviper
bors [Mon, 18 Apr 2022 20:53:42 +0000 (20:53 +0000)]
Auto merge of #96171 - nikic:llvm-update-2, r=cuviper

Update LLVM submodule

Merge upstream release/14.x branch.

Fixes #94762.

2 years agoAdd test to ensure that keywords in path are working
Guillaume Gomez [Mon, 18 Apr 2022 19:05:21 +0000 (21:05 +0200)]
Add test to ensure that keywords in path are working

2 years agoAdd an extra check over filter type
Guillaume Gomez [Sun, 17 Apr 2022 10:05:31 +0000 (12:05 +0200)]
Add an extra check over filter type

2 years agoFix some corner cases
Guillaume Gomez [Sat, 16 Apr 2022 23:43:26 +0000 (01:43 +0200)]
Fix some corner cases

2 years agoAdd more tests for quote errors
Guillaume Gomez [Sat, 16 Apr 2022 14:33:54 +0000 (16:33 +0200)]
Add more tests for quote errors

2 years agoParse idents the same way in both quote string elements and "normal" elements
Guillaume Gomez [Sat, 16 Apr 2022 14:33:42 +0000 (16:33 +0200)]
Parse idents the same way in both quote string elements and "normal" elements

2 years agoRemove unnecessary `elem.name.length === 0` since the rustdoc search eBNF does not...
Guillaume Gomez [Sat, 16 Apr 2022 14:13:57 +0000 (16:13 +0200)]
Remove unnecessary `elem.name.length === 0` since the rustdoc search eBNF does not allow elements without a name

2 years agoAdd tests for paths
Guillaume Gomez [Fri, 8 Apr 2022 12:35:45 +0000 (14:35 +0200)]
Add tests for paths

2 years agoUpdate the eBNF to allow generics bracket to not be closed if it's EOF
Guillaume Gomez [Thu, 31 Mar 2022 09:36:23 +0000 (11:36 +0200)]
Update the eBNF to allow generics bracket to not be closed if it's EOF

2 years agoHandle separators in their own functions and fix missing handling of tabs
Guillaume Gomez [Wed, 30 Mar 2022 09:32:03 +0000 (11:32 +0200)]
Handle separators in their own functions and fix missing handling of tabs

2 years agoImprove the BNF description a bit and fix some issues
Guillaume Gomez [Mon, 28 Mar 2022 14:14:00 +0000 (16:14 +0200)]
Improve the BNF description a bit and fix some issues

2 years agoForbid rustdoc search query to end with ->
Guillaume Gomez [Mon, 28 Mar 2022 13:08:47 +0000 (15:08 +0200)]
Forbid rustdoc search query to end with ->

2 years agoAdd isIdentCharacter function to ensure that unexpected characters are handled correctly
Guillaume Gomez [Wed, 23 Mar 2022 16:26:32 +0000 (17:26 +0100)]
Add isIdentCharacter function to ensure that unexpected characters are handled correctly

2 years agoReplace unneeded use of regex with a simple if
Guillaume Gomez [Tue, 22 Mar 2022 10:22:09 +0000 (11:22 +0100)]
Replace unneeded use of regex with a simple if