Commit Graph

224369 Commits

Author SHA1 Message Date
Ben Kimock
56eb08735b Use a signal handler to observe ctrl+c and cleanly drop the measureme profiler 2023-05-21 13:09:15 -04:00
bors
a4fb4147eb Auto merge of #2898 - RalfJung:rustup, r=RalfJung
Rustup
2023-05-18 09:05:36 +00:00
Ralf Jung
4014b17d86 Merge from rustc 2023-05-18 11:02:09 +02:00
Ralf Jung
d4ce8edc00 Preparing for merge from rustc 2023-05-18 11:00:59 +02:00
Jules Bertholet
f16acbeef6
Document Pin memory layout 2023-05-18 01:30:12 -04:00
bors
77fb0cd3aa Auto merge of #111364 - cuviper:unhack-thinlto, r=nikic
Remove the ThinLTO CU hack

This reverts #46722, commit e0ab5d5feb.

Since #111167, commit 10b69dde3f, we are
generating DWARF subprograms in a way that is meant to be more compatible
with LLVM's expectations, so hopefully we don't need this workaround
rewriting CUs anymore.
2023-05-18 01:35:41 +00:00
bors
2e17ac8bff Auto merge of #2897 - RalfJung:rustup, r=RalfJung
Rustup
2023-05-18 01:23:40 +00:00
bors
24c180c438 Auto merge of #111672 - nikic:llvm-16.0.4, r=cuviper
Update to LLVM 16.0.4

Fixes #109918.
2023-05-17 21:31:18 +00:00
bors
e9e1bbc7a8 Auto merge of #111568 - scottmcm:undo-opt, r=WaffleLapkin
Stop turning transmutes into discriminant reads in mir-opt

Partially reverts #109612, as after #109993 these aren't actually equivalent any more, and I'm no longer confident this was ever an improvement in the first place.

