Commit Graph

216925 Commits

Author SHA1 Message Date
Nicholas Nethercote 18f751df6a Simplify `with_tlv`. 2023-02-09 15:26:37 +11:00
Nicholas Nethercote f7b3e39502 Simplify `tls::enter_context`. 2023-02-09 15:25:45 +11:00
bors e7acd078f4 Auto merge of #107828 - compiler-errors:rollup-gyj6dgj, r=compiler-errors
Rollup of 9 pull requests

Successful merges:

 - #107317 (Implement `AsFd` and `AsRawFd` for `Rc`)
 - #107429 (Stabilize feature `cstr_from_bytes_until_nul`)
 - #107713 (Extend `BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE`.)
 - #107761 (Replace a command line flag with an env var to allow tools to initialize the tracing loggers at their own discretion)
 - #107790 ( x.py fails all downloads that use a tempdir with snap curl #107722)
 - #107799 (correctly update goals in the cache)
 - #107813 (Do not eagerly recover for bad `impl Trait` types in macros)
 - #107817 (rustdoc: use svgo to shrink `wheel.svg`)
 - #107819 (Set `rust-analyzer.check.invocationLocation` to `root`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-09 04:03:20 +00:00
Michael Goulet 3e07554fd7
Rollup merge of #107819 - clubby789:x-py-root, r=jyn514
Set `rust-analyzer.check.invocationLocation` to `root`

Add
```json
    "rust-analyzer.check.invocationLocation": "root",
    "rust-analyzer.check.invocationStrategy": "once",
```
to the bundled VS code config. This prevents an error with r-a invoking `python3 x.py` in `src/bootstrap` where `x.py` does not exist.

r? ``@jyn514``
2023-02-08 20:01:28 -08:00
Michael Goulet ae2ecff04b
Rollup merge of #107817 - notriddle:notriddle/wheel-svg, r=GuillaumeGomez
rustdoc: use svgo to shrink `wheel.svg`

use [svgo] to shrink `wheel.svg`

[svgo]: https://github.com/svg/svgo

    $ du -bs src/librustdoc/html/static/images/wheel.svg wheel-old.svg
    2972    src/librustdoc/html/static/images/wheel.svg
    3764    wheel-old.svg

100*((2972-3764)/3764) = -21.04%
2023-02-08 20:01:27 -08:00
Michael Goulet ab09405e99
Rollup merge of #107813 - compiler-errors:bad-impl-trait-in-macro-is-ok, r=estebank
Do not eagerly recover for bad `impl Trait` types in macros

Fixes #107796

cc #106712, ```@estebank``` and ```@Ezrashaw``` please make sure to use [`Parser::may_recover`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/parser/struct.Parser.html#method.may_recover) for all eager-token-consuming parser recoveries.

This also fixes a separate regression from #99915, that was introduced before we added `may_recover` though.
2023-02-08 20:01:26 -08:00
Michael Goulet 46c7c91ce7
Rollup merge of #107799 - lcnr:update-provisional-result, r=oli-obk
correctly update goals in the cache

we may want to actually write the response for our goal into the provisional or global cache instead of simply using the result from the last iteration '^^

r? ```@rust-lang/initiative-trait-system-refactor```
2023-02-08 20:01:26 -08:00
Michael Goulet 04ebaba17b
Rollup merge of #107790 - tharunsuresh-code:snap_curl, r=jyn514
x.py fails all downloads that use a tempdir with snap curl #107722

Have used the open() library from python to capture the binary output of the curl command and write it to a file using stdout of the subprocess. Added a single-line comment mentioning the redirect operator.
2023-02-08 20:01:25 -08:00
Michael Goulet 32bb73eede
Rollup merge of #107761 - oli-obk:miri_🪵, r=TaKO8Ki
Replace a command line flag with an env var to allow tools to initialize the tracing loggers at their own discretion

fixes https://github.com/rust-lang/miri/issues/2778

