]> git.lizzy.rs Git - rust.git/log
rust.git
19 months agoSuggest `.clone()` or `ref binding` on E0382
Esteban Küber [Thu, 3 Nov 2022 04:22:24 +0000 (21:22 -0700)]
Suggest `.clone()` or `ref binding` on E0382

19 months agoAuto merge of #104776 - Dylan-DPC:rollup-rf4c2u0, r=Dylan-DPC
bors [Wed, 23 Nov 2022 16:29:17 +0000 (16:29 +0000)]
Auto merge of #104776 - Dylan-DPC:rollup-rf4c2u0, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #104269 (Fix hang in where-clause suggestion with `predicate_can_apply`)
 - #104286 (copy doc output files by format)
 - #104509 (Use obligation ctxt instead of dyn TraitEngine)
 - #104721 (Remove more `ref` patterns from the compiler)
 - #104744 (rustdoc: give struct fields CSS `display: block`)
 - #104751 (Fix an ICE parsing a malformed attribute.)

Failed merges:

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

19 months agoRollup merge of #104751 - nnethercote:fix-104620, r=petrochenkov
Dylan DPC [Wed, 23 Nov 2022 15:02:38 +0000 (20:32 +0530)]
Rollup merge of #104751 - nnethercote:fix-104620, r=petrochenkov

Fix an ICE parsing a malformed attribute.

Fixes #104620.

r? `@petrochenkov`

19 months agoRollup merge of #104744 - notriddle:notriddle/struct-fields-display-block, r=Guillaum...
Dylan DPC [Wed, 23 Nov 2022 15:02:37 +0000 (20:32 +0530)]
Rollup merge of #104744 - notriddle:notriddle/struct-fields-display-block, r=GuillaumeGomez

rustdoc: give struct fields CSS `display: block`

Fixes #104737

19 months agoRollup merge of #104721 - WaffleLapkin:deref-harder, r=oli-obk
Dylan DPC [Wed, 23 Nov 2022 15:02:37 +0000 (20:32 +0530)]
Rollup merge of #104721 - WaffleLapkin:deref-harder, r=oli-obk

Remove more `ref` patterns from the compiler

r? `@oli-obk`
Previous PR: https://github.com/rust-lang/rust/pull/104500

19 months agoRollup merge of #104509 - spastorino:use-obligation-ctxt, r=lcnr
Dylan DPC [Wed, 23 Nov 2022 15:02:36 +0000 (20:32 +0530)]
Rollup merge of #104509 - spastorino:use-obligation-ctxt, r=lcnr

Use obligation ctxt instead of dyn TraitEngine

r? `@lcnr`

19 months agoRollup merge of #104286 - ozkanonur:fix-doc-bootstrap-recompilation, r=jyn514
Dylan DPC [Wed, 23 Nov 2022 15:02:36 +0000 (20:32 +0530)]
Rollup merge of #104286 - ozkanonur:fix-doc-bootstrap-recompilation, r=jyn514

copy doc output files by format

This pr provides copying doc outputs by checking output format without removing output directory on each trigger.

Resolves #103785

19 months agoRollup merge of #104269 - compiler-errors:hang-in-where-clause-sugg, r=lcnr
Dylan DPC [Wed, 23 Nov 2022 15:02:35 +0000 (20:32 +0530)]
Rollup merge of #104269 - compiler-errors:hang-in-where-clause-sugg, r=lcnr

Fix hang in where-clause suggestion with `predicate_can_apply`

Using `predicate_may_hold` during error reporting causes an evaluation overflow, which (because we use `evaluate_obligation_no_overflow`) then causes the predicate to need to be re-evaluated locally, which results in a hang.

... but since the "add a where clause" suggestion is best-effort, just throw any overflow errors. No need for 100% accuracy.

r? `@lcnr` who has been thinking about overflows... Let me know if you want more context about this issue, and as always, feel free to reassign.

Fixes #104225

19 months agoAuto merge of #103947 - camsteffen:place-clones, r=cjgillot
bors [Wed, 23 Nov 2022 13:13:50 +0000 (13:13 +0000)]
Auto merge of #103947 - camsteffen:place-clones, r=cjgillot

Reduce `PlaceBuilder` cloning

Some API tweaks with an eye towards reducing clones.

19 months agoPass ObligationCtxt from enter_canonical_trait_query and use ObligationCtxt API
Santiago Pastorino [Wed, 16 Nov 2022 22:40:55 +0000 (19:40 -0300)]
Pass ObligationCtxt from enter_canonical_trait_query and use ObligationCtxt API

19 months agoCall fully_solve_obligations instead of repeating code
Santiago Pastorino [Thu, 17 Nov 2022 14:44:24 +0000 (11:44 -0300)]
Call fully_solve_obligations instead of repeating code

19 months agoUse ObligationCtxt intead of dyn TraitEngine
Santiago Pastorino [Wed, 16 Nov 2022 18:58:48 +0000 (15:58 -0300)]
Use ObligationCtxt intead of dyn TraitEngine

19 months agoAuto merge of #102750 - the8472:opt-field-order, r=wesleywiser
bors [Wed, 23 Nov 2022 10:01:48 +0000 (10:01 +0000)]
Auto merge of #102750 - the8472:opt-field-order, r=wesleywiser

optimize field ordering by grouping m*2^n-sized fields with equivalently aligned ones

```rust
use std::ptr::addr_of;
use std::mem;

struct Foo {
    word: u32,
    byte: u8,
    ary: [u8; 4]
}

fn main() {
    let foo: Foo = unsafe { mem::zeroed() };

    println!("base: {:p}\nword: {:p}\nbyte: {:p}\nary:  {:p}", &foo, addr_of!(foo.word), addr_of!(foo.byte), addr_of!(foo.ary));
}
```

prints

```
base: 0x7fffc1a8a668
word: 0x7fffc1a8a668
byte: 0x7fffc1a8a66c
ary:  0x7fffc1a8a66d
```

I.e. the `u8` in the middle causes the array to sit at an odd offset, which might prevent optimizations, especially on architectures where unaligned loads are costly.

Note that this will make field ordering niche-dependent, i.e. a `Bar<T>` with `T=char` and `T=u32` may result in different field order, this may break some code that makes invalid assumptions about `repr(Rust)` types.

19 months agoAuto merge of #104758 - Manishearth:rollup-rh1tfum, r=Manishearth
bors [Wed, 23 Nov 2022 06:48:56 +0000 (06:48 +0000)]
Auto merge of #104758 - Manishearth:rollup-rh1tfum, r=Manishearth

Rollup of 6 pull requests

