]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoFix comment for async closure variant
Wei Liu [Fri, 6 May 2022 14:59:40 +0000 (14:59 +0000)]
Fix comment for async closure variant

2 years agoAuto merge of #96510 - m-ou-se:futex-bsd, r=Amanieu
bors [Fri, 6 May 2022 07:20:04 +0000 (07:20 +0000)]
Auto merge of #96510 - m-ou-se:futex-bsd, r=Amanieu

Use futex-based locks and thread parker on {Free, Open, DragonFly}BSD.

This switches *BSD to our futex-based locks and thread parker.

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

This is a draft, because this still needs a new version of the `libc` crate to be published that includes https://github.com/rust-lang/libc/pull/2770.

r? `@Amanieu`

2 years agoAuto merge of #96759 - compiler-errors:rollup-p4jtm92, r=compiler-errors
bors [Fri, 6 May 2022 04:56:23 +0000 (04:56 +0000)]
Auto merge of #96759 - compiler-errors:rollup-p4jtm92, r=compiler-errors

Rollup of 7 pull requests

Successful merges:

 - #96174 (mark ptr-int-transmute test as no_run)
 - #96639 (Fix typo in `offset_from` documentation)
 - #96704 (Add rotation animation on settings button when loading)
 - #96730 (Add a regression test for #64173 and #66152)
 - #96741 (Improve settings loading strategy)
 - #96744 (Implement [OsStr]::join)
 - #96747 (Add `track_caller` to `DefId::expect_local()`)

Failed merges:

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

2 years agoRollup merge of #96747 - JohnTitor:expect-local-track-caller, r=compiler-errors
Michael Goulet [Fri, 6 May 2022 02:34:27 +0000 (19:34 -0700)]
Rollup merge of #96747 - JohnTitor:expect-local-track-caller, r=compiler-errors

Add `track_caller` to `DefId::expect_local()`

Suggested in https://github.com/rust-lang/rust/issues/96738#issuecomment-1118961888.
`DefId::expect_local()` often causes ICEs (panics) and should be a good candidate to add `track_caller`.

2 years agoRollup merge of #96744 - est31:join_osstr, r=thomcc
Michael Goulet [Fri, 6 May 2022 02:34:26 +0000 (19:34 -0700)]
Rollup merge of #96744 - est31:join_osstr, r=thomcc

Implement [OsStr]::join

Implements join for `OsStr` and `OsString` slices:

