Commit Graph

2606 Commits

Author SHA1 Message Date
yukang
c3394b3eaa Fix #107910, Shorten backtraces in ICEs 2023-05-17 17:56:26 +08: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
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
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
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
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
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
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
Boxy
2a554eb406 bless 2023-05-16 17:16:06 +01: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
Guillaume Gomez
0f1d4b5d4d Add regression test for #111415 2023-05-16 14:35:46 +02:00
Nilstrieb
87e25f7855
Rollup merge of #111614 - aDotInTheVoid:nonsense, r=cjgillot
Add more interesting nonsense to weird-exprs.rs

Some cursed things rust allows that I've ran into.

[The second is taken from here](https://twitter.com/Lucretiel/status/1638929955751964679)
2023-05-16 11:39:40 +02:00
Nilstrieb
3e34be004e
Rollup merge of #111602 - tmiasko:erroneous-constant-used, r=oli-obk
Suppress "erroneous constant used" for constants tainted by errors

When constant evaluation fails because its MIR is tainted by errors,
suppress note indicating that erroneous constant was used, since those
errors have to be fixed regardless of the constant being used or not.

Fixes #110891.
2023-05-16 11:39:39 +02:00
Nilstrieb
87a0cd9a41
Rollup merge of #111449 - compiler-errors:recover-impl-generics-correctly, r=Nilstrieb
Recover `impl<T ?Sized>` correctly

Fixes #111327

r? ````@Nilstrieb```` but you can re-roll

Alternatively, happy to close this if we're okay with just saying "sorry #111327 is just a poor side-effect of parser ambiguity" 🤷
2023-05-16 11:39:38 +02:00
Nilstrieb
f65281534f
Rollup merge of #111428 - bvanjoi:fix-109250, r=Nilstrieb
refactor(resolve): clean up the early error return caused by non-call

closes https://github.com/rust-lang/rust/issues/109250

It seems no bad happened, r? ``@Nilstrieb``
2023-05-16 11:39:38 +02:00
bohan
b2b2be1cad fix(diagnostic): wrap parens for ref impl trait param 2023-05-16 09:29:33 +08:00
bors
ea54255501 Auto merge of #111221 - compiler-errors:yeet-generalizer, r=lcnr
Combine three generalizer implementations

Fixes #111092
Fixes #109505

This code is a bit delicate and there were subtle changes between them, so I'll leave inline comments where further inspection is needed.

Regarding this comment from #109813 -- "add tests triggering all codepaths: at least the combine and the const generalizer", can't really do that now, and I don't really know how we'd get a higher-ranked const error since non-lifetime binders doesn't *really* support `for<const ..>` (it errors out when you try to use it).

r? `@lcnr`
2023-05-15 22:16:50 +00:00
Alona Enraght-Moony
65f9603a4e Add more interesting nonsense to weird-exprs.rs 2023-05-15 21:22:13 +01:00
Michael Goulet
a5763ff8d3 Recover impl<T ?Sized> correctly 2023-05-15 17:14:59 +00:00
Michael Goulet
6d0b6c0d2c Tweaks and a test 2023-05-15 16:40:42 +00:00
Matthias Krüger
eeebb6590a
Rollup merge of #111587 - cbeuw:copy-for-deref, r=oli-obk
Custom MIR: Support `Rvalue::CopyForDeref`

r? `@oli-obk` or `@tmiasko` or `@JakobDegen`
2023-05-15 17:12:47 +02:00
Matthias Krüger
2f0b456903
Rollup merge of #111578 - Zoxc:query-macro-move, r=cjgillot
Move expansion of query macros in rustc_middle to rustc_middle::query

This moves the expansion of `define_callbacks!` and `define_feedable!` from `rustc_middle::ty::query` to `rustc_middle::query`.

This means that types used in queries are both imported and used in `rustc_middle::query` instead of being split between these modules. It also decouples `rustc_middle::ty::query` further from `rustc_middle` which is helpful since we want to move `rustc_middle::ty::query` to the query system crates.
2023-05-15 17:12:46 +02:00
Matthias Krüger
e52fbff5e8
Rollup merge of #111525 - scottmcm:slice-position-tweak, r=Mark-Simulacrum
Stop checking for the absence of something that doesn't exist

A couple of codegen tests are doing
```
// CHECK-NOT: slice_index_len_fail
```

However, that function no longer exists: [the only places](https://github.com/search?q=repo%3Arust-lang%2Frust+slice_index_len_fail&type=code) it occurs in the repo are in those tests.

So this PR updates the tests to check for the absense of the functions that are actually used today to panic for out-of-bounds indexing.
2023-05-15 17:12:45 +02:00
Oli Scherer
ad424e65d8 Always fall back to PartialEq when a constant in a pattern is not recursively structural-eq 2023-05-15 14:20:31 +00:00
Andy Wang
1bd6e168b2
Address FIXME 2023-05-15 12:05:17 +02:00
Andy Wang
c3ab4f28d3
Add CopyForDeref to custom MIR 2023-05-15 12:05:10 +02:00
Matthias Krüger
7a1f3e7a88
Rollup merge of #111531 - chenyukang:yukang-fix-111416-ice, r=compiler-errors
Fix ice caused by shorthand fields in NoFieldsForFnCall

Fixes #111416
2023-05-15 10:58:39 +02:00
John Kåre Alsaker
fff20a703d Move expansion of query macros in rustc_middle to rustc_middle::query 2023-05-15 08:49:13 +02:00
Tomasz Miąsko
67f455afe1 Suppress "erroneous constant used" for constants tainted by errors
When constant evaluation fails because its MIR is tainted by errors,
suppress note indicating that erroneous constant was used, since those
errors have to be fixed regardless of the constant being used or not.
2023-05-15 00:00:00 +00:00
Michael Goulet
bd31d9ee9c Erase ReError properly 2023-05-14 23:22:30 +00:00
David Tolnay
cb109a672d
Shorten lifetime of panic temporaries in panic_fmt case 2023-05-14 07:27:20 -07:00
David Tolnay
cbee2a1ec4
Add ui test to reproduce non-Send panic temporary 2023-05-14 07:27:20 -07:00
Camille GILLOT
f40f235879 Merge return place with other locals in CopyProp. 2023-05-14 12:06:34 +00:00
bors
3603a84a3d Auto merge of #111517 - lukas-code:addr-of-mutate, r=tmiasko
allow mutating function args through `&raw const`

Fixes https://github.com/rust-lang/rust/issues/111502 by "turning off the sketchy optimization while we figure out if this is ok", like `@JakobDegen` said.

The first commit in this PR removes some suspicious looking logic from the same method, but should have no functional changes, since it doesn't modify the `context` outside of the method. Best reviewed commit by commit.

r? opsem
2023-05-14 10:45:39 +00:00
bors
0a0e045e50 Auto merge of #111552 - matthiaskrgr:rollup-4nidoti, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #111463 (Better diagnostics for `env!` where variable contains escape)
 - #111477 (better diagnostics for `impl<..> impl Trait for Type`)
 - #111534 (rustdoc-json: Add tests for `#![feature(inherent_associated_types)]`)
 - #111549 ([rustdoc] Convert more GUI tests colors to their original format)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-14 08:06:40 +00:00
Matthias Krüger
d1cd1273f5
Rollup merge of #111549 - GuillaumeGomez:update-gui-format, r=notriddle
[rustdoc] Convert more GUI tests colors to their original format

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

The update for the `browser-ui-test` version is about improvements for color handling (alpha for hex format in particular).

r? `@notriddle`
2023-05-14 08:21:40 +02:00
Matthias Krüger
70ab314741
Rollup merge of #111534 - aDotInTheVoid:ita-rdj, r=fmease,GuillaumeGomez
rustdoc-json: Add tests for `#![feature(inherent_associated_types)]`

Follow up to #109410, CC `@fmease`

r? `@GuillaumeGomez`
2023-05-14 08:21:40 +02:00
Matthias Krüger
d7f742532a
Rollup merge of #111477 - y21:extra-impl-in-trait-impl, r=compiler-errors
better diagnostics for `impl<..> impl Trait for Type`

Fixes #109963
2023-05-14 08:21:39 +02:00
Matthias Krüger
0b8f2bfe5f
Rollup merge of #111463 - clubby789:env-escaped-var, r=cjgillot
Better diagnostics for `env!` where variable contains escape

Fixes #110559
2023-05-14 08:21:39 +02:00
bors
bc888958c9 Auto merge of #111440 - cjgillot:refprop-debuginfo, r=oli-obk
Allow MIR debuginfo to point to a variable's address

MIR optimizations currently do not to operate on borrowed locals.

When enabling #106285, many borrows will be left as-is because they are used in debuginfo. This pass allows to replace this pattern directly in MIR debuginfo:
```rust
a => _1
_1 = &raw? mut? _2
```
becomes
```rust
a => &_2
// No statement to borrow _2.
```

This pass is implemented as a drive-by in ReferencePropagation MIR pass.

This transformation allows following following MIR opts to treat _2 as an unborrowed local, and optimize it as such, even in builds with debuginfo.

In codegen, when encountering `a => &..&_2`, we create a list of allocas:
```llvm
store ptr %_2.dbg.spill, ptr %a.ref0.dbg.spill
store ptr %a.ref0.dbg.spill, ptr %a.ref1.dbg.spill
...
call void `@llvm.dbg.declare(metadata` ptr %a.ref{n}.dbg.spill, /* ... */)
```

Caveat: this transformation looses the exact type, we do not differentiate `a` as a immutable, mutable reference or a raw pointer. Everything is declared to `*mut` to codegen. I'm not convinced this is a blocker.
2023-05-14 05:31:10 +00:00
bors
ad6ab11234 Auto merge of #111425 - Bryanskiy:privacy_ef, r=petrochenkov
Populate effective visibilities in `rustc_privacy` (take 2)

Same as https://github.com/rust-lang/rust/pull/110907 + regressions fixes.
Fixes https://github.com/rust-lang/rust/issues/111359.

r? `@petrochenkov`
2023-05-14 02:53:52 +00:00
Guillaume Gomez
91765d8c04 Convert more GUI tests colors to their original format 2023-05-14 00:16:16 +02:00
bors
eb03a3e3f9 Auto merge of #111363 - asquared31415:tidy_no_random_ui_tests, r=fee1-dead
Add a tidy check to find unexpected files in UI tests, and clean up the results

While looking at UI tests, I noticed several weird files that were not being tested, some from even pre-1.0. I added a tidy check that fails if any files not known to compiletest or not used in tests (via manual list) are present in the ui tests.

Unfortunately the root entry limit had to be raised by 1 to accommodate the stderr file for one of the tests.

r? `@fee1-dead`
2023-05-13 21:34:05 +00:00
bors
2c41369acc Auto merge of #111374 - tmiasko:align-unsized-locals, r=cjgillot
Align unsized locals

Allocate an extra space for unsized locals and manually align the storage, since alloca doesn't support dynamic alignment.

Fixes #71416.
Fixes #71695.
2023-05-13 19:03:33 +00:00
clubby789
f77971e221 Handle error body when in generator layout 2023-05-13 16:45:19 +01:00