Successful merges:

 - #103488 (Allow opaque types in trait impl headers and rely on coherence to reject unsound cases)
 - #104359 (Refactor must_use lint into two parts)
 - #104612 (Lower return type outside async block creation)
 - #104621 (Fix --extern library finding errors)
 - #104647 (enable fuzzy_provenance_casts lint in liballoc and libstd)
 - #104750 (Bump `fd-lock` in `bootstrap` again)

Failed merges:

 - #104732 (Refactor `ty::ClosureKind` related stuff)

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

19 months agoAdd fatal overflow test
Michael Goulet [Fri, 18 Nov 2022 17:23:10 +0000 (17:23 +0000)]
Add fatal overflow test

19 months agoDrive-by: Don't manually call evaluate_obligation_no_overflow
Michael Goulet [Fri, 11 Nov 2022 03:37:04 +0000 (03:37 +0000)]
Drive-by: Don't manually call evaluate_obligation_no_overflow
19 months agoDo not need to account for overflow in predicate_can_apply
Michael Goulet [Fri, 11 Nov 2022 03:19:02 +0000 (03:19 +0000)]
Do not need to account for overflow in predicate_can_apply

19 months agoRollup merge of #104750 - mati865:bump-fd-lock-again, r=jyn514
Manish Goregaokar [Wed, 23 Nov 2022 03:54:41 +0000 (22:54 -0500)]
Rollup merge of #104750 - mati865:bump-fd-lock-again, r=jyn514

Bump `fd-lock` in `bootstrap` again

Followup to https://github.com/rust-lang/rust/pull/103778
Sorry for the quick succession but this fixes one more building issue for Tier 3 `windows-gnullvm` that I have previously missed, and it would be nice to have it in the release.

19 months agoRollup merge of #104647 - RalfJung:alloc-strict-provenance, r=thomcc
Manish Goregaokar [Wed, 23 Nov 2022 03:54:41 +0000 (22:54 -0500)]
Rollup merge of #104647 - RalfJung:alloc-strict-provenance, r=thomcc

enable fuzzy_provenance_casts lint in liballoc and libstd

r? ````@thomcc````

19 months agoRollup merge of #104621 - YC:master, r=davidtwco
Manish Goregaokar [Wed, 23 Nov 2022 03:54:40 +0000 (22:54 -0500)]
Rollup merge of #104621 - YC:master, r=davidtwco

Fix --extern library finding errors

- `crate_name` is not specified/passed to `metadata_crate_location_unknown_type`
https://github.com/rust-lang/rust/blob/c493bae0d8efd75723460ce5c371f726efa93f15/compiler/rustc_error_messages/locales/en-US/metadata.ftl#L274-L275
- `metadata_lib_filename_form` is missing `$`
- Add additional check to ensure that library is file

Testing
1. Create file `a.rs`
```rust
extern crate t;
fn main() {}
```
1. Create empty file `x`
1. Create empty directory `y`
1. Run
```sh
$ rustc -o a a.rs --extern t=x
$ rustc -o a a.rs --extern t=y
```
Both currently panic with stable.

19 months agoRollup merge of #104612 - Swatinem:async-ret-y, r=estebank
Manish Goregaokar [Wed, 23 Nov 2022 03:54:39 +0000 (22:54 -0500)]
Rollup merge of #104612 - Swatinem:async-ret-y, r=estebank

Lower return type outside async block creation

This allows feeding a different output type to async blocks with a different `ImplTraitContext`. Spotted this while working on #104321

19 months agoRollup merge of #104359 - Nilstrieb:plus-one, r=fee1-dead
Manish Goregaokar [Wed, 23 Nov 2022 03:54:39 +0000 (22:54 -0500)]
Rollup merge of #104359 - Nilstrieb:plus-one, r=fee1-dead

Refactor must_use lint into two parts

Before, the lint did the checking for `must_use` and pretty printing the types in a special format in one pass, causing quite complex and untranslatable code.
Now the collection and printing is split in two. That should also make it easier to translate or extract the type pretty printing in the future.

Also fixes an integer overflow in the array length pluralization
calculation.

fixes #104352

19 months agoRollup merge of #103488 - oli-obk:impl_trait_for_tait, r=lcnr
Manish Goregaokar [Wed, 23 Nov 2022 03:54:38 +0000 (22:54 -0500)]
Rollup merge of #103488 - oli-obk:impl_trait_for_tait, r=lcnr

Allow opaque types in trait impl headers and rely on coherence to reject unsound cases

r? ````@lcnr````

fixes #99840

19 months agoAuto merge of #104752 - weihanglo:update-cargo, r=weihanglo
bors [Wed, 23 Nov 2022 03:17:56 +0000 (03:17 +0000)]
Auto merge of #104752 - weihanglo:update-cargo, r=weihanglo

Update cargo

7 commits in eb5d35917b2395194593c9ca70c3778f60c1573b..ba607b23db8398723d659249d9abf5536bc322e5 2022-11-17 22:08:43 +0000 to 2022-11-22 20:52:39 +0000