Having this "simplification" meant that similar-looking code actually did somewhat different things.  For example,
```rust
pub unsafe fn demo1(x: std::cmp::Ordering) -> u8 {
    std::mem::transmute(x)
}
pub unsafe fn demo2(x: std::cmp::Ordering) -> i8 {
    std::mem::transmute(x)
}
```
in nightly today is generating <https://rust.godbolt.org/z/dPK58zW18>
```llvm
define noundef i8 `@_ZN7example5demo117h341ef313673d2ee6E(i8` noundef %x) unnamed_addr #0 {
  %0 = icmp uge i8 %x, -1
  %1 = icmp ule i8 %x, 1
  %2 = or i1 %0, %1
  call void `@llvm.assume(i1` %2)
  ret i8 %x
}

define noundef i8 `@_ZN7example5demo217h5ad29f361a3f5700E(i8` noundef %0) unnamed_addr #0 {
  %x = alloca i8, align 1
  store i8 %0, ptr %x, align 1
  %1 = load i8, ptr %x, align 1, !range !2, !noundef !3
  ret i8 %1
}
```

Which feels too different when the original code is essentially identical.

---

Aside: that example is different *after* optimizations too:
```llvm
define noundef i8 `@_ZN7example5demo117h341ef313673d2ee6E(i8` noundef returned %x) unnamed_addr #0 {
  %0 = add i8 %x, 1
  %1 = icmp ult i8 %0, 3
  tail call void `@llvm.assume(i1` %1)
  ret i8 %x
}

define noundef i8 `@_ZN7example5demo217h5ad29f361a3f5700E(i8` noundef returned %0) unnamed_addr #1 {
  ret i8 %0
}
```
so turning the `Transmute` into a `Discriminant` was arguably just making things worse, so leaving it alone instead -- and thus having less code in rustc -- seems clearly better.
2023-05-17 18:53:26 +00:00
bors
ad23942ad4 Auto merge of #111680 - Dylan-DPC:rollup-1p45gxt, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #110930 (Don't expect normalization to succeed in elaborate_drops)
 - #111557 (Revert "Validate resolution for SelfCtor too.")
 - #111565 (rustdoc-json: Add tests for visibility of impls)
 - #111588 (Emits E0599 when meeting `MyTrait::missing_method`)
 - #111625 (Move rustc_middle/src/ty/query.rs to rustc_middle/src/query/plumbing.rs)
 - #111674 (Add missing backslash in HTML string)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-17 15:17:13 +00:00
Dylan DPC
b0d92c2b70
Rollup merge of #111674 - GuillaumeGomez:add-missing-backslash, r=notriddle
Add missing backslash in HTML string

Found this missing one when looking at code.

r? `@notriddle`
2023-05-17 19:11:56 +05:30
Dylan DPC
3df55382d4
Rollup merge of #111625 - Zoxc:rustc_middle-query-move, r=cjgillot
Move rustc_middle/src/ty/query.rs to rustc_middle/src/query/plumbing.rs

This just keeps the query modules together.

r? `@cjgillot`
2023-05-17 19:11:55 +05:30
Dylan DPC
291ced5e9a
Rollup merge of #111588 - MU001999:diag/improve-e0782, r=fee1-dead
Emits E0599 when meeting `MyTrait::missing_method`

Fixes #111312
2023-05-17 19:11:55 +05:30
Dylan DPC
703323e490
Rollup merge of #111565 - aDotInTheVoid:rdj-impl-viz, r=GuillaumeGomez
rustdoc-json: Add tests for visibility of impls

[Apparrently rustdoc use to give these `crate` instead of `default`](https://github.com/obi1kenobi/trustfall-rustdoc-adapter/compare/rustdoc-v24...rustdoc-v25#diff-58e57a0fc73d1353fa3a057f0fe81c6ecfd4548b429cef1aee36b1c84d8d15a4L366). CC `@obi1kenobi`

The output is arguably still buggy as to weather some of these impls should be stripped, but that's a seperate issue and shouldn't block adding these tests (#111564)

r? `@GuillaumeGomez`
2023-05-17 19:11:54 +05:30
Dylan DPC
ff364b0082
Rollup merge of #111557 - cjgillot:revert-111020, r=petrochenkov
Revert "Validate resolution for SelfCtor too."

This reverts commit 83453408a0.

That PR introduced a breaking change.

Fixes https://github.com/rust-lang/rust/issues/111541
Reopens https://github.com/rust-lang/rust/issues/89868

r? `@petrochenkov`
2023-05-17 19:11:54 +05:30
Dylan DPC
828caa80a9
Rollup merge of #110930 - b-naber:normalize-elaborate-drops, r=cjgillot
Don't expect normalization to succeed in elaborate_drops

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

This was exposed through the changes in https://github.com/rust-lang/rust/pull/109247, which causes more things to be inlined. Inlining can happen before monomorphization, so we can't expect normalization to succeed. In the elaborate_drops analysis we currently have [this call](033aa092ab/compiler/rustc_mir_dataflow/src/elaborate_drops.rs (L278)) to `normalize_erasing_regions`, which ICEs when normalization fails. The types are used to infer [whether the type needs a drop](033aa092ab/compiler/rustc_mir_dataflow/src/elaborate_drops.rs (L374)), where `needs_drop` itself [uses `try_normalize_erasing_regions`](033aa092ab/compiler/rustc_middle/src/ty/util.rs (L1121)).

~[`instance_mir`](https://doc.rust-lang.org/stable/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.instance_mir) isn't explicit about whether it expects the instances corresponding to the `InstanceDef`s to be monomorphized (though I think in all other contexts the function is used post-monomorphization), so the use of `instance_mir` in inlining doesn't necessarily seem wrong to me.~
2023-05-17 19:11:53 +05:30
Guillaume Gomez
54f882e478 Add missing backslash in HTML string 2023-05-17 11:43:13 +02:00
mu001999
db64512422 Emits E0599 when meeting MyTrait::missing_method 2023-05-17 16:59:39 +08:00
Nikita Popov
c544fc3584 Update to LLVM 16.0.4 2023-05-17 10:35:12 +02:00
bors
c2ccc855e7 Auto merge of #111671 - Dylan-DPC:rollup-1jy5r16, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #110145 (Share slice of bytes)
 - #111043 (Stabilize feature `cstr_is_empty`)
 - #111648 (Remove `LangItems::require`)
 - #111649 (Add derive for `core::marker::ConstParamTy`)
 - #111654 (Add a conversion from `&mut T` to `&mut UnsafeCell<T>`)
 - #111661 (Erase regions of type in `offset_of!`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-17 06:42:07 +00:00
Dylan DPC
0720743836
Rollup merge of #111661 - clubby789:offset-of-erase-regions, r=compiler-errors
Erase regions of type in `offset_of!`

Fixes #111657
2023-05-17 11:13:58 +05:30
Dylan DPC
71fdb95272
Rollup merge of #111654 - JoJoJet:unsafe-cell-from-mut-lib, r=joshtriplett
Add a conversion from `&mut T` to `&mut UnsafeCell<T>`

Provides a safe way of downgrading an exclusive reference into an alias-able `&UnsafeCell<T>` reference.

ACP: https://github.com/rust-lang/libs-team/issues/198.
2023-05-17 11:13:57 +05:30
Dylan DPC
bc3b94a486
Rollup merge of #111649 - Nilstrieb:derive-const-param-ty, r=BoxyUwU
Add derive for `core::marker::ConstParamTy`

This makes it easier to implement it for a type, just like `Copy`.

`@BoxyUwU` half asked me to add it
2023-05-17 11:13:57 +05:30
Dylan DPC
e7176dbfd8
Rollup merge of #111648 - Nilstrieb:language-items, r=WaffleLapkin
Remove `LangItems::require`

It's just a short wrapper used by `tcx.require_lang_item`. Deleting it gives us a negative diff.
2023-05-17 11:13:56 +05:30
Dylan DPC
5b58471c4c
Rollup merge of #111043 - jmillikin:cstr-is-empty, r=dtolnay
Stabilize feature `cstr_is_empty`

Fixes #102444

ACP: https://github.com/rust-lang/libs-team/issues/106
2023-05-17 11:13:56 +05:30
Dylan DPC
2a5c4baf68
Rollup merge of #110145 - WaffleLapkin:share_slice_of_bytes, r=Nilstrieb
Share slice of bytes

r? `@Nilstrieb`
cc `@noamtashma`
2023-05-17 11:13:55 +05:30
bors
6c64870fa6 Auto merge of #111630 - BoxyUwU:ty_const_debug_formatting, r=compiler-errors
debug format `Const`'s less verbosely

Not user visible change only visible to people debugging const generics.

Currently debug output for `ty::Const` is super verbose (even for `-Zverbose` lol), things like printing infer vars as `Infer(Var(?0c))` instead of just `?0c`, bound vars and placeholders not using `^0_1` or `!0_1` syntax respectively. With these changes its imo better but not perfect:
`Const { ty: usize, kind: ^0_1 }`
is still a lot for not much information. not entirely sure what to do about that so not dealing with it yet.

Need to do formatting for `ConstKind::Expr` at some point too since rn it sucks (doesn't even print anything with `Display`) not gonna do that in this PR either.

r? `@compiler-errors`
2023-05-17 03:37:54 +00:00
bors
c0784db3de Auto merge of #111664 - weihanglo:update-cargo, r=weihanglo
Update cargo

8 commits in 13413c64ff88dd6c2824e9eb9374fc5f10895d28..09276c703a473ab33daaeb94917232e80eefd628
2023-05-10 13:46:18 +0000 to 2023-05-16 21:43:35 +0000
- docs: Clarify that crates.io doesn't link to docs.rs right away. (rust-lang/cargo#12146)
- docs(ref): Clarify MSRV is generally minor (rust-lang/cargo#12122)
- Fix `check_for_file_and_add`'s check for conflict file (rust-lang/cargo#12135)
- Fixes: Incorrect document link (rust-lang/cargo#12143)
- doc: intra-doc links and doc comments for build script (rust-lang/cargo#12133)
- Add Cargo team charter. (rust-lang/cargo#12010)
- Remove useless drop of copy type (rust-lang/cargo#12136)
- Fix dep/feat syntax with hidden implicit optional dependencies (rust-lang/cargo#12130)

r? ghost
2023-05-17 00:59:44 +00:00
Weihang Lo
41a0286afc
Update cargo 2023-05-17 01:32:31 +01:00
John Kåre Alsaker
54b582a0e8 Finish move of query.rs 2023-05-17 01:57:21 +02:00
John Kåre Alsaker
d169581ea7 Move rustc_middle/src/ty/query.rs to rustc_middle/src/query/plumbing.rs 2023-05-17 01:57:00 +02:00
bors
5c3a3362f8 Auto merge of #111556 - cjgillot:copy-prop-nrvo, r=oli-obk
Merge return place with other locals in CopyProp.

This reintroduces a limited form of NRVO.

r? wg-mir-opt
2023-05-16 22:27:08 +00:00
clubby789
35cf5726e3 Erase regions of type in offset_of! 2023-05-16 21:36:42 +00:00
JoJoJet
ffacb8861a add UnsafeCell::from_mut 2023-05-16 15:36:05 -04:00
bors
e77366b57b Auto merge of #111650 - matthiaskrgr:rollup-n7w17v4, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #107680 (Hide repr attribute from doc of types without guaranteed repr)
 - #111488 (Use error term in projection if missing associated item in new solver)
 - #111533 (Handle error body in generator layout)
 - #111573 (Erase `ReError` properly)
 - #111592 (Change Vec examples to not assert exact capacity except where it is guaranteed)
 - #111610 (fix(diagnostic): wrap parens for ref impl trait param)
 - #111642 ([rustdoc] Only keep impl blocks from bodies)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-16 18:43:04 +00:00
Matthias Krüger
54a49769fa
Rollup merge of #111642 - GuillaumeGomez:only-impl-from-bodies, r=notriddle
[rustdoc] Only keep impl blocks from bodies

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

The problem was that we kept everything inside bodies whereas only impl blocks are actually accessible from outside bodies.

r? `@notriddle`
2023-05-16 20:12:18 +02:00
Matthias Krüger
d2e52ea127
Rollup merge of #111610 - bvanjoi:fix-99597, r=compiler-errors
fix(diagnostic): wrap parens for ref impl trait param

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

When parameters are an `impl_trait` which it needed to add trait, and it is a reference, add parentheses to the type of the parameter in the suggestion
2023-05-16 20:12:18 +02:00
Matthias Krüger
20f6aa1365
Rollup merge of #111592 - Nemo157:fix-vec-capacity-examples, r=joshtriplett
Change Vec examples to not assert exact capacity except where it is guaranteed

It was [brought up on discord](https://discord.com/channels/273534239310479360/818964227783262209/1107633959329878077) that the `Vec::into_boxed_slice` example contradicted the `Vec::with_capacity` docs in that the returned `Vec` might have _more_ capacity than requested.

So, to reduce confusion change all the `assert_eq!(vec.capacity(), _)` to `assert!(vec.capacity() >= _)`, except in 4 examples that have guaranteed capacities: `Vec::from_raw_parts`, `Vec::from_raw_parts_in`, `Vec::<()>::with_capacity`,`Vec::<(), _>::with_capacity_in`.
2023-05-16 20:12:17 +02:00
Matthias Krüger
6dc365003b
Rollup merge of #111573 - compiler-errors:erase-re-error, r=WaffleLapkin
Erase `ReError` properly

Fixes #111341

Since we check whether a type has free regions before erasing (to short circuit unnecesary folding), we need to consider `ReError` as a free region, or else we'll skip it when erasing a type that only mentions `ReError`.

cc `@nnethercote`
2023-05-16 20:12:17 +02:00
Matthias Krüger
426dbcdf92
Rollup merge of #111533 - clubby789:drop-tracking-error, r=oli-obk
Handle error body in generator layout

Fixes #111468

I feel like making this query return `Option<GeneratorLayout>` might be better but had some issues with that approach
2023-05-16 20:12:16 +02:00
Matthias Krüger
c78a67b710
Rollup merge of #111488 - compiler-errors:error-term, r=lcnr
Use error term in projection if missing associated item in new solver

We were previously delaying a bug but not bailing, leading to an ICE in the `tcx.type_of(assoc_def.item.def_id)` call below.
2023-05-16 20:12:16 +02:00
Matthias Krüger
8d162fb150
Rollup merge of #107680 - dtolnay:docrepr, r=Amanieu
Hide repr attribute from doc of types without guaranteed repr

Rustdoc has an undesirable behavior of blindly copying `repr` into the documentation of structs and enums, even when there is no particular repr that the type guarantees to its users. This is a source of confusion for standard library users who assume the fact that a repr is documented means it must be something the standard library promises they can rely on (in transmutes, or FFI).

Some issues on the topic of rustdoc's incorrect handling of `repr`:

- https://github.com/rust-lang/rust/issues/66401
- https://github.com/rust-lang/rust/issues/90435

In places, the standard library currently works around this confusing rustdoc behavior by just omitting `repr(transparent)` altogether even where it should be required if equivalent code were being written outside of the standard library. See #61969.

IMO that is even more confusing, even for standard library maintainers &mdash; see https://github.com/rust-lang/rust/pull/105018#discussion_r1058400997. It's also not something that works for other reprs like `C` or `u8` which cannot just be omitted even in standard library code.

This PR tries a different approach for some types that are being currently incorrectly documented with a repr.

> **Warning**
> This PR does not imply that every type that still has a `repr` attribute in its docs after this PR is now public for users to rely on. This PR only tries to reduce harm from this longstanding rustdoc issue.
2023-05-16 20:12:16 +02:00
Nilstrieb
0336dd132b Add derive for core::marker::ConstParamTy
This makes it easier to implement it for a type, just like `Copy`.
2023-05-16 20:09:25 +02:00
Nilstrieb
c3efa51947 Remove LangItems::require
It's just a short wrapper used by `tcx.require_lang_item`. Deleting it
gives us a negative diff.
2023-05-16 19:53:38 +02:00
David Tolnay
e7963a65ed
Hide repr attribute from doc of types without guaranteed repr 2023-05-16 10:00:52 -07:00
Boxy
2a554eb406 bless 2023-05-16 17:16:06 +01:00
Boxy
e16d71b706 format Const's less verbosely 2023-05-16 17:09:14 +01:00
bors
b652d9a0fd Auto merge of #108062 - Zoxc:spec-incr, r=cjgillot
Specialize query execution for incremental and non-incremental

This specializes query execution for incremental and non-incremental by passing in a separate `dyn QueryEngine` types, taking advantage of the virtual dispatch to avoid a branch. This ends up duplicating `try_execute_query`, hopefully the compile time cost of that is relatively low.

This is a performance improvement for the non-incremental path:
<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><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></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">1.8420s</td><td align="right">1.8331s</td><td align="right"> -0.48%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2652s</td><td align="right">0.2631s</td><td align="right"> -0.78%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">1.0161s</td><td align="right">1.0062s</td><td align="right"> -0.98%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.6408s</td><td align="right">1.6197s</td><td align="right">💚  -1.28%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check</td><td align="right">6.3939s</td><td align="right">6.3558s</td><td align="right"> -0.60%</td></tr><tr><td>Total</td><td align="right">11.1580s</td><td align="right">11.0780s</td><td align="right"> -0.72%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9918s</td><td align="right"> -0.82%</td></tr></table>

The incremental path is more neutral:
<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><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></tr><tr><td>🟣 <b>clap</b>:check:initial</td><td align="right">2.2210s</td><td align="right">2.2227s</td><td align="right"> 0.08%</td></tr><tr><td>🟣 <b>hyper</b>:check:initial</td><td align="right">0.3441s</td><td align="right">0.3443s</td><td align="right"> 0.05%</td></tr><tr><td>🟣 <b>regex</b>:check:initial</td><td align="right">1.2919s</td><td align="right">1.2877s</td><td align="right"> -0.33%</td></tr><tr><td>🟣 <b>syn</b>:check:initial</td><td align="right">2.0749s</td><td align="right">2.0721s</td><td align="right"> -0.14%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check:initial</td><td align="right">7.9266s</td><td align="right">7.9206s</td><td align="right"> -0.07%</td></tr><tr><td>Total</td><td align="right">13.8585s</td><td align="right">13.8474s</td><td align="right"> -0.08%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9992s</td><td align="right"> -0.08%</td></tr></table>

r? `@cjgillot`
2023-05-16 16:02:53 +00:00
Michael Goulet
8921391a12 Use error term if missing associated item in new solver 2023-05-16 16:02:17 +00:00
bors
9239760da8 Auto merge of #105750 - oli-obk:valtrees, r=lcnr
Always fall back to PartialEq when a constant in a pattern is not recursively structural-eq

Right now we destructure the constant as far as we can, but with this PR we just don't take it apart anymore. This is preparatory work for moving to always using valtrees, as these will just do a single conversion of the constant to a valtree at the start, and if that fails, fall back to `PartialEq`.

This removes a few cases where we emitted the `unreachable pattern` lint, because we stop looking into the constant deeply enough to detect that a constant is already covered by another pattern.

Previous work: https://github.com/rust-lang/rust/pull/70743

This is groundwork towards fixing https://github.com/rust-lang/rust/issues/83085 and https://github.com/rust-lang/rust/issues/105047
2023-05-16 13:10:24 +00:00