this was introduced in https://github.com/rust-lang/rust/pull/104645, so this PR reverts the flag-part and uses an env var instead.
2023-02-08 20:01:25 -08:00
Michael Goulet 04f770839d
Rollup merge of #107713 - nnethercote:extend-BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE, r=RalfJung
Extend `BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE`.

To temporarily allow a `str` field in a packed struct using `derive`, along with `[u8]`.

r? ``@RalfJung``
2023-02-08 20:01:25 -08:00
Michael Goulet aee4570adf
Rollup merge of #107429 - tgross35:from-bytes-until-null-stabilization, r=dtolnay
Stabilize feature `cstr_from_bytes_until_nul`

This PR seeks to stabilize `cstr_from_bytes_until_nul`.

Partially addresses #95027

This function has only been on nightly for about 10 months, but I think it is simple enough that there isn't harm discussing stabilization. It has also had at least a handful of mentions on both the user forum and the discord, so it seems like it's already in use or at least known.

This needs FCP still.

Comment on potential discussion points:
- eventual conversion of `CStr` to be a single thin pointer: this function will still be useful to provide a safe way to create a `CStr` after this change.
- should this return a length too, to address concerns about the `CStr` change? I don't see it as being particularly useful, and it seems less ergonomic (i.e. returning `Result<(&CStr, usize), FromBytesUntilNulError>`). I think users that also need this length without the additional `strlen` call are likely better off using a combination of other methods, but this is up for discussion
- `CString::from_vec_until_nul`: this is also useful, but it doesn't even have a nightly implementation merged yet. I propose feature gating that separately, as opposed to blocking this `CStr` implementation on that

Possible alternatives:

A user can use `from_bytes_with_nul` on a slice up to `my_slice[..my_slice.iter().find(|c| c == 0).unwrap()]`. However; that is significantly less ergonomic, and is a bit more work for the compiler to optimize compared the direct `memchr` call that this wraps.

## New stable API

```rs
// both in core::ffi

pub struct FromBytesUntilNulError(());

impl CStr {
    pub const fn from_bytes_until_nul(
        bytes: &[u8]
    ) -> Result<&CStr, FromBytesUntilNulError>
}
```

cc ```@ericseppanen``` original author, ```@Mark-Simulacrum``` original reviewer, ```@m-ou-se``` brought up some issues on the thin pointer CStr

```@rustbot``` modify labels: +T-libs-api +needs-fcp
2023-02-08 20:01:24 -08:00
Michael Goulet a478b836fa
Rollup merge of #107317 - ids1024:asfd-rc, r=dtolnay
Implement `AsFd` and `AsRawFd` for `Rc`

Fixes https://github.com/rust-lang/rust/issues/105931.
2023-02-08 20:01:24 -08:00
Oleksii Lozovskyi 54b26f49e6 Test XRay only for supported targets
Now that the compiler accepts "-Z instrument-xray" option only when
targeting one of the supported targets, make sure to not run the
codegen tests where the compiler will fail.

Like with other compiletests, we don't have access to internals,
so simply hardcode a list of supported architectures here.
2023-02-09 12:29:43 +09:00
Oleksii Lozovskyi 3561dc948c Emit an error if -Z instrument-xray is not supported
This is somewhat important because LLVM enables the pass based on
target architecture, but support by the target OS also matters.

For example, XRay attributes are processed by codegen for macOS
targets, but Apple linker fails to process relocations in XRay
data sections, so the feature as a whole is not supported there
for the time being.
2023-02-09 12:29:40 +09:00
Oleksii Lozovskyi 8e49c84740 XRay support flag in TargetOptions
Specify where XRay is supported. I only test ARM64 and x86_64, but hey
those others should work too, right? LLVM documentation says that MIPS
and PPC are also supported, but I don't have the hardware, so I won't
pretend. Naturally, more targets can be added later with more testing.
2023-02-09 12:28:01 +09:00
Oleksii Lozovskyi 0fef658ffe Codegen tests for -Z instrument-xray
Let's add at least some tests to verify that this option is accepted
and produces expected LLVM attributes. More tests can be added later
with attribute support.
2023-02-09 12:28:00 +09:00
Oleksii Lozovskyi bac15db1d0 Emit basic XRay instrumentation attributes
Add the attributes to functions according to the settings.