```Rust
    let strings = [OsStr::new("hello"), OsStr::new("dear"), OsStr::new("world")];
    assert_eq!("hello dear world", strings.join(OsStr::new(" ")));
````

This saves one from converting to strings and back, or from implementing it manually.

2 years agoRollup merge of #96741 - GuillaumeGomez:improve-settings-loading-strategy, r=jsha
Michael Goulet [Fri, 6 May 2022 02:34:25 +0000 (19:34 -0700)]
Rollup merge of #96741 - GuillaumeGomez:improve-settings-loading-strategy, r=jsha

Improve settings loading strategy

I learned about this thanks to ```@jsha``` who suggested this approach:

It improves the settings loading strategy by loading CSS and JS at the same time to prevent the style to be applied afterwards on slow connections.

r? ```@jsha```

2 years agoRollup merge of #96730 - JohnTitor:unused-lifetimes-tests, r=compiler-errors
Michael Goulet [Fri, 6 May 2022 02:34:25 +0000 (19:34 -0700)]
Rollup merge of #96730 - JohnTitor:unused-lifetimes-tests, r=compiler-errors

Add a regression test for #64173 and #66152

Closes #64173
Closes #66152

Mixed the code as the root cause seems the same.

2 years agoRollup merge of #96704 - GuillaumeGomez:rotation-animation, r=jsha
Michael Goulet [Fri, 6 May 2022 02:34:24 +0000 (19:34 -0700)]
Rollup merge of #96704 - GuillaumeGomez:rotation-animation, r=jsha

Add rotation animation on settings button when loading

As discussed, I added an animation when the settings JS file is loading (I voluntarily made the timeout at the end of the `settings.js` super long so we can see what the animation looks like):

https://user-images.githubusercontent.com/3050060/166693243-816a08b7-5e39-4142-acd3-686ad9950d8e.mp4

r? ````@jsha````

2 years agoRollup merge of #96639 - adpaco-aws:fix-offset-from-typo, r=scottmcm
Michael Goulet [Fri, 6 May 2022 02:34:23 +0000 (19:34 -0700)]
Rollup merge of #96639 - adpaco-aws:fix-offset-from-typo, r=scottmcm

Fix typo in `offset_from` documentation

Small fix for what I think is a typo in the `offset_from` documentation.

Someone reading this may understand that the distance in bytes is obtained by dividing the distance by `mem::size_of::<T>()`, but here we just want to define "units of T" in terms of bytes (i.e., units of T == bytes / `mem::size_of::<T>()`).

2 years agoRollup merge of #96174 - RalfJung:no-run-transmute, r=scottmcm
Michael Goulet [Fri, 6 May 2022 02:34:22 +0000 (19:34 -0700)]
Rollup merge of #96174 - RalfJung:no-run-transmute, r=scottmcm

mark ptr-int-transmute test as no_run

This causes [CI failures in Miri](https://github.com/rust-lang/miri-test-libstd/runs/6062500259?check_suite_focus=true) since ptr-int-transmutes are rejected there (when strict provenance is enabled).

2 years agoAuto merge of #96520 - lcnr:general-incoherent-impls, r=petrochenkov
bors [Thu, 5 May 2022 23:24:36 +0000 (23:24 +0000)]
Auto merge of #96520 - lcnr:general-incoherent-impls, r=petrochenkov

generalize "incoherent impls" impl for user defined types

To allow the move of `trait Error` into core.

continues the work from #94963, finishes https://github.com/rust-lang/compiler-team/issues/487

r? `@petrochenkov` cc `@yaahc`

2 years agoAdd `track_caller` to `DefId::expect_local()`
Yuki Okushi [Thu, 5 May 2022 22:28:06 +0000 (07:28 +0900)]
Add `track_caller` to `DefId::expect_local()`

2 years agoImplement [OsStr]::join
est31 [Thu, 5 May 2022 19:38:15 +0000 (21:38 +0200)]
Implement [OsStr]::join

2 years agoRemove condvar::two_mutexes test.
Mara Bos [Thu, 5 May 2022 19:47:13 +0000 (21:47 +0200)]
Remove condvar::two_mutexes test.

We don't guarantee this panics. On most platforms it doesn't anymore.

2 years agoAuto merge of #96735 - flip1995:clippyup, r=Manishearth
bors [Thu, 5 May 2022 19:28:41 +0000 (19:28 +0000)]
Auto merge of #96735 - flip1995:clippyup, r=Manishearth

Update Clippy

r? `@Manishearth`

2 years agoImprove settings loading strategy by loading CSS and JS at the same time to prevent...
Guillaume Gomez [Thu, 5 May 2022 18:19:40 +0000 (20:19 +0200)]
Improve settings loading strategy by loading CSS and JS at the same time to prevent the style to be applied afterwards on slow connections

2 years agoAuto merge of #96734 - matthiaskrgr:rollup-hng33tb, r=matthiaskrgr
bors [Thu, 5 May 2022 16:59:54 +0000 (16:59 +0000)]
Auto merge of #96734 - matthiaskrgr:rollup-hng33tb, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #95359 (Update `int_roundings` methods from feedback)
 - #95843 (Improve Rc::new_cyclic and Arc::new_cyclic documentation)
 - #96507 (Suggest calling `Self::associated_function()`)
 - #96635 (Use "strict" mode in JS scripts)
 - #96673 (Report that opaque types are not allowed in impls even in the presence of other errors)
 - #96682 (Show invisible delimeters (within comments) when pretty printing.)
 - #96714 (interpret/validity: debug-check ScalarPair layout information)

Failed merges:

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

2 years agoUpdate Cargo.lock
flip1995 [Thu, 5 May 2022 14:13:10 +0000 (15:13 +0100)]
Update Cargo.lock

2 years agoMerge commit '7c21f91b15b7604f818565646b686d90f99d1baf' into clippyup
flip1995 [Thu, 5 May 2022 14:12:52 +0000 (15:12 +0100)]
Merge commit '7c21f91b15b7604f818565646b686d90f99d1baf' into clippyup

2 years agoRollup merge of #96714 - RalfJung:scalar-pair-debug, r=oli-obk
Matthias Krüger [Thu, 5 May 2022 13:43:07 +0000 (15:43 +0200)]
Rollup merge of #96714 - RalfJung:scalar-pair-debug, r=oli-obk

interpret/validity: debug-check ScalarPair layout information

This would have caught https://github.com/rust-lang/rust/issues/96158.
I ran the Miri test suite and it still passes.

r? `@oli-obk`

2 years agoRollup merge of #96682 - nnethercote:show-invisible-delims, r=petrochenkov
Matthias Krüger [Thu, 5 May 2022 13:43:05 +0000 (15:43 +0200)]
Rollup merge of #96682 - nnethercote:show-invisible-delims, r=petrochenkov

Show invisible delimeters (within comments) when pretty printing.

Because invisible syntax is really hard to work with!

r? `@petrochenkov`

2 years agoRollup merge of #96673 - oli-obk:tait_impl_diagnostic, r=petrochenkov
Matthias Krüger [Thu, 5 May 2022 13:43:05 +0000 (15:43 +0200)]
Rollup merge of #96673 - oli-obk:tait_impl_diagnostic, r=petrochenkov

Report that opaque types are not allowed in impls even in the presence of other errors

fixes  #96569

before this PR those useful errors were hidden because either `unused parameter` or `only traits defined in the current crate can be implemented for arbitrary types` got emitted first.

2 years agoRollup merge of #96635 - GuillaumeGomez:js-script-mode, r=notriddle
Matthias Krüger [Thu, 5 May 2022 13:43:04 +0000 (15:43 +0200)]
Rollup merge of #96635 - GuillaumeGomez:js-script-mode, r=notriddle

Use "strict" mode in JS scripts

Part of #93058.

r? `@notriddle`

2 years agoRollup merge of #96507 - TaKO8Ki:suggest-calling-associated-function, r=lcnr
Matthias Krüger [Thu, 5 May 2022 13:43:03 +0000 (15:43 +0200)]
Rollup merge of #96507 - TaKO8Ki:suggest-calling-associated-function, r=lcnr

Suggest calling `Self::associated_function()`

closes #96453

2 years agoRollup merge of #95843 - GuillaumeGomez:improve-new-cyclic-doc, r=m-ou-se
Matthias Krüger [Thu, 5 May 2022 13:43:02 +0000 (15:43 +0200)]
Rollup merge of #95843 - GuillaumeGomez:improve-new-cyclic-doc, r=m-ou-se

Improve Rc::new_cyclic and Arc::new_cyclic documentation

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

cc `@CAD97` (since I used your explanations)

2 years agoRollup merge of #95359 - jhpratt:int_roundings, r=joshtriplett
Matthias Krüger [Thu, 5 May 2022 13:43:00 +0000 (15:43 +0200)]
Rollup merge of #95359 - jhpratt:int_roundings, r=joshtriplett

Update `int_roundings` methods from feedback

This updates `#![feature(int_roundings)]` (#88581) from feedback. All methods now take `NonZeroX`. The documentation makes clear that they panic in debug mode and wrap in release mode.