- Fix failure to parse rustc's JSON output if it is too nested (rust-lang/cargo#11368)
- Add suggestions when `cargo add` multiple packages (rust-lang/cargo#11186)
- Update mod.rs (rust-lang/cargo#11395)
- Fix typo `try use` -> `try to use` (rust-lang/cargo#11394)
- Add warning when `cargo tree -i <spec>` can not find packages (rust-lang/cargo#11377)
- Clean profile, patch, and replace in cargo remove (rust-lang/cargo#11194)
- chore: Upgrade miow (rust-lang/cargo#11391)

19 months agoFix an ICE parsing a malformed attribute.
Nicholas Nethercote [Tue, 22 Nov 2022 05:48:42 +0000 (16:48 +1100)]
Fix an ICE parsing a malformed attribute.

Fixes #104620.

19 months agoUpdate cargo
Weihang Lo [Wed, 23 Nov 2022 01:01:35 +0000 (01:01 +0000)]
Update cargo

7 commits in eb5d35917b2395194593c9ca70c3778f60c1573b..ba607b23db8398723d659249d9abf5536bc322e5
2022-11-17 22:08:43 +0000 to 2022-11-22 20:52:39 +0000

- Fix failure to parse rustc's JSON output if it is too nested (rust-lang/cargo#11368)
- Add suggestions when `cargo add` multiple packages (rust-lang/cargo#11186)
- Update mod.rs (rust-lang/cargo#11395)
- Fix typo `try use` -> `try to use` (rust-lang/cargo#11394)
- Add warning when `cargo tree -i <spec>` can not find packages (rust-lang/cargo#11377)
- Clean profile, patch, and replace in cargo remove (rust-lang/cargo#11194)
- chore: Upgrade miow (rust-lang/cargo#11391)

19 months agoAuto merge of #104743 - JohnTitor:rollup-9z9u7yd, r=JohnTitor
bors [Tue, 22 Nov 2022 23:43:13 +0000 (23:43 +0000)]
Auto merge of #104743 - JohnTitor:rollup-9z9u7yd, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #101368 (Forbid inlining `thread_local!`'s `__getit` function on Windows)
 - #102293 (Add powerpc64-ibm-aix as Tier-3 target)
 - #104717 (Add failing test for projections used as const generic)
 - #104720 (rustdoc: remove no-op CSS `.popover::before / a.test-arrow { display: inline-block }`)
 - #104722 (Speed up mpsc_stress test)
 - #104724 (Fix `ClosureKind::to_def_id`)
 - #104728 (Use `tcx.require_lang_item` instead of unwrapping lang items)

Failed merges:

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

19 months agoBump `fd-lock` in `bootstrap` again
Mateusz Mikuła [Tue, 22 Nov 2022 23:12:57 +0000 (00:12 +0100)]
Bump `fd-lock` in `bootstrap` again

Followup to https://github.com/rust-lang/rust/pull/103778
Sorry for the quick succession but this fixes one more building issue for Tier 3 `windows-gnullvm` that I have previously missed, and it would be nice to have it in the release.

19 months agoadd tests for field ordering optimization
The 8472 [Fri, 7 Oct 2022 18:35:34 +0000 (20:35 +0200)]
add tests for field ordering optimization

19 months agofix tests, update size asserts
The 8472 [Thu, 6 Oct 2022 23:10:15 +0000 (01:10 +0200)]
fix tests, update size asserts

19 months agoalso sort fields by niche sizes to retain optimizations
The 8472 [Thu, 6 Oct 2022 23:09:54 +0000 (01:09 +0200)]
also sort fields by niche sizes to retain optimizations

19 months agogroup fields based on largest power of two dividing its size
The 8472 [Thu, 6 Oct 2022 21:34:50 +0000 (23:34 +0200)]
group fields based on largest power of two dividing its size

19 months agooptimize field ordering by grouping power-of-two arrays with larger types
The 8472 [Thu, 6 Oct 2022 19:20:02 +0000 (21:20 +0200)]
optimize field ordering by grouping power-of-two arrays with larger types

19 months agorustdoc: make struct fields `display: block`
Michael Howell [Tue, 22 Nov 2022 21:48:58 +0000 (14:48 -0700)]
rustdoc: make struct fields `display: block`

19 months agoRollup merge of #104728 - WaffleLapkin:require-lang-items-politely, r=compiler-errors
Yuki Okushi [Tue, 22 Nov 2022 21:40:24 +0000 (06:40 +0900)]
Rollup merge of #104728 - WaffleLapkin:require-lang-items-politely, r=compiler-errors

Use `tcx.require_lang_item` instead of unwrapping lang items

I clearly remember esteban telling me that there is `require_lang_item` but he was from a phone atm and I couldn't find it, so I didn't use it. Stumbled on it today, so here we are :)

19 months agoRollup merge of #104724 - WaffleLapkin:to_def_idn't, r=compiler-errors
Yuki Okushi [Tue, 22 Nov 2022 21:40:24 +0000 (06:40 +0900)]
Rollup merge of #104724 - WaffleLapkin:to_def_idn't, r=compiler-errors

Fix `ClosureKind::to_def_id`

`Fn` and `FnOnce` were mixed up in https://github.com/rust-lang/rust/pull/99131.

19 months agoRollup merge of #104722 - mejrs:stress, r=ChrisDenton
Yuki Okushi [Tue, 22 Nov 2022 21:40:23 +0000 (06:40 +0900)]
Rollup merge of #104722 - mejrs:stress, r=ChrisDenton

Speed up mpsc_stress test

See https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/mpsc_stress for context

r? windows

19 months agoRollup merge of #104720 - notriddle:notriddle/popover-before-display-inline, r=Guilla...
Yuki Okushi [Tue, 22 Nov 2022 21:40:23 +0000 (06:40 +0900)]
Rollup merge of #104720 - notriddle:notriddle/popover-before-display-inline, r=GuillaumeGomez

rustdoc: remove no-op CSS `.popover::before / a.test-arrow { display: inline-block }`

Since this box is absolutely positioned, its display type is [blockified] anyway. We just need to make sure it isn't `display: none`.

[blockified]: https://www.w3.org/TR/css-display-3/#transformations

19 months agoRollup merge of #104717 - GuillaumeGomez:test-projection-used-as-const-generic, r...
Yuki Okushi [Tue, 22 Nov 2022 21:40:22 +0000 (06:40 +0900)]
Rollup merge of #104717 - GuillaumeGomez:test-projection-used-as-const-generic, r=oli-obk

Add failing test for projections used as const generic

Based on the experiment done in https://github.com/rust-lang/rust/pull/104443, we realized it's currently not possible to support projections in const generics. More information about it in https://github.com/rust-lang/rust/pull/104443#discussion_r1029375633.

This PR adds the UI test in any case so we can gather data in order to work towards adding `TyAlias` into the ABI in the future.

r? ``@oli-obk``

19 months agoRollup merge of #102293 - ecnelises:aix.initial, r=davidtwco
Yuki Okushi [Tue, 22 Nov 2022 21:40:22 +0000 (06:40 +0900)]
Rollup merge of #102293 - ecnelises:aix.initial, r=davidtwco

Add powerpc64-ibm-aix as Tier-3 target

This is part of the effort mentioned in https://github.com/rust-lang/compiler-team/issues/553.

A reference to these options are definitions from [clang](https://github.com/llvm/llvm-project/blob/ad6fe32032a6229e0c40510e9bed419a01c695b3/clang/lib/Basic/Targets/PPC.h#L414-L448) and [llvm](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp).

AIX has a system `ld` but [its options and behaviors](https://www.ibm.com/docs/en/aix/7.3?topic=l-ld-command) are different from GNU ld. Thanks to ``@bzEq`` for contributing the linking args.

19 months agoRollup merge of #101368 - thomcc:wintls-noinline, r=ChrisDenton
Yuki Okushi [Tue, 22 Nov 2022 21:40:21 +0000 (06:40 +0900)]
Rollup merge of #101368 - thomcc:wintls-noinline, r=ChrisDenton

Forbid inlining `thread_local!`'s `__getit` function on Windows

Sadly, this will make things slower to avoid UB in an edge case, but it seems hard to avoid... and really whenever I look at this code I can't help but think we're asking for trouble.

It's pretty dodgy for us to leave this as a normal function rather than `#[inline(never)]`, given that if it *does* get inlined into a dynamically linked component, it's extremely unsafe (you get some other thread local, or if you're lucky, crash). Given that it's pretty rare for people to use dylibs on Windows, the fact that we haven't gotten bug reports about it isn't really that convincing. Ideally we'd come up with some kind of compiler solution (that avoids paying for this cost when static linking, or *at least* for use within the same crate...), but it's not clear what that looks like.

Oh, and because all this is only needed when we're implementing `thread_local!` with `#[thread_local]`, this patch adjusts the `cfg_attr` to be `all(windows, target_thread_local)` as well.

r? ``@ChrisDenton``

See also #84933, which is about improving the situation.

19 months agoAuto merge of #104735 - the8472:simd-contains-fix, r=thomcc
bors [Tue, 22 Nov 2022 20:47:17 +0000 (20:47 +0000)]
Auto merge of #104735 - the8472:simd-contains-fix, r=thomcc

Simd contains fix

Fixes #104726

The bug was introduced by an improvement late in the original PR (#103779) which added the backtracking when the last and first byte of the needle were the same. That changed the meaning of the variable for the last probe offset, which I should have split into the last byte offset and last probe offset. Not doing so lead to incorrect loop conditions.

19 months agofix OOB access in SIMD impl of str.contains()
The 8472 [Tue, 22 Nov 2022 19:59:19 +0000 (20:59 +0100)]
fix OOB access in SIMD impl of str.contains()

19 months agoadd test for issue 104726
The 8472 [Tue, 22 Nov 2022 19:54:10 +0000 (20:54 +0100)]
add test for issue 104726

19 months ago`rustc_ast_lowering`: remove `ref` patterns
Maybe Waffle [Tue, 22 Nov 2022 15:37:54 +0000 (15:37 +0000)]
`rustc_ast_lowering`: remove `ref` patterns

19 months ago`rustc_arena`: remove a couple of `ref` patterns
Maybe Waffle [Tue, 22 Nov 2022 09:49:31 +0000 (09:49 +0000)]
`rustc_arena`: remove a couple of `ref` patterns

19 months ago`rustc_parse`: remove `ref` patterns
Maybe Waffle [Tue, 22 Nov 2022 09:42:01 +0000 (09:42 +0000)]
`rustc_parse`: remove `ref` patterns

19 months agoSpeed up mpsc_stress test
mejrs [Tue, 22 Nov 2022 18:11:12 +0000 (19:11 +0100)]
Speed up mpsc_stress test

19 months agoUse `tcx.require_lang_item` instead of unwrapping
Maybe Waffle [Tue, 22 Nov 2022 17:19:19 +0000 (17:19 +0000)]
Use `tcx.require_lang_item` instead of unwrapping

19 months agoAuto merge of #104688 - flip1995:clippyup, r=Manishearth,flip1995
bors [Tue, 22 Nov 2022 17:09:06 +0000 (17:09 +0000)]
Auto merge of #104688 - flip1995:clippyup, r=Manishearth,flip1995

Update Clippy

r? `@Manishearth`

Sorry for taking so long. There were so many blockers and so little time. This situation should be mitigated with #104007 in the future.

19 months agoFix `ClosureKind::to_def_id`
Maybe Waffle [Tue, 22 Nov 2022 15:57:06 +0000 (15:57 +0000)]
Fix `ClosureKind::to_def_id`

19 months agorustdoc: remove no-op CSS `a.test-arrow { display: inline-block }`
Michael Howell [Tue, 22 Nov 2022 16:06:24 +0000 (09:06 -0700)]
rustdoc: remove no-op CSS `a.test-arrow { display: inline-block }`

Since this box is absolutely positioned, its display type is [blockified]
anyway. We just need to make sure it isn't `display: none`.

[blockified]: https://www.w3.org/TR/css-display-3/#transformations

19 months agorustdoc: remove no-op CSS `.popover::before { display: inline-block }`
Michael Howell [Tue, 22 Nov 2022 15:21:10 +0000 (08:21 -0700)]
rustdoc: remove no-op CSS `.popover::before { display: inline-block }`

Since this box is absolutely positioned, its display type is [blockified]
anyway. We just need to make sure it isn't `display: none`.

[blockified]: https://www.w3.org/TR/css-display-3/#transformations

19 months agoAdd failing test for projections used as const generic
Guillaume Gomez [Tue, 22 Nov 2022 15:02:37 +0000 (16:02 +0100)]
Add failing test for projections used as const generic

19 months agoClippy: Workaround for let_chains issue
Philipp Krones [Tue, 22 Nov 2022 13:30:29 +0000 (14:30 +0100)]
Clippy: Workaround for let_chains issue

19 months agoAuto merge of #104711 - Dylan-DPC:rollup-gkw1qr8, r=Dylan-DPC
bors [Tue, 22 Nov 2022 13:18:45 +0000 (13:18 +0000)]
Auto merge of #104711 - Dylan-DPC:rollup-gkw1qr8, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #104295 (Check generics parity before collecting return-position `impl Trait`s in trait)
 - #104464 (Reduce exceptions overallocation on non Windows x86_64)
 - #104615 (Create def_id for async fns during lowering)
 - #104669 (Only declare bindings for if-let guards once per arm)
 - #104701 (Remove a lifetime resolution hack from `compare_predicate_entailment`)
 - #104710 (disable strict-provenance-violating doctests in Miri)

Failed merges:

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

19 months agoRollup merge of #104710 - RalfJung:doc-strict-provenance, r=thomcc
Dylan DPC [Tue, 22 Nov 2022 11:06:39 +0000 (16:36 +0530)]
Rollup merge of #104710 - RalfJung:doc-strict-provenance, r=thomcc

disable strict-provenance-violating doctests in Miri

Most of these are on deprecated unstable functions anyway. This lets us run the remaining doctests with `-Zmiri-strict-provenance`, which I think is a win.

r? `@thomcc`

19 months agoRollup merge of #104701 - compiler-errors:rpitit-remove-reempty-hack, r=TaKO8Ki
Dylan DPC [Tue, 22 Nov 2022 11:06:38 +0000 (16:36 +0530)]
Rollup merge of #104701 - compiler-errors:rpitit-remove-reempty-hack, r=TaKO8Ki

Remove a lifetime resolution hack from `compare_predicate_entailment`

This is not needed anymore, probably due to #102334 equating the function signatures fully in `collect_trait_impl_trait_tys`. Also, the assertion in in #102903 makes sure that this is actually fixed, so I'm pretty confident this isn't needed.

19 months agoRollup merge of #104669 - LeSeulArtichaut:88015-if-let-guard-bindings, r=cjgillot
Dylan DPC [Tue, 22 Nov 2022 11:06:38 +0000 (16:36 +0530)]
Rollup merge of #104669 - LeSeulArtichaut:88015-if-let-guard-bindings, r=cjgillot

Only declare bindings for if-let guards once per arm

Currently, each candidate for a match arm uses separate locals for the bindings in the if-let guard, causing problems (#88015) when those branches converge in the arm body.

Fixes #88015 (🤞)

19 months agoRollup merge of #104615 - spastorino:create-async-def-id-in-lowering, r=compiler...
Dylan DPC [Tue, 22 Nov 2022 11:06:37 +0000 (16:36 +0530)]
Rollup merge of #104615 - spastorino:create-async-def-id-in-lowering, r=compiler-errors

Create def_id for async fns during lowering

r? `@compiler-errors`

19 months agoRollup merge of #104464 - mati865:reduce-eh-overallocation-amd64, r=thomcc
Dylan DPC [Tue, 22 Nov 2022 11:06:37 +0000 (16:36 +0530)]
Rollup merge of #104464 - mati865:reduce-eh-overallocation-amd64, r=thomcc

Reduce exceptions overallocation on non Windows x86_64

Addressing https://github.com/rust-lang/rust/pull/103894#discussion_r1020950196

19 months agoRollup merge of #104295 - compiler-errors:rpitit-generics-parity, r=eholk
Dylan DPC [Tue, 22 Nov 2022 11:06:36 +0000 (16:36 +0530)]
Rollup merge of #104295 - compiler-errors:rpitit-generics-parity, r=eholk

Check generics parity before collecting return-position `impl Trait`s in trait

The only thing is that this duplicates the error message for number of generics mismatch, but we already deduplicate that error message in Cargo. I could add a flag to delay the error if the reviewer cares.

Fixes #104281

Also drive-by adds a few comments to the `collect_trait_impl_trait_tys` method, and removes an unused argument from `compare_number_of_generics`.

19 months agodisable strict-provenance-violating doctests in Miri
Ralf Jung [Tue, 22 Nov 2022 10:28:35 +0000 (11:28 +0100)]
disable strict-provenance-violating doctests in Miri

19 months agoAuto merge of #103578 - petrochenkov:nofict, r=nagisa
bors [Tue, 22 Nov 2022 10:17:09 +0000 (10:17 +0000)]
Auto merge of #103578 - petrochenkov:nofict, r=nagisa

Unreserve braced enum variants in value namespace

With this PR braced enum variants (`enum E { V { /*...*/ } }`) no longer take a slot in value namespace, so the special case mentioned in the note in https://github.com/rust-lang/rfcs/blob/master/text/1506-adt-kinds.md#braced-structs is removed.

Report - https://github.com/rust-lang/rust/pull/103578#issuecomment-1292594900.

19 months agoForbid inlining `thread_local!`'s `__getit` function on Windows
Thom Chiovoloni [Sat, 3 Sep 2022 07:28:03 +0000 (00:28 -0700)]
Forbid inlining `thread_local!`'s `__getit` function on Windows

19 months agoAuto merge of #104702 - Manishearth:rollup-75hagzd, r=Manishearth
bors [Tue, 22 Nov 2022 07:15:48 +0000 (07:15 +0000)]
Auto merge of #104702 - Manishearth:rollup-75hagzd, r=Manishearth

Rollup of 7 pull requests

Successful merges:

 - #83608 (Add slice methods for indexing via an array of indices.)
 - #95583 (Deprecate the unstable `ptr_to_from_bits` feature)
 - #101655 (Make the Box one-liner more descriptive)
 - #102207 (Constify remaining `Layout` methods)
 - #103193 (mark sys_common::once::generic::Once::new const-stable)
 - #104622 (Use clang for the UEFI targets)
 - #104638 (Move macro_rules diagnostics to diagnostics module)

Failed merges:

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

19 months agoTests for bad --extern library path and file
Steven Tang [Tue, 22 Nov 2022 06:09:47 +0000 (17:09 +1100)]
Tests for bad --extern library path and file

19 months agoRollup merge of #104638 - Nilstrieb:macro-diagnostics, r=compiler-errors
Manish Goregaokar [Tue, 22 Nov 2022 06:26:08 +0000 (01:26 -0500)]
Rollup merge of #104638 - Nilstrieb:macro-diagnostics, r=compiler-errors

Move macro_rules diagnostics to diagnostics module

This will make it easier to add more diagnostics in the future in a centralized place.

19 months agoRollup merge of #104622 - nicholasbishop:bishop-uefi-clang, r=Mark-Simulacrum
Manish Goregaokar [Tue, 22 Nov 2022 06:26:08 +0000 (01:26 -0500)]
Rollup merge of #104622 - nicholasbishop:bishop-uefi-clang, r=Mark-Simulacrum

Use clang for the UEFI targets

This fixes an issue where the C and asm sources built by compiler_builtins were being compiled as ELF objects instead of PE objects. This wasn't noticed before because it doesn't cause compiler_builtins or rustc to fail to build. You only see a failure when a program is built that references one of the symbols in an ELF object.

Compiling with clang fixes this because the cc crate converts the UEFI targets into Windows targets that clang understands, causing it to produce PE objects.

Also update compiler_builtins to 0.1.84 to pull in some necessary fixes for compiling the UEFI targets with clang.

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

19 months agoRollup merge of #103193 - krasimirgg:sysonce, r=Amanieu
Manish Goregaokar [Tue, 22 Nov 2022 06:26:07 +0000 (01:26 -0500)]
Rollup merge of #103193 - krasimirgg:sysonce, r=Amanieu

mark sys_common::once::generic::Once::new const-stable

Attempt to address https://github.com/rust-lang/rust/issues/103191 by marking the impl const-stable.
Picked the declaration from the callsite:
https://github.com/rust-lang/rust/blob/21b246587c2687935bd6004ffa5dcc4f4dd6600d/library/std/src/sync/once.rs#L67

This is similar to https://github.com/rust-lang/rust/pull/98457.

With this in, `python3 x.py build library/std --target x86_64-unknown-none` succeeds.

19 months agoRollup merge of #102207 - CraftSpider:const-layout, r=scottmcm
Manish Goregaokar [Tue, 22 Nov 2022 06:26:07 +0000 (01:26 -0500)]
Rollup merge of #102207 - CraftSpider:const-layout, r=scottmcm

Constify remaining `Layout` methods

Makes the methods on `Layout` that aren't yet unstably const, under the same feature and issue, #67521. Most of them required no changes, only non-trivial change is probably constifying `ValidAlignment` which may affect #102072

19 months agoRollup merge of #101655 - dns2utf8:box_docs, r=dtolnay
Manish Goregaokar [Tue, 22 Nov 2022 06:26:06 +0000 (01:26 -0500)]
Rollup merge of #101655 - dns2utf8:box_docs, r=dtolnay

Make the Box one-liner more descriptive

I would like to avoid a definition that relies on itself.

r? `@GuillaumeGomez`

19 months agoRollup merge of #95583 - scottmcm:deprecate-ptr-to-from-bits, r=dtolnay
Manish Goregaokar [Tue, 22 Nov 2022 06:26:05 +0000 (01:26 -0500)]
Rollup merge of #95583 - scottmcm:deprecate-ptr-to-from-bits, r=dtolnay

Deprecate the unstable `ptr_to_from_bits` feature

I propose that we deprecate the (unstable!) `to_bits` and `from_bits` methods on raw pointers.  (With the intent to ~~remove them once `addr` has been around long enough to make the transition easy on people -- maybe another 6 weeks~~ remove them fairly soon after, as the strict and expose versions have been around for a while already.)

The APIs that came from the strict provenance explorations (#95228) are a more holistic version of these, and things like `.expose_addr()` work for the "that cast looks sketchy" case even if the full strict provenance stuff never happens.  (As a bonus, `addr` is even shorter than `to_bits`, though it is only applicable if people can use full strict provenance! `addr` is *not* a direct replacement for `to_bits`.)  So I think it's fine to move away from the `{to|from}_bits` methods, and encourage the others instead.

That also resolves the worry that was brought up (I forget where) that `q.to_bits()` and `(*q).to_bits()` both work if `q` is a pointer-to-floating-point, as they also have a `to_bits` method.

Tracking issue #91126
Code search: https://github.com/search?l=Rust&p=1&q=ptr_to_from_bits&type=Code

For potential pushback, some users in case they want to chime in
- `@RSSchermer` https://github.com/RSSchermer/ARWA/blob/365bb68541447453fc44f6fbcc5d394bb94c14e9/arwa/src/html/custom_element.rs#L105
- `@strax` https://github.com/strax/pbr/blob/99616d1dbf42f93ec8dd668d05b3180649558180/openexr/src/core/alloc.rs#L36
- `@MiSawa` https://github.com/MiSawa/pomelo/blob/577c6223588d539295a71ff125d8f249e59f4146/crates/kernel/src/timer.rs#L50

19 months agoRollup merge of #83608 - Kimundi:index_many, r=Mark-Simulacrum
Manish Goregaokar [Tue, 22 Nov 2022 06:26:05 +0000 (01:26 -0500)]
Rollup merge of #83608 - Kimundi:index_many, r=Mark-Simulacrum

Add slice methods for indexing via an array of indices.

Disclaimer: It's been a while since I contributed to the main Rust repo, apologies in advance if this is large enough already that it should've been an RFC.

---

# Update:

- Based on feedback, removed the `&[T]` variant of this API, and removed the requirements for the indices to be sorted.

# Description

This adds the following slice methods to `core`:

```rust
impl<T> [T] {
    pub unsafe fn get_many_unchecked_mut<const N: usize>(&mut self, indices: [usize; N]) -> [&mut T; N];
    pub fn get_many_mut<const N: usize>(&mut self, indices: [usize; N]) -> Option<[&mut T; N]>;
}
```

This allows creating multiple mutable references to disjunct positions in a slice, which previously required writing some awkward code with `split_at_mut()` or `iter_mut()`. For the bound-checked variant, the indices are checked against each other and against the bounds of the slice, which requires `N * (N + 1) / 2` comparison operations.

This has a proof-of-concept standalone implementation here: https://crates.io/crates/index_many

Care has been taken that the implementation passes miri borrow checks, and generates straight-forward assembly (though this was only checked on x86_64).

# Example

```rust
let v = &mut [1, 2, 3, 4];
let [a, b] = v.get_many_mut([0, 2]).unwrap();
std::mem::swap(a, b);
*v += 100;
assert_eq!(v, &[3, 2, 101, 4]);
```

# Codegen Examples

<details>
  <summary>Click to expand!</summary>

Disclaimer: Taken from local tests with the standalone implementation.

## Unchecked Indexing:

```rust
pub unsafe fn example_unchecked(slice: &mut [usize], indices: [usize; 3]) -> [&mut usize; 3] {
    slice.get_many_unchecked_mut(indices)
}
```

```nasm
example_unchecked:
 mov     rcx, qword, ptr, [r9]
 mov     r8, qword, ptr, [r9, +, 8]
 mov     r9, qword, ptr, [r9, +, 16]
 lea     rcx, [rdx, +, 8*rcx]
 lea     r8, [rdx, +, 8*r8]
 lea     rdx, [rdx, +, 8*r9]
 mov     qword, ptr, [rax], rcx
 mov     qword, ptr, [rax, +, 8], r8
 mov     qword, ptr, [rax, +, 16], rdx
 ret
```

## Checked Indexing (Option):

```rust
pub unsafe fn example_option(slice: &mut [usize], indices: [usize; 3]) -> Option<[&mut usize; 3]> {
    slice.get_many_mut(indices)
}
```

```nasm
 mov     r10, qword, ptr, [r9, +, 8]
 mov     rcx, qword, ptr, [r9, +, 16]
 cmp     rcx, r10
 je      .LBB0_7
 mov     r9, qword, ptr, [r9]
 cmp     rcx, r9
 je      .LBB0_7
 cmp     rcx, r8
 jae     .LBB0_7
 cmp     r10, r9
 je      .LBB0_7
 cmp     r9, r8
 jae     .LBB0_7
 cmp     r10, r8
 jae     .LBB0_7
 lea     r8, [rdx, +, 8*r9]
 lea     r9, [rdx, +, 8*r10]
 lea     rcx, [rdx, +, 8*rcx]
 mov     qword, ptr, [rax], r8
 mov     qword, ptr, [rax, +, 8], r9
 mov     qword, ptr, [rax, +, 16], rcx
 ret
.LBB0_7:
 mov     qword, ptr, [rax], 0
 ret
```

## Checked Indexing (Panic):

```rust
pub fn example_panic(slice: &mut [usize], indices: [usize; 3]) -> [&mut usize; 3] {
    let len = slice.len();
    match slice.get_many_mut(indices) {
        Some(s) => s,
        None => {
            let tmp = indices;
            index_many::sorted_bound_check_failed(&tmp, len)
        }
    }
}
```

```nasm
example_panic:
 sub     rsp, 56
 mov     rax, qword, ptr, [r9]
 mov     r10, qword, ptr, [r9, +, 8]
 mov     r9, qword, ptr, [r9, +, 16]
 cmp     r9, r10
 je      .LBB0_6
 cmp     r9, rax
 je      .LBB0_6
 cmp     r9, r8
 jae     .LBB0_6
 cmp     r10, rax
 je      .LBB0_6
 cmp     rax, r8
 jae     .LBB0_6
 cmp     r10, r8
 jae     .LBB0_6
 lea     rax, [rdx, +, 8*rax]
 lea     r8, [rdx, +, 8*r10]
 lea     rdx, [rdx, +, 8*r9]
 mov     qword, ptr, [rcx], rax
 mov     qword, ptr, [rcx, +, 8], r8
 mov     qword, ptr, [rcx, +, 16], rdx
 mov     rax, rcx
 add     rsp, 56
 ret
.LBB0_6:
 mov     qword, ptr, [rsp, +, 32], rax
 mov     qword, ptr, [rsp, +, 40], r10
 mov     qword, ptr, [rsp, +, 48], r9
 lea     rcx, [rsp, +, 32]
 mov     edx, 3
 call    index_many::bound_check_failed
 ud2
```
</details>

# Extensions

There are multiple optional extensions to this.

## Indexing With Ranges

This could easily be expanded to allow indexing with `[I; N]` where `I: SliceIndex<Self>`.  I wanted to keep the initial implementation simple, so I didn't include it yet.

## Panicking Variant

We could also add this method:

```rust
impl<T> [T] {
    fn index_many_mut<const N: usize>(&mut self, indices: [usize; N]) -> [&mut T; N];
}
```

This would work similar to the regular index operator and panic with out-of-bound indices. The advantage would be that we could more easily ensure good codegen with a useful panic message, which is non-trivial with the `Option` variant.

This is implemented in the standalone implementation, and used as basis for the codegen examples here and there.

19 months agoRemove extra . in metadata_lib_filename_form
Steven Tang [Tue, 22 Nov 2022 06:07:19 +0000 (17:07 +1100)]
Remove extra . in metadata_lib_filename_form

19 months agoRemove a hack from compare_predicate_entailment
Michael Goulet [Tue, 22 Nov 2022 02:22:33 +0000 (02:22 +0000)]
Remove a hack from compare_predicate_entailment

19 months agoDelay bug to deduplicate diagnostics
Michael Goulet [Tue, 22 Nov 2022 01:36:35 +0000 (01:36 +0000)]
Delay bug to deduplicate diagnostics

19 months agodrive-by: style nits
Michael Goulet [Tue, 15 Nov 2022 04:06:40 +0000 (04:06 +0000)]
drive-by: style nits

19 months agoCheck generics parity between impl and trait before collecting RPITITs
Michael Goulet [Fri, 11 Nov 2022 17:36:16 +0000 (17:36 +0000)]
Check generics parity between impl and trait before collecting RPITITs

19 months agoAuto merge of #104696 - matthiaskrgr:rollup-gi1pdb0, r=matthiaskrgr
bors [Tue, 22 Nov 2022 01:35:57 +0000 (01:35 +0000)]
Auto merge of #104696 - matthiaskrgr:rollup-gi1pdb0, r=matthiaskrgr

Rollup of 11 pull requests

Successful merges:

 - #103396 (Pin::new_unchecked: discuss pinning closure captures)
 - #104416 (Fix using `include_bytes` in pattern position)
 - #104557 (Add a test case for async dyn* traits)
 - #104559 (Split `MacArgs` in two.)
 - #104597 (Probe + better error messsage for `need_migrate_deref_output_trait_object`)
 - #104656 (Move tests)
 - #104657 (Do not check transmute if has non region infer)
 - #104663 (rustdoc: factor out common button CSS)
 - #104666 (Migrate alias search result to CSS variables)
 - #104674 (Make negative_impl and negative_impl_exists take the right types)
 - #104692 (Update test's cfg-if dependency to 1.0)

Failed merges:

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

19 months agoTouch up Box<T> one-liner
David Tolnay [Mon, 21 Nov 2022 23:28:41 +0000 (15:28 -0800)]
Touch up Box<T> one-liner

19 months agoRustc_deprecated attribute superseded by deprecated
David Tolnay [Mon, 21 Nov 2022 23:18:36 +0000 (15:18 -0800)]
Rustc_deprecated attribute superseded by deprecated

19 months agoBump ptr_to_from_bits deprecation to Rust 1.67
David Tolnay [Mon, 21 Nov 2022 23:10:59 +0000 (15:10 -0800)]
Bump ptr_to_from_bits deprecation to Rust 1.67

19 months agoRollup merge of #104692 - chbaker0:libtest-cfg-if, r=thomcc
Matthias Krüger [Mon, 21 Nov 2022 23:01:12 +0000 (00:01 +0100)]
Rollup merge of #104692 - chbaker0:libtest-cfg-if, r=thomcc

Update test's cfg-if dependency to 1.0

This change was mistakenly left out of #103367

Finishes #103365

19 months agoRollup merge of #104674 - spastorino:negative-impl-tcx, r=lcnr
Matthias Krüger [Mon, 21 Nov 2022 23:01:12 +0000 (00:01 +0100)]
Rollup merge of #104674 - spastorino:negative-impl-tcx, r=lcnr

Make negative_impl and negative_impl_exists take the right types

r? `@lcnr`

19 months agoRollup merge of #104666 - GuillaumeGomez:migrate-alias-search-result, r=notriddle
Matthias Krüger [Mon, 21 Nov 2022 23:01:11 +0000 (00:01 +0100)]
Rollup merge of #104666 - GuillaumeGomez:migrate-alias-search-result, r=notriddle

Migrate alias search result to CSS variables

r? `@notriddle`

19 months agoRollup merge of #104663 - notriddle:notriddle/button-cursor, r=GuillaumeGomez
Matthias Krüger [Mon, 21 Nov 2022 23:01:11 +0000 (00:01 +0100)]
Rollup merge of #104663 - notriddle:notriddle/button-cursor, r=GuillaumeGomez

rustdoc: factor out common button CSS

19 months agoRollup merge of #104657 - hi-rustin:rustin-patch-check-transmute, r=compiler-errors
Matthias Krüger [Mon, 21 Nov 2022 23:01:10 +0000 (00:01 +0100)]
Rollup merge of #104657 - hi-rustin:rustin-patch-check-transmute, r=compiler-errors

Do not check transmute if has non region infer

close https://github.com/rust-lang/rust/issues/104609

See: https://github.com/rust-lang/rust/issues/104609#issuecomment-1320956351

r? `@compiler-errors`

19 months agoRollup merge of #104656 - c410-f3r:moar-errors, r=petrochenkov
Matthias Krüger [Mon, 21 Nov 2022 23:01:10 +0000 (00:01 +0100)]
Rollup merge of #104656 - c410-f3r:moar-errors, r=petrochenkov

Move tests

r? `@petrochenkov`

19 months agoRollup merge of #104597 - compiler-errors:need_migrate_deref_output_trait_object...
Matthias Krüger [Mon, 21 Nov 2022 23:01:09 +0000 (00:01 +0100)]
Rollup merge of #104597 - compiler-errors:need_migrate_deref_output_trait_object-msg, r=eholk

Probe + better error messsage for `need_migrate_deref_output_trait_object`

1. Use `InferCtxt::probe` in `need_migrate_deref_output_trait_object` -- that normalization *could* technically do type inference as a side-effect, and this is a lint, so it should have no side-effects.
2. Return the trait-ref so we format the error message correctly. See the UI test change -- `(dyn A + 'static)` is not a trait.

19 months agoRollup merge of #104559 - nnethercote:split-MacArgs, r=petrochenkov
Matthias Krüger [Mon, 21 Nov 2022 23:01:09 +0000 (00:01 +0100)]
Rollup merge of #104559 - nnethercote:split-MacArgs, r=petrochenkov

Split `MacArgs` in two.

`MacArgs` is an enum with three variants: `Empty`, `Delimited`, and `Eq`. It's used in two ways:
- For representing attribute macro arguments (e.g. in `AttrItem`), where all three variants are used.
- For representing function-like macros (e.g. in `MacCall` and `MacroDef`), where only the `Delimited` variant is used.

In other words, `MacArgs` is used in two quite different places due to them having partial overlap. I find this makes the code hard to read. It also leads to various unreachable code paths, and allows invalid values (such as accidentally using `MacArgs::Empty` in a `MacCall`).

This commit splits `MacArgs` in two:
- `DelimArgs` is a new struct just for the "delimited arguments" case. It is now used in `MacCall` and `MacroDef`.
- `AttrArgs` is a renaming of the old `MacArgs` enum for the attribute macro case. Its `Delimited` variant now contains a `DelimArgs`.

Various other related things are renamed as well.

These changes make the code clearer, avoids several unreachable paths, and disallows the invalid values.

r? `@petrochenkov`

19 months agoRollup merge of #104557 - eholk:dyn-star-in-traits, r=compiler-errors
Matthias Krüger [Mon, 21 Nov 2022 23:01:08 +0000 (00:01 +0100)]
Rollup merge of #104557 - eholk:dyn-star-in-traits, r=compiler-errors

Add a test case for async dyn* traits

This adds a test case that approximates async functions in dyn traits using `dyn*`. The purpose is to have an example of where we are with `dyn*` and the goal of using it for dyn traits.

Issue #102425

r? `@compiler-errors`

19 months agoRollup merge of #104416 - clubby789:fix-104414, r=eholk
Matthias Krüger [Mon, 21 Nov 2022 23:01:07 +0000 (00:01 +0100)]
Rollup merge of #104416 - clubby789:fix-104414, r=eholk

Fix using `include_bytes` in pattern position

Fix #104414

19 months agoRollup merge of #103396 - RalfJung:pinning-closure-captures, r=dtolnay
Matthias Krüger [Mon, 21 Nov 2022 23:01:06 +0000 (00:01 +0100)]
Rollup merge of #103396 - RalfJung:pinning-closure-captures, r=dtolnay

Pin::new_unchecked: discuss pinning closure captures

Regardless of how the discussion in https://github.com/rust-lang/rust/pull/102737 turns out, pinning closure captures is super subtle business and probably worth discussing separately.

19 months agoSplit `MacArgs` in two.
Nicholas Nethercote [Fri, 18 Nov 2022 00:24:21 +0000 (11:24 +1100)]
Split `MacArgs` in two.

`MacArgs` is an enum with three variants: `Empty`, `Delimited`, and `Eq`. It's
used in two ways:
- For representing attribute macro arguments (e.g. in `AttrItem`), where all
  three variants are used.
- For representing function-like macros (e.g. in `MacCall` and `MacroDef`),
  where only the `Delimited` variant is used.

In other words, `MacArgs` is used in two quite different places due to them
having partial overlap. I find this makes the code hard to read. It also leads
to various unreachable code paths, and allows invalid values (such as
accidentally using `MacArgs::Empty` in a `MacCall`).

This commit splits `MacArgs` in two:
- `DelimArgs` is a new struct just for the "delimited arguments" case. It is
  now used in `MacCall` and `MacroDef`.
- `AttrArgs` is a renaming of the old `MacArgs` enum for the attribute macro
  case. Its `Delimited` variant now contains a `DelimArgs`.

Various other related things are renamed as well.

These changes make the code clearer, avoids several unreachable paths, and
disallows the invalid values.

19 months agoAuto merge of #104533 - oli-obk:method_callee, r=lcnr
bors [Mon, 21 Nov 2022 21:51:00 +0000 (21:51 +0000)]
Auto merge of #104533 - oli-obk:method_callee, r=lcnr

Clean up and harden various methods around trait substs

r? `@lcnr`

19 months agoUpdate test's cfg-if dependency to 1.0
Collin Baker [Mon, 21 Nov 2022 21:43:34 +0000 (16:43 -0500)]
Update test's cfg-if dependency to 1.0

This change was mistakenly left out of #103367

19 months agomerge self type and substs in `trait_method`
Oli Scherer [Mon, 21 Nov 2022 15:59:15 +0000 (15:59 +0000)]
merge self type and substs in `trait_method`

19 months agoSimplify one more `TraitRef::new` site
Oli Scherer [Mon, 21 Nov 2022 15:55:37 +0000 (15:55 +0000)]
Simplify one more `TraitRef::new` site

19 months agoSimplify test
Oli Scherer [Mon, 21 Nov 2022 15:52:18 +0000 (16:52 +0100)]
Simplify test

Co-authored-by: lcnr <rust@lcnr.de>