"xray-always" overrides "xray-never", and they both override
"xray-ignore-loops" and "xray-instruction-threshold", but we'll
let lints deal with warnings about silly attribute combinations.
2023-02-09 12:28:00 +09:00
Oleksii Lozovskyi b3cadd2dcf Allow multiple instrumentation attributes
Four because that's the new reasonable maximum for XRay instrumentation
attributes in the following commit.
2023-02-09 12:28:00 +09:00
Oleksii Lozovskyi d748f08547 UI tests for -Z instrument-xray
I'm tired of testing it manually, just codify my expectations in tests.
They're pretty low-maintenance.
2023-02-09 12:27:58 +09:00
Oleksii Lozovskyi 0e60df9ed1 Parse "-Z instrument-xray" codegen option
Recognize all bells and whistles that LLVM's XRay pass is capable of.
The always/never settings are a bit dumb without attributes but they're
still there. The default instruction count is chosen by the compiler,
not LLVM pass. We'll do it later.
2023-02-09 12:25:21 +09:00
yukang 8f736a4042 fix #104961, Add parentheses properly for borrowing suggestion 2023-02-09 02:38:55 +00:00
Nicholas Nethercote a70d03b624 Extend `BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE`.
To temporarily allow a `str` field in a packed struct using `derive`,
along with `[u8]`.
2023-02-09 11:47:12 +11:00
bors 575d424c94 Auto merge of #107717 - nnethercote:opt-TyKind-eq, r=compiler-errors
Optimize `TyKind::eq`.

r? `@ghost`
2023-02-09 00:41:31 +00:00
bors fd2d8beaf8 Auto merge of #10293 - Alexendoo:bool-assert-comparison-negation, r=dswij
Negate suggestions when needed in `bool_assert_comparison`

changelog: none assuming this gets into the same release as #10218

Fixes #10291

r? `@dswij`

Thanks to `@black-puppydog` for spotting it early
2023-02-08 23:03:32 +00:00
clubby789 730470c8dd Set `rust-analyzer.check.invocationLocation` to `root` 2023-02-08 22:53:50 +00:00
Michael Howell 8cb5be96c4 rustdoc: use [svgo] to shrink `wheel.svg`
[svgo]: https://github.com/svg/svgo

    $ du -bs src/librustdoc/html/static/images/wheel.svg wheel-old.svg
    2972    src/librustdoc/html/static/images/wheel.svg
    3764    wheel-old.svg

100*((2972-3764)/3764) = -21.04%
2023-02-08 14:17:19 -07:00
bors ef934d9b63 Auto merge of #107811 - matthiaskrgr:rollup-rpjzshk, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #105641 (Implement cursors for BTreeMap)
 - #107271 (Treat Drop as a rmw operation)
 - #107710 (Update strip-ansi-escapes and vte)
 - #107758 (Change `arena_cache` to not alter the declared query result)
 - #107777 (Make `derive_const` derive properly const-if-const impls)
 - #107780 (Rename `replace_bound_vars_with_*` to `instantiate_binder_with_*`)
 - #107793 (Add missing tracking issue for `RawOsError`)
 - #107807 (Fix small debug typo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-08 20:11:35 +00:00
Alan Egerton 38ec810c37
Do not assemble supertraits for trait aliases 2023-02-08 19:55:50 +00:00
KaDiWa 62edacf738
bootstrap.py: fix build-failure message 2023-02-08 19:19:23 +01:00
lcnr 4c7c5e597f add (currently ICEing) test 2023-02-08 19:11:14 +01:00
lcnr a5164605bc correctly update goals in the cache 2023-02-08 19:11:14 +01:00
Michael Goulet 0017822b70 Do not eagerly recover for bad impl-trait in macros 2023-02-08 17:56:08 +00:00
Matthias Krüger 3eea052dbb
Rollup merge of #107807 - GuillaumeGomez:fix-small-debug-typo, r=notriddle
Fix small debug typo