r? `@joshtriplett`

`@rustbot` label +T-libs +T-libs-api +S-waiting-on-review

2 years agoAuto merge of #8788 - flip1995:rustup, r=xFrednet,flip1995
bors [Thu, 5 May 2022 13:12:09 +0000 (13:12 +0000)]
Auto merge of #8788 - flip1995:rustup, r=xFrednet,flip1995

Rustup

r? `@ghost`

changelog: move trait_duplication_in_bounds and type_repetition_in_bounds to nursery temporarily. This could already be reverted before the release. Check the Clippy in the Rust repo beta branch when writing this changelog.

2 years agoFix ICE in EarlyAttribtues lints
flip1995 [Thu, 5 May 2022 13:10:06 +0000 (14:10 +0100)]
Fix ICE in EarlyAttribtues lints

2 years agoHACK: Move buggy lints to nursery
flip1995 [Thu, 5 May 2022 12:32:31 +0000 (13:32 +0100)]
HACK: Move buggy lints to nursery

Those lints are trait_duplication_in_bounds and
type_repetition_in_bounds. I don't think those can be fixed on the
Clippy side alone, but need changes in the compiler. So let's move them
to nursery to get the sync through and then fix them on the rustc side.

Also adds a regression test that has to be fixed before they can be
moved back to pedantic.