r? ``@notriddle``
2023-02-08 18:32:45 +01:00
Matthias Krüger c7c66e1b12
Rollup merge of #107793 - joboet:raw_os_error_ty_tracking, r=Dylan-DPC
Add missing tracking issue for `RawOsError`

I forgot to add it in the original PR…

See #107792.

```@rustbot``` label +T-libs-api -T-libs
2023-02-08 18:32:44 +01:00
Matthias Krüger ec65285fdd
Rollup merge of #107780 - compiler-errors:instantiate-binder, r=lcnr
Rename `replace_bound_vars_with_*` to `instantiate_binder_with_*`

Mentioning "binder" rather than "bound vars", imo, makes it clearer that we're doing something to the binder as a whole.

Also, "instantiate" is the verb that I'm always reaching for when I'm looking for these functions, and the name that we use in the new solver anyways.

r? types
2023-02-08 18:32:44 +01:00
Matthias Krüger 5b8403c463
Rollup merge of #107777 - compiler-errors:derive_const-actually-derive-const, r=fee1-dead
Make `derive_const` derive properly const-if-const impls

Fixes #107774
Fixes #107666

Also fixes rendering of const-if-const bounds in pretty printing.

r? ```@oli-obk``` or ```@fee1-dead```
2023-02-08 18:32:43 +01:00
Matthias Krüger abc2203e36
Rollup merge of #107758 - Zoxc:arena-enref, r=cjgillot
Change `arena_cache` to not alter the declared query result

This makes the return types a bit clearer, limiting `arena_cache`'s effect to just the computation side. It also makes it easier to potentially remove `arena_cache`.

r? ```@cjgillot```
2023-02-08 18:32:43 +01:00
Matthias Krüger f696e699a0
Rollup merge of #107710 - ehuss:update-strip-ansi-escapes, r=Mark-Simulacrum
Update strip-ansi-escapes and vte

This updates strip-ansi-escapes from 0.1.0 to 0.1.1 (and consequently vte).
Changes: https://github.com/luser/strip-ansi-escapes/compare/0.1.0...0.1.1
The only change really is updating vte which fixes some parsing issues (and drops the vendored source size by several megabytes).

Closes #107708
2023-02-08 18:32:42 +01:00
Matthias Krüger 05748c66a0
Rollup merge of #107271 - Zeegomo:drop-rmw, r=oli-obk
Treat Drop as a rmw operation

Previously, a Drop terminator was considered a move in MIR. This commit changes the behavior to only treat Drop as a mutable access to the dropped place.

In order for this change to be correct, we need to guarantee that

1.  A dropped value won't be used again
   2.  Places that appear in a drop won't be used again before a
     subsequent initialization.

We can ensure this to be correct at MIR construction because Drop will only be emitted when a variable goes out of scope, thus having:
*   (1) as there is no way of reaching the old value. drop-elaboration
     will also remove any uninitialized drop.
 * (2) as the place can't be named following the end of the scope.

However, the initialization status, previously tracked by moves, should also be tied to the execution of a Drop, hence the additional logic in the dataflow analyses.

From discussion in [this thread](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/.60DROP.60.20to.20.60DROP_IF.60.20compiler-team.23558), originating from https://github.com/rust-lang/compiler-team/issues/558.
See also https://github.com/rust-lang/rust/pull/104488#discussion_r1085556010
2023-02-08 18:32:41 +01:00
Matthias Krüger 562581c2db
Rollup merge of #105641 - Amanieu:btree_cursor, r=m-ou-se
Implement cursors for BTreeMap

See the ACP for an overview of the API: https://github.com/rust-lang/libs-team/issues/141

The implementation is split into 2 commits:
- The first changes the internal insertion functions to return a handle to the newly inserted element. The lifetimes involved are a bit hairy since we need a mutable handle to both the `BTreeMap` itself (which holds the root) and the nodes allocated in memory. I have tested that this passes the standard library testsuite under miri.
- The second commit implements the cursor API itself. This is more straightforward to follow but still involves some unsafe code to deal with simultaneous mutable borrows of the tree root and the node that is currently being iterated.
2023-02-08 18:32:41 +01:00
bors 9433ba6394 Auto merge of #107644 - Zoxc:query-cache-tweak, r=cjgillot
Remove QueryStorage::store_nocache

This method was added in https://github.com/rust-lang/rust/pull/70674 but it doesn't seem to serve any purpose.
2023-02-08 16:59:18 +00:00
Guillaume Gomez cc8758480c Fix small debug typo 2023-02-08 17:31:54 +01:00
joboet 6a5331146c
std: add tracking issue for `RawOsError` 2023-02-08 12:35:27 +01:00
bors a00e24d76a Auto merge of #107529 - Zoxc:inline-tweak-profile, r=cjgillot
Optimize query_cache_hit to reduce code size of the query hot path.

A small tweak which improves performance on check builds by 0.33% and reduces `rustc_driver` size by 1%.
<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">1.7978s</td><td align="right">1.7980s</td><td align="right"> 0.01%</td><td align="right">1.7930s</td><td align="right"> -0.27%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2594s</td><td align="right">0.2591s</td><td align="right"> -0.12%</td><td align="right">0.2592s</td><td align="right"> -0.09%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check</td><td align="right">6.2522s</td><td align="right">6.2540s</td><td align="right"> 0.03%</td><td align="right">6.2358s</td><td align="right"> -0.26%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.5889s</td><td align="right">1.5880s</td><td align="right"> -0.05%</td><td align="right">1.5799s</td><td align="right"> -0.57%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">0.9941s</td><td align="right">0.9939s</td><td align="right"> -0.02%</td><td align="right">0.9893s</td><td align="right"> -0.49%</td></tr><tr><td>Total</td><td align="right">10.8925s</td><td align="right">10.8930s</td><td align="right"> 0.01%</td><td align="right">10.8572s</td><td align="right"> -0.32%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9997s</td><td align="right"> -0.03%</td><td align="right">0.9967s</td><td align="right"> -0.33%</td></tr></table>

r? `@cjgillot`
2023-02-08 10:35:46 +00:00
John Kåre Alsaker a0b96fdb50 Change `arena_cache` to not alter the declared query result 2023-02-08 09:34:52 +01:00
Tharun Suresh 4259073e9a x.py fails all downloads that use a tempdir with snap curl #107722 2023-02-08 13:37:15 +05:30
bors 3bb6ee5dce Auto merge of #10295 - DesmondWillowbrook:diff-format-suspicious-to-owned, r=Jarcho
fix(suspicious_to_owned): use span_suggestions to suggest both intents

fixes #10294

changelog: [`suspicious_to_owned`]: suggestions now produce valid Rust code
2023-02-08 07:50:43 +00:00
bors 6eb9f2dd67 Auto merge of #107788 - matthiaskrgr:rollup-mw10sli, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #107656 (Bump rust-installer)
 - #107757 (Allow automatically creating vscode `settings.json` with `x setup`)
 - #107769 (Rename `PointerSized` to `PointerLike`)
 - #107770 (rustdoc: use a newline instead of `<br>` to format code headers)
 - #107771 (Tweak ICE message)
 - #107773 (Clearly signal purpose of the yaml template)
 - #107776 (Docs: Fix format of headings in String::reserve)
 - #107779 (Remove astconv usage in diagnostic)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-08 07:43:37 +00:00
Matthias Krüger fe26182281
Rollup merge of #107779 - compiler-errors:issue-107775, r=jackh726
Remove astconv usage in diagnostic

Fixes #107775

Location of the test sucks, I know, but I needed to put it somewhere 😓
The issue here is that the root cause of the issue has nothing to do with what's being tested, so I couldn't really give it a better name. Oh well.
2023-02-08 07:13:29 +01:00
Matthias Krüger 5e467f5dfa
Rollup merge of #107776 - dbrgn:docs-string-reserve-headings, r=cuviper
Docs: Fix format of headings in String::reserve

It was inconsistent with other doc comments in the same module (and the rest of the rust std docs).
2023-02-08 07:13:28 +01:00