2 years agoBump nightly version -> 2022-05-05
flip1995 [Thu, 5 May 2022 12:32:18 +0000 (13:32 +0100)]
Bump nightly version -> 2022-05-05

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 5 May 2022 12:01:37 +0000 (13:01 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoupdate error messages and explicitly mention them in tests
lcnr [Thu, 5 May 2022 12:29:24 +0000 (14:29 +0200)]
update error messages and explicitly mention them in tests

2 years agoAuto merge of #91779 - ridwanabdillahi:natvis, r=michaelwoerister
bors [Thu, 5 May 2022 12:26:38 +0000 (12:26 +0000)]
Auto merge of #91779 - ridwanabdillahi:natvis, r=michaelwoerister

Add a new Rust attribute to support embedding debugger visualizers

Implemented [this RFC](https://github.com/rust-lang/rfcs/pull/3191) to add support for embedding debugger visualizers into a PDB.

Added a new attribute `#[debugger_visualizer]` and updated the `CrateMetadata` to store debugger visualizers for crate dependencies.

RFC: https://github.com/rust-lang/rfcs/pull/3191

2 years agoAdd a regression test for #64173 and #66152
Yuki Okushi [Thu, 5 May 2022 11:03:34 +0000 (20:03 +0900)]
Add a regression test for #64173 and #66152

2 years agoAuto merge of #96649 - tbu-:pr_to_ipv4_loopback_doc, r=m-ou-se
bors [Thu, 5 May 2022 09:45:53 +0000 (09:45 +0000)]
Auto merge of #96649 - tbu-:pr_to_ipv4_loopback_doc, r=m-ou-se

Make it clear that `to_ipv4` returns an IPv4 address for the IPv6 loopback

2 years agoAdd rotation animation on settings button when loading
Guillaume Gomez [Wed, 4 May 2022 13:39:18 +0000 (15:39 +0200)]
Add rotation animation on settings button when loading

2 years agoUse "strict" mode in JS scripts
Guillaume Gomez [Mon, 2 May 2022 12:32:56 +0000 (14:32 +0200)]
Use "strict" mode in JS scripts

2 years agoforbid empty impls for types with incoherent impls
lcnr [Thu, 5 May 2022 07:37:50 +0000 (09:37 +0200)]
forbid empty impls for types with incoherent impls

2 years agoremove unnecessary check
lcnr [Fri, 29 Apr 2022 13:55:54 +0000 (15:55 +0200)]
remove unnecessary check

2 years agogeneralize "incoherent impls" impl for custom types
lcnr [Thu, 28 Apr 2022 14:26:30 +0000 (16:26 +0200)]
generalize "incoherent impls" impl for custom types

2 years agogive it a scary name
Ralf Jung [Thu, 5 May 2022 07:55:38 +0000 (09:55 +0200)]
give it a scary name

2 years agosuggest calling `Self::associated_function()`
Takayuki Maeda [Thu, 28 Apr 2022 07:54:28 +0000 (16:54 +0900)]
suggest calling `Self::associated_function()`

do not suggest when trait_ref is some

Update compiler/rustc_resolve/src/late/diagnostics.rs

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

add a test for functions with some params

refactor debug log

2 years agoAuto merge of #96630 - m-ysk:fix/issue-88038, r=notriddle
bors [Thu, 5 May 2022 07:25:18 +0000 (07:25 +0000)]
Auto merge of #96630 - m-ysk:fix/issue-88038, r=notriddle

Include nonexported macro_rules! macros in the doctest target

Fixes #88038

This PR aims to include nonexported `macro_rules!` macros in the doctest target. For more details, please see the above issue.

2 years agoAuto merge of #96626 - thomcc:rand-bump, r=m-ou-se
bors [Thu, 5 May 2022 05:08:44 +0000 (05:08 +0000)]
Auto merge of #96626 - thomcc:rand-bump, r=m-ou-se

Avoid using `rand::thread_rng` in the stdlib benchmarks.

This is kind of an anti-pattern because it introduces extra nondeterminism for no real reason. In thread_rng's case this comes both from the random seed and also from the reseeding operations it does, which occasionally does syscalls (which adds additional nondeterminism). The impact of this would be pretty small in most cases, but it's a good practice to avoid (particularly because avoiding it was not hard).

Anyway, several of our benchmarks already did the right thing here anyway, so the change was pretty easy and mostly just applying it more universally. That said, the stdlib benchmarks aren't particularly stable (nor is our benchmark framework particularly great), so arguably this doesn't matter that much in practice.

~~Anyway, this also bumps the `rand` dev-dependency to 0.8, since it had fallen somewhat out of date.~~ Nevermind, too much of a headache.

2 years agoUpdate `int_roundings` methods from feedback
Jacob Pratt [Sun, 27 Mar 2022 07:15:21 +0000 (03:15 -0400)]
Update `int_roundings` methods from feedback

2 years agoAuto merge of #96720 - JohnTitor:rollup-9jaaekr, r=JohnTitor
bors [Thu, 5 May 2022 02:49:16 +0000 (02:49 +0000)]
Auto merge of #96720 - JohnTitor:rollup-9jaaekr, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #96603 (Enable full revision in const generics ui tests)
 - #96616 (Relax memory ordering used in `min_stack`)
 - #96619 (Relax memory ordering used in SameMutexCheck)
 - #96628 (Stabilize `bool::then_some`)
 - #96658 (Move callback to the () => {} syntax.)
 - #96677 (Add more tests for label-break-value)
 - #96697 (Enable tracing for all queries)

Failed merges:

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

2 years agoRollup merge of #96697 - oli-obk:trace_queries, r=michaelwoerister
Yuki Okushi [Thu, 5 May 2022 01:20:38 +0000 (10:20 +0900)]
Rollup merge of #96697 - oli-obk:trace_queries, r=michaelwoerister

Enable tracing for all queries

This allows you to log everything within a specific query, e.g.

```
env RUSTC_LOG=[mir_borrowck]
```

dumping all borrowck queries may be a bit verbose, so you can also restrict it to just an item of your choice:

```
env RUSTC_LOG=[mir_borrowck{key=\.\*name_of_item\.\*}]
```

the regex `.*` in the key name are because the key is a debug printed DefId, so you'd get all kinds of things like hashes in there. The tracing logs will show you the key, so you can restrict it further if you want.

2 years agoRollup merge of #96677 - jyn514:label-break-value-tests, r=petrochenkov
Yuki Okushi [Thu, 5 May 2022 01:20:37 +0000 (10:20 +0900)]
Rollup merge of #96677 - jyn514:label-break-value-tests, r=petrochenkov

Add more tests for label-break-value

Helps with https://github.com/rust-lang/rust/issues/48594. The tests are adapted from https://github.com/rust-lang/rust/issues/48594#issuecomment-421625182.

2 years agoRollup merge of #96658 - Folyd:es6, r=GuillaumeGomez
Yuki Okushi [Thu, 5 May 2022 01:20:36 +0000 (10:20 +0900)]
Rollup merge of #96658 - Folyd:es6, r=GuillaumeGomez

Move callback to the () => {} syntax.

Part of https://github.com/rust-lang/rust/issues/93058.

r? `@GuillaumeGomez`

2 years agoRollup merge of #96628 - joshtriplett:stabilize-then-some, r=m-ou-se
Yuki Okushi [Thu, 5 May 2022 01:20:35 +0000 (10:20 +0900)]
Rollup merge of #96628 - joshtriplett:stabilize-then-some, r=m-ou-se

Stabilize `bool::then_some`

FCP completed in https://github.com/rust-lang/rust/issues/80967

2 years agoRollup merge of #96619 - akiekintveld:same_mutex_check_relaxed_ordering, r=m-ou-se
Yuki Okushi [Thu, 5 May 2022 01:20:34 +0000 (10:20 +0900)]
Rollup merge of #96619 - akiekintveld:same_mutex_check_relaxed_ordering, r=m-ou-se

Relax memory ordering used in SameMutexCheck

`SameMutexCheck` only requires atomicity for `self.addr`, but does not need ordering of other memory accesses in either the success or failure case. Using `Relaxed`, the code still correctly handles the case when two threads race to store an address.

2 years agoRollup merge of #96616 - akiekintveld:min_stack_relaxed_ordering, r=joshtriplett
Yuki Okushi [Thu, 5 May 2022 01:20:33 +0000 (10:20 +0900)]
Rollup merge of #96616 - akiekintveld:min_stack_relaxed_ordering, r=joshtriplett

Relax memory ordering used in `min_stack`

`min_stack` does not provide any synchronization guarantees to its callers, and only requires atomicity for `MIN` itself, so relaxed memory ordering is sufficient.

2 years agoRollup merge of #96603 - Alexendoo:const-generics-tests, r=Mark-Simulacrum
Yuki Okushi [Thu, 5 May 2022 01:20:32 +0000 (10:20 +0900)]
Rollup merge of #96603 - Alexendoo:const-generics-tests, r=Mark-Simulacrum

Enable full revision in const generics ui tests

The ICEs no longer occur since https://github.com/rust-lang/rust/pull/95776 so the revisions can be reenabled

Also adds some regression tests for issues that no longer ICE because of it

closes #77357
closes #78180
closes #83993

2 years agoAuto merge of #96593 - jackh726:issue-93262, r=compiler-errors
bors [Thu, 5 May 2022 00:24:48 +0000 (00:24 +0000)]
Auto merge of #96593 - jackh726:issue-93262, r=compiler-errors

Revert "Prefer projection candidates instead of param_env candidates for Sized predicates"

Fixes #93262
Reopens #89352

This was a hack that seemed to have no negative side-effects at the time. Given that the latter has a workaround and likely less common than the former, it makes sense to revert this change.

r? `@compiler-errors`

2 years agoCleanup broken doc links.
ridwanabdillahi [Thu, 5 May 2022 00:17:57 +0000 (17:17 -0700)]
Cleanup broken doc links.

2 years agoMake it clear that `to_ipv4` returns an IPv4 address for the IPv6 loopback
Tobias Bucher [Mon, 2 May 2022 21:20:51 +0000 (23:20 +0200)]
Make it clear that `to_ipv4` returns an IPv4 address for the IPv6 loopback

2 years agoAuto merge of #96546 - nnethercote:overhaul-MacArgs, r=petrochenkov
bors [Wed, 4 May 2022 21:16:28 +0000 (21:16 +0000)]
Auto merge of #96546 - nnethercote:overhaul-MacArgs, r=petrochenkov

Overhaul `MacArgs`

Motivation:
- Clarify some code that I found hard to understand.
- Eliminate one use of three places where `TokenKind::Interpolated` values are created.

r? `@petrochenkov`

2 years agoAuto merge of #96546 - nnethercote:overhaul-MacArgs, r=petrochenkov
bors [Wed, 4 May 2022 21:16:28 +0000 (21:16 +0000)]
Auto merge of #96546 - nnethercote:overhaul-MacArgs, r=petrochenkov

Overhaul `MacArgs`

Motivation:
- Clarify some code that I found hard to understand.
- Eliminate one use of three places where `TokenKind::Interpolated` values are created.

r? `@petrochenkov`

2 years agoAdd a comment on `TokenKind::Interpolated`.
Nicholas Nethercote [Wed, 4 May 2022 06:12:09 +0000 (16:12 +1000)]
Add a comment on `TokenKind::Interpolated`.

2 years agoOverhaul `MacArgs::Eq`.
Nicholas Nethercote [Thu, 28 Apr 2022 20:52:01 +0000 (06:52 +1000)]
Overhaul `MacArgs::Eq`.

The value in `MacArgs::Eq` is currently represented as a `Token`.
Because of `TokenKind::Interpolated`, `Token` can be either a token or
an arbitrary AST fragment. In practice, a `MacArgs::Eq` starts out as a
literal or macro call AST fragment, and then is later lowered to a
literal token. But this is very non-obvious. `Token` is a much more
general type than what is needed.

This commit restricts things, by introducing a new type `MacArgsEqKind`
that is either an AST expression (pre-lowering) or an AST literal
(post-lowering). The downside is that the code is a bit more verbose in
a few places. The benefit is that makes it much clearer what the
possibilities are (though also shorter in some other places). Also, it
removes one use of `TokenKind::Interpolated`, taking us a step closer to
removing that variant, which will let us make `Token` impl `Copy` and
remove many "handle Interpolated" code paths in the parser.

Things to note:
- Error messages have improved. Messages like this:
  ```
  unexpected token: `"bug" + "found"`
  ```
  now say "unexpected expression", which makes more sense. Although
  arbitrary expressions can exist within tokens thanks to
  `TokenKind::Interpolated`, that's not obvious to anyone who doesn't
  know compiler internals.
- In `parse_mac_args_common`, we no longer need to collect tokens for
  the value expression.

2 years agoOverhaul `MacArgs::Eq`.
Nicholas Nethercote [Thu, 28 Apr 2022 20:52:01 +0000 (06:52 +1000)]
Overhaul `MacArgs::Eq`.

The value in `MacArgs::Eq` is currently represented as a `Token`.
Because of `TokenKind::Interpolated`, `Token` can be either a token or
an arbitrary AST fragment. In practice, a `MacArgs::Eq` starts out as a
literal or macro call AST fragment, and then is later lowered to a
literal token. But this is very non-obvious. `Token` is a much more
general type than what is needed.

This commit restricts things, by introducing a new type `MacArgsEqKind`
that is either an AST expression (pre-lowering) or an AST literal
(post-lowering). The downside is that the code is a bit more verbose in
a few places. The benefit is that makes it much clearer what the
possibilities are (though also shorter in some other places). Also, it
removes one use of `TokenKind::Interpolated`, taking us a step closer to
removing that variant, which will let us make `Token` impl `Copy` and
remove many "handle Interpolated" code paths in the parser.

Things to note:
- Error messages have improved. Messages like this:
  ```
  unexpected token: `"bug" + "found"`
  ```
  now say "unexpected expression", which makes more sense. Although
  arbitrary expressions can exist within tokens thanks to
  `TokenKind::Interpolated`, that's not obvious to anyone who doesn't
  know compiler internals.
- In `parse_mac_args_common`, we no longer need to collect tokens for
  the value expression.

2 years agointerpret: debug-check ScalarPair layout information
Ralf Jung [Wed, 4 May 2022 20:47:46 +0000 (22:47 +0200)]
interpret: debug-check ScalarPair layout information

2 years agoEnable tracing for all queryies
Oli Scherer [Wed, 4 May 2022 08:30:13 +0000 (08:30 +0000)]
Enable tracing for all queryies

2 years agoAuto merge of #96683 - nnethercote:speed-up-Token-ident-lifetime, r=petrochenkov
bors [Wed, 4 May 2022 15:24:02 +0000 (15:24 +0000)]
Auto merge of #96683 - nnethercote:speed-up-Token-ident-lifetime, r=petrochenkov

Speed up `Token::{ident,lifetime}`

Some speed and cleanliness improvements.

r? `@petrochenkov`

2 years agoAuto merge of #8575 - FoseFx:trim_split_whitespace2, r=flip1995
bors [Wed, 4 May 2022 13:31:19 +0000 (13:31 +0000)]
Auto merge of #8575 - FoseFx:trim_split_whitespace2, r=flip1995

add `trim_split_whitespace`

Closes #8521

changelog: [`trim_split_whitespace`]

2 years agoImprove Rc::new_cyclic and Arc::new_cyclic documentation
Guillaume Gomez [Sat, 9 Apr 2022 12:14:06 +0000 (14:14 +0200)]
Improve Rc::new_cyclic and Arc::new_cyclic documentation

2 years agoAuto merge of #8780 - Alexendoo:init-numbered-field-alias, r=flip1995
bors [Wed, 4 May 2022 13:17:35 +0000 (13:17 +0000)]
Auto merge of #8780 - Alexendoo:init-numbered-field-alias, r=flip1995

Ignore type aliases in `init_numbered_fields`

changelog: Ignore type aliases in [`init_numbered_fields`]

Fixes #8638

2 years agoadd trim_split_whitespace
Max Baumann [Tue, 22 Mar 2022 20:15:09 +0000 (21:15 +0100)]
add trim_split_whitespace

2 years agoAuto merge of #94775 - oli-obk:operand_order, r=davidtwco
bors [Wed, 4 May 2022 12:54:02 +0000 (12:54 +0000)]
Auto merge of #94775 - oli-obk:operand_order, r=davidtwco

Fix constants not getting dropped if part of a diverging expression

fixes https://github.com/rust-lang/rust/issues/90762

cc `@RalfJung`

2 years agoStabilize `bool::then_some`
Josh Triplett [Mon, 2 May 2022 08:12:35 +0000 (01:12 -0700)]
Stabilize `bool::then_some`

2 years agoAuto merge of #96695 - JohnTitor:rollup-oo4fc1h, r=JohnTitor
bors [Wed, 4 May 2022 09:55:51 +0000 (09:55 +0000)]
Auto merge of #96695 - JohnTitor:rollup-oo4fc1h, r=JohnTitor

Rollup of 6 pull requests

Successful merges:

 - #96597 (openbsd: unbreak build on native platform)
 - #96662 (Fix typo in lint levels doc)
 - #96668 (Fix flaky rustdoc-ui test because it did not replace time result)
 - #96679 (Quick fix for #96223.)
 - #96684 (Update `ProjectionElem::Downcast` documentation)
 - #96686 (Add some TAIT-related tests)

Failed merges:

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

2 years agoGenerate an intermediate temporary for `Drop` constants.
Oli Scherer [Wed, 9 Mar 2022 17:10:48 +0000 (17:10 +0000)]
Generate an intermediate temporary for `Drop` constants.

To limit the fallout from this, don't do this for the last (or only) operand in an rvalue.

2 years agoRollup merge of #96686 - JohnTitor:impl-trait-tests, r=oli-obk
Yuki Okushi [Wed, 4 May 2022 08:13:16 +0000 (17:13 +0900)]
Rollup merge of #96686 - JohnTitor:impl-trait-tests, r=oli-obk

Add some TAIT-related tests

Closes #53398
Closes #58662
Closes #89952
Closes #94429

r? `@oli-obk` as you're familiar with it

2 years agoRollup merge of #96684 - tmiasko:mir-downcast, r=petrochenkov
Yuki Okushi [Wed, 4 May 2022 08:13:15 +0000 (17:13 +0900)]
Rollup merge of #96684 - tmiasko:mir-downcast, r=petrochenkov

Update `ProjectionElem::Downcast` documentation

`ProjectionElem:::Downcast` is used when downcasting to a variant of
an enum or a generator, regardless of the number of variants.

2 years agoRollup merge of #96679 - ricked-twice:issue-96223-fix, r=jackh726
Yuki Okushi [Wed, 4 May 2022 08:13:14 +0000 (17:13 +0900)]
Rollup merge of #96679 - ricked-twice:issue-96223-fix, r=jackh726

Quick fix for #96223.

This PR is a quick fix regarding #96223.

As mentioned in the issue, others modification could be added to not elide types with bound vars from suggestions.

Special thanks to ``@jackh726`` for mentoring and ``@Manishearth`` for minimal test case.

r? ``@jackh726``

2 years agoRollup merge of #96668 - GuillaumeGomez:fix-rustdoc-ui-flaky-test, r=petrochenkov
Yuki Okushi [Wed, 4 May 2022 08:13:13 +0000 (17:13 +0900)]
Rollup merge of #96668 - GuillaumeGomez:fix-rustdoc-ui-flaky-test, r=petrochenkov

Fix flaky rustdoc-ui test because it did not replace time result

As mentioned in https://github.com/rust-lang/rust/pull/93715: a test is flaky because I forgot to replace the time value.

This PR fixes it.

r? ``@petrochenkov``

2 years agoRollup merge of #96662 - rockboynton:master, r=GuillaumeGomez
Yuki Okushi [Wed, 4 May 2022 08:13:12 +0000 (17:13 +0900)]
Rollup merge of #96662 - rockboynton:master, r=GuillaumeGomez

Fix typo in lint levels doc

2 years agoRollup merge of #96597 - semarie:split_debuginfo-unix, r=davidtwco,Mark-Simulacrum
Yuki Okushi [Wed, 4 May 2022 08:13:11 +0000 (17:13 +0900)]
Rollup merge of #96597 - semarie:split_debuginfo-unix, r=davidtwco,Mark-Simulacrum

openbsd: unbreak build on native platform

after #95612, only linux and windows target are build with `-Zunstable-options`, but others platforms might use `-Csplit-debuginfo`

currently, without this PR, the build of rustc on OpenBSD fails with:

```
Building stage0 tool unstable-book-gen (x86_64-unknown-openbsd)
running: "/data/semarie/build-rust/install_dir/beta/bin/cargo" "build" "--target" "x86_64-unknown-openbsd" "-Zbinary-dep-depinfo" "-j" "4" "-v" "--release" "--frozen" "--manifest-path"
"/data/semarie/build-rust/build_dir/rustc-nightly-src/src/tools/unstable-book-gen/Cargo.toml" "--message-format" "json-render-diagnostics"
error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `/data/semarie/build-rust/build_dir/build/bootstrap/debug/rustc - --crate-name ___ --print=file-names --cfg=bootstrap -Csymbol-mangling-version=v0 -Zmacro-backtrace -Clink-args=-Wl,-z,origin
'-Clink-args=-Wl,-rpath,$ORIGIN/../lib' -Csplit-debuginfo=off -Ztls-model=initial-exec --target x86_64-unknown-openbsd --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro
--print=sysroot --print=cfg` (exit status: 1)
  --- stdout

  Did not run successfully: exit status: 1
  "/data/semarie/build-rust/install_dir/beta/bin/rustc" "-" "--crate-name" "___" "--print=file-names" "--cfg=bootstrap" "-Csymbol-mangling-version=v0" "-Zmacro-backtrace" "-Clink-args=-Wl,-z,origin" "-Clink-args=-Wl,-rpath,$ORIGIN/../lib"
"-Csplit-debuginfo=off" "-Ztls-model=initial-exec" "--target" "x86_64-unknown-openbsd" "--crate-type" "bin" "--crate-type" "rlib" "--crate-type" "dylib" "--crate-type" "cdylib" "--crate-type" "staticlib" "--crate-type" "proc-macro"
"--print=sysroot" "--print=cfg" "-Wrust_2018_idioms" "-Wunused_lifetimes" "-Wsemicolon_in_expressions_from_macros" "-Dwarnings" "--sysroot" "/data/semarie/build-rust/install_dir/beta"
  -------------

  --- stderr
  error: `-Csplit-debuginfo` is unstable on this platform

command did not execute successfully: "/data/semarie/build-rust/install_dir/beta/bin/cargo.bin" "build" "--target" "x86_64-unknown-openbsd" "-Zbinary-dep-depinfo" "-j" "4" "-v" "--release" "--frozen" "--manifest-path"
```

I am suspecting that all unix might be affected, but I am unsure about the right conditional to use. so I only added "openbsd" target inside it as I am able to test it.

rustc nightly built correctly with this PR on openbsd.

2 years agoAuto merge of #96693 - ehuss:update-cargo, r=ehuss
bors [Wed, 4 May 2022 07:31:58 +0000 (07:31 +0000)]
Auto merge of #96693 - ehuss:update-cargo, r=ehuss

Update cargo

7 commits in f63f23ff1f1a12ede8585bbd1bbf0c536e50293d..a44758ac805600edbb6ba51e7e6fb81a6077c0cd
2022-04-28 03:15:50 +0000 to 2022-05-04 02:29:34 +0000
- Add support for `-Zbuild-std` to `cargo fetch` (rust-lang/cargo#10129)
- Migrate tests of `cargo-init` to snapbox (rust-lang/cargo#10620)
- dedupe toml_edit crate, followup rust-lang/cargo#10603 (rust-lang/cargo#10619)
- Update GitHub Actions actions/checkout@v2 to v3 (rust-lang/cargo#10618)
- Integrate snapbox in with cargo-test-support (rust-lang/cargo#10581)
- Fix zsh completion (rust-lang/cargo#10613)
- Update documentation for workspace inheritance (rust-lang/cargo#10611)

2 years agoAdd regression test
Oli Scherer [Wed, 9 Mar 2022 15:27:28 +0000 (15:27 +0000)]
Add regression test

2 years agoRevert #92191 Prefer projection candidates instead of param_env candidates for Sized...
Jack Huey [Sun, 1 May 2022 01:00:57 +0000 (21:00 -0400)]
Revert #92191 Prefer projection candidates instead of param_env candidates for Sized predicates

2 years agoUpdate cargo
Eric Huss [Wed, 4 May 2022 05:48:05 +0000 (22:48 -0700)]
Update cargo

2 years agoAuto merge of #96447 - petrochenkov:docregr, r=GuillaumeGomez
bors [Wed, 4 May 2022 05:01:47 +0000 (05:01 +0000)]
Auto merge of #96447 - petrochenkov:docregr, r=GuillaumeGomez

rustdoc: Resolve doc links on fields during early resolution

Another subset of https://github.com/rust-lang/rust/pull/94857 which fixes https://github.com/rust-lang/rust/issues/96429.

This case regressed in https://github.com/rust-lang/rust/pull/96135 when `may_have_doc_links`-based filtering was introduced.
Before that filtering structs could collect traits in scope for their fields, but after the filtering structs won't collect anything if they don't have doc comments on them, so we have to visit fields too.

2 years agoMove callback to the () => {} syntax.
Folyd [Tue, 3 May 2022 04:03:17 +0000 (12:03 +0800)]
Move callback to the () => {} syntax.

Fix lint

Fix main.js

Restore anonymous functions

Fix

Fix more

2 years agoAuto merge of #96353 - estebank:issue-95413, r=compiler-errors
bors [Wed, 4 May 2022 01:58:23 +0000 (01:58 +0000)]
Auto merge of #96353 - estebank:issue-95413, r=compiler-errors

When suggesting to import an item, also suggest changing the path if appropriate

When we don't find an item we search all of them for an appropriate
import and suggest `use`ing it. This is sometimes done for expressions
that have paths with more than one segment. We now also suggest changing
that path to work with the `use`.

Fix #95413

2 years agoAdd some TAIT-related tests
Yuki Okushi [Wed, 4 May 2022 00:12:50 +0000 (09:12 +0900)]
Add some TAIT-related tests

2 years agoShow invisible delimeters (within comments) when pretty printing.
Nicholas Nethercote [Fri, 29 Apr 2022 07:58:41 +0000 (17:58 +1000)]
Show invisible delimeters (within comments) when pretty printing.

2 years agoAuto merge of #95380 - compiler-errors:unit-destructure-assign, r=nikomatsakis
bors [Tue, 3 May 2022 22:29:58 +0000 (22:29 +0000)]
Auto merge of #95380 - compiler-errors:unit-destructure-assign, r=nikomatsakis

Fix unit struct/enum variant in destructuring assignment

See https://github.com/rust-lang/rfcs/blob/master/text/2909-destructuring-assignment.md#guide-level-explanation, "including **unit** and tuple structs"

Fixes #94319

2 years agoAuto merge of #8779 - binggh:easier-needless-late-init, r=llogiq
bors [Tue, 3 May 2022 20:42:35 +0000 (20:42 +0000)]
Auto merge of #8779 - binggh:easier-needless-late-init, r=llogiq

Easier readability for `needless_late_init` message

Closes #8530

Updated the lint to use a `MultiSpan`, showing where the `let` statement was first used and where the initialisation statement was done, as in the format described, for easier readability.

Was wondering why, when pushing the span label for the initialisation statement, that sometimes the prior statement above the initialisation statement gets pulled into the output as well - any insight is appreciated!

---

changelog: [`needless_late_init`]: Now shows the `let` statement where it was first initialized

2 years agoUpdate `ProjectionElem::Downcast` documentation
Tomasz Miąsko [Tue, 3 May 2022 00:00:00 +0000 (00:00 +0000)]
Update `ProjectionElem::Downcast` documentation

`ProjectionElem:::Downcast` is used when downcasting to a variant of
an enum or a generator, regardless of the number of variants.

2 years agoTaking review hints into account.
ricked-twice [Tue, 3 May 2022 20:23:30 +0000 (22:23 +0200)]
Taking review hints into account.

2 years agoRemove unnecessary `NtIdent` in `Token::is_whole_expr`.
Nicholas Nethercote [Tue, 3 May 2022 05:12:43 +0000 (15:12 +1000)]
Remove unnecessary `NtIdent` in `Token::is_whole_expr`.

The comment on this function explains that it's a specialized version of
`maybe_whole_expr`. But `maybe_whole_expr` doesn't do anything with
`NtIdent`, so `is_whole_expr` also doesn't need to.

2 years agoFix spelling of an identifier.
Nicholas Nethercote [Tue, 3 May 2022 04:23:19 +0000 (14:23 +1000)]
Fix spelling of an identifier.

2 years agoSpeed up `Token::{ident,lifetime}`.
Nicholas Nethercote [Tue, 3 May 2022 02:40:35 +0000 (12:40 +1000)]
Speed up `Token::{ident,lifetime}`.

They're hot enough that the repeated matching done by `uninterpolate`
has a measurable effect.

2 years agoAuto merge of #96558 - bjorn3:librarify_parse_format, r=davidtwco
bors [Tue, 3 May 2022 20:03:54 +0000 (20:03 +0000)]
Auto merge of #96558 - bjorn3:librarify_parse_format, r=davidtwco

Make rustc_parse_format compile on stable

This allows it to be used by lightweight formatting systems and may allow it to be used by rust-analyzer.

2 years agoAuto merge of #96558 - bjorn3:librarify_parse_format, r=davidtwco
bors [Tue, 3 May 2022 20:03:54 +0000 (20:03 +0000)]
Auto merge of #96558 - bjorn3:librarify_parse_format, r=davidtwco

Make rustc_parse_format compile on stable

This allows it to be used by lightweight formatting systems and may allow it to be used by rust-analyzer.

2 years agoQuick fix for #96223.
ricked-twice [Tue, 3 May 2022 19:16:03 +0000 (21:16 +0200)]
Quick fix for #96223.

2 years agoAdd more tests for label-break-value
Joshua Nelson [Tue, 3 May 2022 19:07:36 +0000 (14:07 -0500)]
Add more tests for label-break-value

2 years agoFix flaky rustdoc-ui test because it did not replace time result
Guillaume Gomez [Tue, 3 May 2022 18:46:02 +0000 (20:46 +0200)]
Fix flaky rustdoc-ui test because it did not replace time result

2 years agoAuto merge of #8783 - flip1995:ouir-nursery, r=llogiq
bors [Tue, 3 May 2022 18:06:52 +0000 (18:06 +0000)]
Auto merge of #8783 - flip1995:ouir-nursery, r=llogiq

Move only_used_in_recursion to nursery

r? `@llogiq`

I still think this is the right thing to do for this lint. See: #8782

I want to get this merged before the sync on Thursday, because I want to backport this and the last fix #8691 to beta.

changelog: Move [`only_used_in_recursion`] to nursery