]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAuto merge of #91030 - estebank:trait-bounds-are-tricky-2, r=oli-obk
bors [Thu, 24 Mar 2022 10:24:54 +0000 (10:24 +0000)]
Auto merge of #91030 - estebank:trait-bounds-are-tricky-2, r=oli-obk

Properly track `ImplObligations`

Instead of probing for all possible `impl`s that could have caused an
`ImplObligation`, keep track of its `DefId` and obligation spans for
accurate error reporting.

Follow to #89580. Addresses #89418.

2 years agoAuto merge of #95233 - compiler-errors:chalk-up, r=jackh726
bors [Thu, 24 Mar 2022 06:05:30 +0000 (06:05 +0000)]
Auto merge of #95233 - compiler-errors:chalk-up, r=jackh726

Upgrade chalk to `0.80.0`

r? `@jackh726`

2 years agomake rustc work again
Michael Goulet [Thu, 24 Mar 2022 04:52:17 +0000 (21:52 -0700)]
make rustc work again

2 years agoProperly track `ImplObligation`s
Esteban Kuber [Wed, 13 Oct 2021 13:58:41 +0000 (13:58 +0000)]
Properly track `ImplObligation`s

Instead of probing for all possible impls that could have caused an
`ImplObligation`, keep track of its `DefId` and obligation spans for
accurate error reporting.

Follow up to #89580. Addresses #89418.

Remove some unnecessary clones.

Tweak output for auto trait impl obligations.

2 years agoAuto merge of #87667 - the8472:document-in-place-iter, r=yaahc
bors [Thu, 24 Mar 2022 01:43:21 +0000 (01:43 +0000)]
Auto merge of #87667 - the8472:document-in-place-iter, r=yaahc

add module-level documentation for vec's in-place iteration

As requested in the last libs team meeting and during previous reviews.

Feel free to point out any gaps you encounter, after all non-obvious things may with hindsight seem obvious to me.

r? `@yaahc`

CC `@steffahn`

2 years agoAuto merge of #95250 - matthiaskrgr:rollup-ma4zl69, r=matthiaskrgr
bors [Wed, 23 Mar 2022 23:02:17 +0000 (23:02 +0000)]
Auto merge of #95250 - matthiaskrgr:rollup-ma4zl69, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #94249 (Better errors when a Copy impl on a Struct is not self-consistent)
 - #95069 (Fix auto traits in rustdoc)
 - #95221 (interpret/memory: simplify check_and_deref_ptr)
 - #95225 (remove `[async output]` from `impl Future` pretty-printing)
 - #95238 (Stop emitting E0026 for struct enums with underscores)

Failed merges:

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

2 years agoRollup merge of #95238 - TaKO8Ki:stop-emitting-E0026-for-struct-enum-with-underscore...
Matthias Krüger [Wed, 23 Mar 2022 21:13:26 +0000 (22:13 +0100)]
Rollup merge of #95238 - TaKO8Ki:stop-emitting-E0026-for-struct-enum-with-underscore, r=estebank

Stop emitting E0026 for struct enums with underscores

This patch resolves a part of #83263;

r? `@estebank`

2 years agoRollup merge of #95225 - compiler-errors:impl-future-generator-ty, r=oli-obk
Matthias Krüger [Wed, 23 Mar 2022 21:13:25 +0000 (22:13 +0100)]
Rollup merge of #95225 - compiler-errors:impl-future-generator-ty, r=oli-obk

remove `[async output]` from `impl Future` pretty-printing

self-explanatory, guess it's not as helpful as I thought when I added it 4 months ago
re https://github.com/rust-lang/rust/issues/95089#issuecomment-1075482851

2 years agoRollup merge of #95221 - RalfJung:check_and_deref_ptr, r=oli-obk
Matthias Krüger [Wed, 23 Mar 2022 21:13:24 +0000 (22:13 +0100)]
Rollup merge of #95221 - RalfJung:check_and_deref_ptr, r=oli-obk

interpret/memory: simplify check_and_deref_ptr

*Finally* I saw a way to make this code simpler. The odd preprocessing in `let ptr_or_addr =` has bothered me since forever, but it actually became unnecessary in the last provenance refactoring. :)

This also leads to slightly more explicit error messages as a nice side-effect. :tada:

r? `@oli-obk`

2 years agoRollup merge of #95069 - GuillaumeGomez:auto-traits-rustdoc, r=oli-obk
Matthias Krüger [Wed, 23 Mar 2022 21:13:23 +0000 (22:13 +0100)]
Rollup merge of #95069 - GuillaumeGomez:auto-traits-rustdoc, r=oli-obk

Fix auto traits in rustdoc

Fixes #90324.

cc `@matthewjasper`
r? `@Aaron1011`

2 years agoRollup merge of #94249 - compiler-errors:better-copy-errors, r=davidtwco
Matthias Krüger [Wed, 23 Mar 2022 21:13:22 +0000 (22:13 +0100)]
Rollup merge of #94249 - compiler-errors:better-copy-errors, r=davidtwco

Better errors when a Copy impl on a Struct is not self-consistent

As discovered in a Zulip thread with `@nnethercote` and `@Mark-Simulacrum,` it's not immediately obvious why a field on an ADT doesn't implement `Copy`.  This PR attempts to give slightly more detailed information by spinning up a fulfillment context to try to dig down and discover transitive fulfillment errors that cause `is_copy_modulo_regions` to fail on a ADT field.

The error message still kinda sucks, but should only show up in the case that an existing error message was totally missing... so I think it's a good compromise for now?

2 years agoAuto merge of #95247 - cuviper:llvm14, r=nikic
bors [Wed, 23 Mar 2022 20:18:53 +0000 (20:18 +0000)]
Auto merge of #95247 - cuviper:llvm14, r=nikic

Update to LLVM 14.0.0 final

This is a simple rebase of the submodule onto the `llvmorg-14.0.0` release tag.

r? `@nikic`

2 years agofix some links, clarify documentation based on review feedback
The 8472 [Wed, 23 Mar 2022 19:57:49 +0000 (20:57 +0100)]
fix some links, clarify documentation based on review feedback

2 years agoUpdate to LLVM 14.0.0 final
Josh Stone [Wed, 23 Mar 2022 18:42:13 +0000 (11:42 -0700)]
Update to LLVM 14.0.0 final

2 years agoAuto merge of #95220 - rust-lang:notriddle/ast-validation-semicolon, r=Dylan-DPC
bors [Wed, 23 Mar 2022 16:53:47 +0000 (16:53 +0000)]
Auto merge of #95220 - rust-lang:notriddle/ast-validation-semicolon, r=Dylan-DPC

diagnostics: do not suggest `fn foo({ <body> }`

Instead of suggesting that the body always replace the last character on the line, presuming it must be a semicolon, the parser should instead check what the last character is, and append the body if it is anything else.

Fixes #83104

2 years agoAuto merge of #94901 - fee1-dead:destructable, r=oli-obk
bors [Wed, 23 Mar 2022 14:04:38 +0000 (14:04 +0000)]
Auto merge of #94901 - fee1-dead:destructable, r=oli-obk

Rename `~const Drop` to `~const Destruct`

r? `@oli-obk`

Completely switching to `~const Destructible` would be rather complicated, so it seems best to add it for now and wait for it to be backported to beta in the next release.

The rationale is to prevent complications such as #92149 and #94803 by introducing an entirely new trait. And `~const Destructible` reads a bit better than `~const Drop`. Name Bikesheddable.

2 years agostop emitting E0026 for struct enums with underscores
Takayuki Maeda [Wed, 23 Mar 2022 13:54:02 +0000 (22:54 +0900)]
stop emitting E0026 for struct enums with underscores

2 years agoAuto merge of #95235 - asquared31415:ptr_eq_typo, r=Dylan-DPC
bors [Wed, 23 Mar 2022 11:21:04 +0000 (11:21 +0000)]
Auto merge of #95235 - asquared31415:ptr_eq_typo, r=Dylan-DPC

Fix `core::ptr::guaranteed_eq` and `guaranteed_ne` docs typo

2 years agoAuto merge of #95232 - lnicola:rust-analyzer-2022-03-23, r=lnicola
bors [Wed, 23 Mar 2022 08:54:31 +0000 (08:54 +0000)]
Auto merge of #95232 - lnicola:rust-analyzer-2022-03-23, r=lnicola

:arrow_up: rust-analyzer

r? `@ghost`

2 years agoptr::guaranteed_eq doc typo
asquared31415 [Wed, 23 Mar 2022 08:21:50 +0000 (04:21 -0400)]
ptr::guaranteed_eq doc typo

2 years agoupgrade chalk
Michael Goulet [Wed, 23 Mar 2022 06:39:11 +0000 (23:39 -0700)]
upgrade chalk

2 years ago:arrow_up: rust-analyzer
Laurențiu Nicola [Wed, 23 Mar 2022 06:24:14 +0000 (08:24 +0200)]
:arrow_up: rust-analyzer

2 years agoAuto merge of #95173 - m-ou-se:sys-locks-module, r=dtolnay
bors [Wed, 23 Mar 2022 06:01:48 +0000 (06:01 +0000)]
Auto merge of #95173 - m-ou-se:sys-locks-module, r=dtolnay

Move std::sys::{mutex, condvar, rwlock} to std::sys::locks.

This cleans up the the std::sys modules a bit by putting the locks in a single module called `locks` rather than spread over the three modules `mutex`, `condvar`, and `rwlock`. This makes it easier to organise lock implementations, which helps with https://github.com/rust-lang/rust/issues/93740.

2 years agoAuto merge of #95223 - Dylan-DPC:rollup-idpb7ka, r=Dylan-DPC
bors [Wed, 23 Mar 2022 03:31:20 +0000 (03:31 +0000)]
Auto merge of #95223 - Dylan-DPC:rollup-idpb7ka, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #91608 (Fold aarch64 feature +fp into +neon)
 - #92955 (add perf side effect docs to `Iterator::cloned()`)
 - #94713 (Add u16::is_utf16_surrogate)
 - #95212 (Replace `this.clone()` with `this.create_snapshot_for_diagnostic()`)
 - #95219 (Modernize `alloc-no-oom-handling` test)
 - #95222 (interpret/validity: improve clarity)

Failed merges:

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

2 years agoremove [async output] from impl Future
Michael Goulet [Wed, 23 Mar 2022 02:25:43 +0000 (19:25 -0700)]
remove [async output] from impl Future

2 years agobless 32bit
Ralf Jung [Wed, 23 Mar 2022 02:19:50 +0000 (22:19 -0400)]
bless 32bit

2 years agoRollup merge of #95222 - RalfJung:validity, r=Dylan-DPC
Dylan DPC [Wed, 23 Mar 2022 02:05:34 +0000 (03:05 +0100)]
Rollup merge of #95222 - RalfJung:validity, r=Dylan-DPC

interpret/validity: improve clarity

I was confused by my own (ancient) comment in `validity.rs` so I figured I'd clarify. (And I don't think ZST-ness is relevant at all inside that branch, no idea where that comment comes from.)

Also `extend` seems more clear than `clone_from`.

2 years agoRollup merge of #95219 - ojeda:update-alloc-no-oom-handling-test, r=Dylan-DPC
Dylan DPC [Wed, 23 Mar 2022 02:05:33 +0000 (03:05 +0100)]
Rollup merge of #95219 - ojeda:update-alloc-no-oom-handling-test, r=Dylan-DPC

Modernize `alloc-no-oom-handling` test

  - The edition should be 2021 to avoid warnings.

  - The `external_crate` feature was removed in commit 45bf1ed1a112 ("rustc: Allow changing the default allocator").

    Note that commit d620ae10709c ("Auto merge of #84266") removed the old test, but the new one introduced passed the `--cfg` like in the old one.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---

This is intended to align this test to the new `no_rc` and `no_sync` ones being added in https://github.com/rust-lang/rust/pull/89891, but it makes sense on its own too.

2 years agoRollup merge of #95212 - TaKO8Ki:replace-this-clone-with-this-create-snapshot-for...
Dylan DPC [Wed, 23 Mar 2022 02:05:32 +0000 (03:05 +0100)]
Rollup merge of #95212 - TaKO8Ki:replace-this-clone-with-this-create-snapshot-for-diagnostic, r=Dylan-DPC

Replace `this.clone()` with `this.create_snapshot_for_diagnostic()`

Use [`create_snapshot_for_diagnostic`](https://github.com/rust-lang/rust/blob/cd119057160cedea245aa2679add56723f3dc784/compiler/rustc_parse/src/parser/diagnostics.rs#L214-L223) I implemented in https://github.com/rust-lang/rust/pull/94731 instead of `this.clone()` to avoid duplicate errors about unclosed delims being emitted when the `Parser` is dropped.

2 years agoRollup merge of #94713 - clarfonthey:is_char_surrogate, r=scottmcm
Dylan DPC [Wed, 23 Mar 2022 02:05:31 +0000 (03:05 +0100)]
Rollup merge of #94713 - clarfonthey:is_char_surrogate, r=scottmcm

Add u16::is_utf16_surrogate

Right now, there are methods in the standard library for encoding and decoding UTF-16, but at least for the moment, there aren't any methods specifically for `u16` to help work with UTF-16 data. Since the full logic already exists, this wouldn't really add any code, just expose what's already there.

This method in particular is useful for working with the data returned by Windows `OsStrExt::encode_wide`. Initially, I was planning to also offer a `TryFrom<u16> for char`, but decided against it for now. There is plenty of code in rustc that could be rewritten to use this method, but I only checked within the standard library to replace them.

I think that offering more UTF-16-related methods to u16 would be useful, but I think this one is a good start. For example, one useful method might be `u16::is_pattern_whitespace`, which would check if something is the Unicode `Pattern_Whitespace` category. We can get away with this because all of the `Pattern_Whitespace` characters are in the basic multilingual plane, and hence we don't need to check for surrogates.

2 years agoRollup merge of #92955 - llogiq:cloned-side-effect-doc, r=yaahc
Dylan DPC [Wed, 23 Mar 2022 02:05:28 +0000 (03:05 +0100)]
Rollup merge of #92955 - llogiq:cloned-side-effect-doc, r=yaahc

add perf side effect docs to `Iterator::cloned()`

Now that #90209 has been closed, as the current state of affairs is neither here nor there, this at least adds a paragraph + example on what to expect performance-wise and how to deal with it to the .cloned() docs.

cc `@the8472`

2 years agoRollup merge of #91608 - workingjubilee:fold-neon-fp, r=nagisa,Amanieu
Dylan DPC [Wed, 23 Mar 2022 02:05:28 +0000 (03:05 +0100)]
Rollup merge of #91608 - workingjubilee:fold-neon-fp, r=nagisa,Amanieu

Fold aarch64 feature +fp into +neon

Arm's FEAT_FP and Feat_AdvSIMD describe the same thing on AArch64:
The Neon unit, which handles both floating point and SIMD instructions.
Moreover, a configuration for AArch64 must include both or neither.
Arm says "entirely proprietary" toolchains may omit floating point:
https://developer.arm.com/documentation/102374/0101/Data-processing---floating-point
In the Programmer's Guide for Armv8-A, Arm says AArch64 can have
both FP and Neon or neither in custom implementations:
https://developer.arm.com/documentation/den0024/a/AArch64-Floating-point-and-NEON

In "Bare metal boot code for Armv8-A", enabling Neon and FP
is just disabling the same trap flag:
https://developer.arm.com/documentation/dai0527/a

In an unlikely future where "Neon and FP" become unrelated,
we can add "[+-]fp" as its own feature flag.
Until then, we can simplify programming with Rust on AArch64 by
folding both into "[+-]neon", which is valid as it supersets both.

"[+-]neon" is retained for niche uses such as firmware, kernels,
"I just hate floats", and so on.

I am... pretty sure no one is relying on this.

An argument could be made that, as we are not an "entirely proprietary" toolchain, we should not support AArch64 without floats at all. I think that's a bit excessive. However, I want to recognize the intent: programming for AArch64 should be simplified where possible. For x86-64, programmers regularly set up illegal feature configurations because it's hard to understand them, see https://github.com/rust-lang/rust/issues/89586. And per the above notes, plus the discussion in https://github.com/rust-lang/rust/issues/86941, there should be no real use cases for leaving these features split: the two should in fact always go together.

- Fixes rust-lang/rust#95002.
- Fixes rust-lang/rust#95064.
- Fixes rust-lang/rust#95122.

2 years agoFixup aarch64 smoke test
Jubilee Young [Wed, 23 Mar 2022 01:11:21 +0000 (18:11 -0700)]
Fixup aarch64 smoke test

2 years agobetter errors when a Copy impl is not coherent
Michael Goulet [Tue, 22 Feb 2022 05:26:37 +0000 (21:26 -0800)]
better errors when a Copy impl is not coherent

2 years agoAuto merge of #95088 - bjorn3:fix_test_variadic_fnptr, r=dtolnay
bors [Wed, 23 Mar 2022 00:50:33 +0000 (00:50 +0000)]
Auto merge of #95088 - bjorn3:fix_test_variadic_fnptr, r=dtolnay

Don't declare test_variadic_fnptr with two conflicting signatures

It is UB for LLVM and results in a compile error for Cranelift.

cc https://github.com/bjorn3/rustc_codegen_cranelift/issues/806
Fixes https://github.com/rust-lang/rust/issues/66690

2 years agointerpret/memory: simplify check_and_deref_ptr
Ralf Jung [Tue, 22 Mar 2022 22:58:54 +0000 (18:58 -0400)]
interpret/memory: simplify check_and_deref_ptr

2 years agointerpret/validity: improve clarity
Ralf Jung [Tue, 22 Mar 2022 22:58:23 +0000 (18:58 -0400)]
interpret/validity: improve clarity

2 years agoTest SVE2 includes NEON and not vice versa
Jubilee Young [Tue, 22 Mar 2022 22:03:59 +0000 (15:03 -0700)]
Test SVE2 includes NEON and not vice versa

Required by https://github.com/rust-lang/rust/issues/95122

2 years agodiagnostics: do not suggest `fn foo({ <body> }`
Michael Howell [Tue, 22 Mar 2022 22:29:07 +0000 (15:29 -0700)]
diagnostics: do not suggest `fn foo({ <body> }`

Instead of suggesting that the body always replace the last character on the
line, presuming it must be a semicolon, the parser should instead check what
the last character is, and append the body if it is anything else.

Fixes #83104

2 years agoTest NEON compiles
Jubilee Young [Tue, 22 Mar 2022 21:24:59 +0000 (14:24 -0700)]
Test NEON compiles

Required by https://github.com/rust-lang/rust/issues/95002

2 years agoFilter for all features instead of any
Jubilee Young [Sun, 20 Mar 2022 02:36:42 +0000 (19:36 -0700)]
Filter for all features instead of any

Adds regression tests for feature logic
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
Co-authored-by: Simonas Kazlauskas <git@kazlauskas.me>
2 years agoFold aarch64 feature +fp into +neon
Jubilee Young [Sat, 4 Dec 2021 01:56:59 +0000 (17:56 -0800)]
Fold aarch64 feature +fp into +neon

Arm's FEAT_FP and Feat_AdvSIMD describe the same thing on AArch64:
The Neon unit, which handles both floating point and SIMD instructions.
Moreover, a configuration for AArch64 must include both or neither.
Arm says "entirely proprietary" toolchains may omit floating point:
https://developer.arm.com/documentation/102374/0101/Data-processing---floating-point
In the Programmer's Guide for Armv8-A, Arm says AArch64 can have
both FP and Neon or neither in custom implementations:
https://developer.arm.com/documentation/den0024/a/AArch64-Floating-point-and-NEON

In "Bare metal boot code for Armv8-A", enabling Neon and FP
is just disabling the same trap flag:
https://developer.arm.com/documentation/dai0527/a

In an unlikely future where "Neon and FP" become unrelated,
we can add "[+-]fp" as its own feature flag.
Until then, we can simplify programming with Rust on AArch64 by
folding both into "[+-]neon", which is valid as it supersets both.

"[+-]neon" is retained for niche uses such as firmware, kernels,
"I just hate floats", and so on.

2 years agoAuto merge of #95159 - nnethercote:TtParser, r=petrochenkov
bors [Tue, 22 Mar 2022 21:46:57 +0000 (21:46 +0000)]
Auto merge of #95159 - nnethercote:TtParser, r=petrochenkov

Introduce `TtParser`

These commits make a number of changes to declarative macro expansion, resulting in code that is shorter, simpler, and faster.

Best reviewed one commit at a time.

r? `@petrochenkov`

2 years agoLimit test_variadic_fnptr to unix
bjorn3 [Tue, 22 Mar 2022 21:27:13 +0000 (22:27 +0100)]
Limit test_variadic_fnptr to unix

2 years agoModernize `alloc-no-oom-handling` test
Miguel Ojeda [Tue, 22 Mar 2022 20:44:58 +0000 (21:44 +0100)]
Modernize `alloc-no-oom-handling` test

  - The edition should be 2021 to avoid warnings.

  - The `external_crate` feature was removed in commit 45bf1ed1a112
    ("rustc: Allow changing the default allocator").

    Note that commit d620ae10709c ("Auto merge of #84266") removed
    the old test, but the new one introduced passed the `--cfg` like
    in the old one.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2 years agoEliminate `TokenTreeOrTokenTreeSlice`.
Nicholas Nethercote [Sat, 19 Mar 2022 05:20:07 +0000 (16:20 +1100)]
Eliminate `TokenTreeOrTokenTreeSlice`.

As its name suggests, `TokenTreeOrTokenTreeSlice` is either a single
`TokenTree` or a slice of them. It has methods `len` and `get_tt` that
let it be treated much like an ordinary slice. The reason it isn't an
ordinary slice is that for `TokenTree::Delimited` the open and close
delimiters are represented implicitly, and when they are needed they are
constructed on the fly with `Delimited::{open,close}_tt`, rather than
being present in memory.

This commit changes `Delimited` so the open and close delimiters are
represented explicitly. As a result, `TokenTreeOrTokenTreeSlice` is no
longer needed and `MatcherPos` and `MatcherTtFrame` can just use an
ordinary slice. `TokenTree::{len,get_tt}` are also removed, because they
were only needed to support `TokenTreeOrTokenTreeSlice`.

The change makes the code shorter and a little bit faster on benchmarks
that use macro expansion heavily, partly because `MatcherPos` is a lot
smaller (less data to `memcpy`) and partly because ordinary slice
operations are faster than `TokenTreeOrTokenTreeSlice::{len,get_tt}`.

2 years agoAuto merge of #95215 - Dylan-DPC:rollup-l9f9t7l, r=Dylan-DPC
bors [Tue, 22 Mar 2022 19:06:04 +0000 (19:06 +0000)]
Auto merge of #95215 - Dylan-DPC:rollup-l9f9t7l, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #95188 ([`macro-metavar-expr`] Fix generated tokens hygiene)
 - #95196 (rename LocalState::Uninitialized to Unallocated)
 - #95197 (Suggest constraining param for unary ops when missing trait impl)
 - #95200 (Cancel a not emitted error after parsing const generic args)
 - #95207 (update Termination trait docs)

Failed merges:

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

2 years agoRollup merge of #95207 - ZHANGWENTAI:update_termination_doc, r=yaahc
Dylan DPC [Tue, 22 Mar 2022 18:07:37 +0000 (19:07 +0100)]
Rollup merge of #95207 - ZHANGWENTAI:update_termination_doc, r=yaahc

update Termination trait docs

this pr add some statement about intending to provide `Termination` trait only on standard library's runtime.

from #93448

r? `@Lokathor`

2 years agoRollup merge of #95200 - TaKO8Ki:cancel-not-emitted-error-when-parsing-generic-arg...
Dylan DPC [Tue, 22 Mar 2022 18:07:36 +0000 (19:07 +0100)]
Rollup merge of #95200 - TaKO8Ki:cancel-not-emitted-error-when-parsing-generic-arg, r=oli-obk

Cancel a not emitted error after parsing const generic args

closes #95163

2 years agoRollup merge of #95197 - frank-king:feat/unary_op_type_constrain, r=petrochenkov
Dylan DPC [Tue, 22 Mar 2022 18:07:35 +0000 (19:07 +0100)]
Rollup merge of #95197 - frank-king:feat/unary_op_type_constrain, r=petrochenkov

Suggest constraining param for unary ops when missing trait impl

This PR adds a suggestion of constraining param for unary ops `-` and `!` when the corresponding trait implementation
is missing.

Fixs #94543.

BTW, this is my first time to touch rustc, please correct me if I did anything wrong.

2 years agoRollup merge of #95196 - RalfJung:unalloc-not-uninit, r=oli-obk
Dylan DPC [Tue, 22 Mar 2022 18:07:34 +0000 (19:07 +0100)]
Rollup merge of #95196 - RalfJung:unalloc-not-uninit, r=oli-obk

rename LocalState::Uninitialized to Unallocated

This is to avoid confusion with `Uninit` as in `ScalarMaybeUninit`, which is very different.

r? `@oli-obk`

2 years agoRollup merge of #95188 - c410-f3r:aqui-vamos-nos, r=petrochenkov
Dylan DPC [Tue, 22 Mar 2022 18:07:33 +0000 (19:07 +0100)]
Rollup merge of #95188 - c410-f3r:aqui-vamos-nos, r=petrochenkov

[`macro-metavar-expr`] Fix generated tokens hygiene

Only uses `Marker` on generated tokens -> https://github.com/rust-lang/rust/issues/83527#issuecomment-1074439425)

I really don't know how to test this PR

r? `@petrochenkov`

2 years agoadd perf side effect docs to `Iterator::cloned()`
Andre Bogus [Sun, 16 Jan 2022 00:33:19 +0000 (01:33 +0100)]
add perf side effect docs to `Iterator::cloned()`

2 years agoMove std::sys::{mutex, condvar, rwlock} to std::sys::locks.
Mara Bos [Mon, 21 Mar 2022 14:45:51 +0000 (15:45 +0100)]
Move std::sys::{mutex, condvar, rwlock} to std::sys::locks.

2 years agoreplace `this.clone()` with `this.create_snapshot_for_diagnostic()`
Takayuki Maeda [Tue, 22 Mar 2022 16:26:34 +0000 (01:26 +0900)]
replace `this.clone()` with `this.create_snapshot_for_diagnostic()`

2 years agoAuto merge of #94693 - nnethercote:parser-inlining, r=petrochenkov
bors [Tue, 22 Mar 2022 16:24:50 +0000 (16:24 +0000)]
Auto merge of #94693 - nnethercote:parser-inlining, r=petrochenkov

Inline some parser functions

Some crates that do a lot of complex declarative macro expansion spend a lot of time parsing (and reparsing) tokens. These commits inline some functions for some minor speed wins.

r? `@ghost`

2 years agoadd some fix
ZHANGWENTAI [Tue, 22 Mar 2022 15:33:08 +0000 (23:33 +0800)]
add some fix

Signed-off-by: ZHANGWENTAI <2092913428@qq.com>
2 years agofix the lint problem
ZHANGWENTAI [Tue, 22 Mar 2022 15:10:00 +0000 (23:10 +0800)]
fix the lint problem

Signed-off-by: ZHANGWENTAI <2092913428@qq.com>
2 years agoupdate Termination trait docs
ZHANGWENTAI [Tue, 22 Mar 2022 14:37:17 +0000 (22:37 +0800)]
update Termination trait docs

2 years agoAuto merge of #95107 - r00ster91:fmt, r=joshtriplett
bors [Tue, 22 Mar 2022 08:47:16 +0000 (08:47 +0000)]
Auto merge of #95107 - r00ster91:fmt, r=joshtriplett

Improve formatting in macro

CC `@dtolnay`

2 years agocancel a not emitted error after parsing const generic args
Takayuki Maeda [Tue, 22 Mar 2022 07:06:56 +0000 (16:06 +0900)]
cancel a not emitted error after parsing const generic args

2 years agoAuto merge of #95158 - sunfishcode:sunfishcode/windows-8, r=joshtriplett
bors [Tue, 22 Mar 2022 05:48:49 +0000 (05:48 +0000)]
Auto merge of #95158 - sunfishcode:sunfishcode/windows-8, r=joshtriplett

Preserve the Windows `GetLastError` error in `HandleOrInvalid`.

In the `TryFrom<HandleOrInvalid> for OwnedHandle` and
`TryFrom<HandleOrNull> for OwnedHandle` implemenations, `forget` the
owned handle on the error path, to avoid calling `CloseHandle` on an
invalid handle. It's harmless, except that it may overwrite the
thread's `GetLastError` error.

r? `@joshtriplett`

2 years agosuggest constraining param for unary ops when missing trait impl
Frank King [Tue, 22 Mar 2022 04:17:30 +0000 (12:17 +0800)]
suggest constraining param for unary ops when missing trait impl

2 years agoAuto merge of #95127 - notriddle:notriddle/option-content-move-from-tuple-match,...
bors [Tue, 22 Mar 2022 03:08:01 +0000 (03:08 +0000)]
Auto merge of #95127 - notriddle:notriddle/option-content-move-from-tuple-match, r=estebank

diagnostics: do not give Option::as_ref suggestion for complex match

Fixes #82528

2 years agoAdd u16::is_utf16_surrogate
ltdk [Mon, 7 Mar 2022 21:36:13 +0000 (16:36 -0500)]
Add u16::is_utf16_surrogate

2 years agorename LocalState::Uninitialized to Unallocated
Ralf Jung [Tue, 22 Mar 2022 02:33:23 +0000 (22:33 -0400)]
rename LocalState::Uninitialized to Unallocated

2 years agoAuto merge of #95161 - JakobDegen:fix-early-otherwise-branch, r=wesleywiser
bors [Tue, 22 Mar 2022 00:26:06 +0000 (00:26 +0000)]
Auto merge of #95161 - JakobDegen:fix-early-otherwise-branch, r=wesleywiser

Disable almost certainly unsound early otherwise branch MIR opt

Originally thought this was just an MIR semantics issue, but it's not.

r? rust-lang/mir-opt

2 years agoSplit `TokenCursor::{next,next_desugared}` into inlined and non-inlined halves.
Nicholas Nethercote [Mon, 7 Mar 2022 04:55:39 +0000 (15:55 +1100)]
Split `TokenCursor::{next,next_desugared}` into inlined and non-inlined halves.

2 years agoSplit `Parser::bump_with` into inlined and non-inlined halves.
Nicholas Nethercote [Mon, 7 Mar 2022 04:17:38 +0000 (15:17 +1100)]
Split `Parser::bump_with` into inlined and non-inlined halves.

The call site within `Parser::bump` is hot.

Also add an inline annotation to `Parser::next_tok`. It was already
being inlined by the compiler; this just makes sure that continues.

2 years agorename internal helper trait AsIntoIter to AsVecIntoIter
The 8472 [Mon, 21 Mar 2022 23:02:54 +0000 (00:02 +0100)]
rename internal helper trait AsIntoIter to AsVecIntoIter

2 years agoFix generated tokens hygiene
Caio [Mon, 21 Mar 2022 22:45:55 +0000 (19:45 -0300)]
Fix generated tokens hygiene

2 years agoadd module-level documentation for vec's in-place iteration
The8472 [Sat, 31 Jul 2021 15:39:35 +0000 (17:39 +0200)]
add module-level documentation for vec's in-place iteration

2 years agomove AsIntoIter helper trait and mark it as unsafe
The8472 [Tue, 24 Aug 2021 21:54:14 +0000 (23:54 +0200)]
move AsIntoIter helper trait and mark it as unsafe

2 years agorename module to better reflect its purpose
The8472 [Tue, 24 Aug 2021 21:30:05 +0000 (23:30 +0200)]
rename module to better reflect its purpose

2 years agoAuto merge of #95180 - matthiaskrgr:rollup-ai1ch2s, r=matthiaskrgr
bors [Mon, 21 Mar 2022 19:23:00 +0000 (19:23 +0000)]
Auto merge of #95180 - matthiaskrgr:rollup-ai1ch2s, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #95074 (Refactor: use `format-args-capture` and remove unnecessary nested if blocks in some parts of `rust_passes`)
 - #95085 (Return err instead of ICE)
 - #95116 (Add needs-* directives to many tests)
 - #95129 (Remove animation on source sidebar)
 - #95166 (Update the unstable book with the new `values()` form of check-cfg)
 - #95175 (move `adt_const_params`  to its own tracking issue)

Failed merges:

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

2 years agoRollup merge of #95175 - lcnr:adt_const_params-tracking-issue, r=Dylan-DPC
Matthias Krüger [Mon, 21 Mar 2022 18:48:35 +0000 (19:48 +0100)]
Rollup merge of #95175 - lcnr:adt_const_params-tracking-issue, r=Dylan-DPC

move `adt_const_params`  to its own tracking issue

the new tracking issue is  #95174

r? ``@rust-lang/project-const-generics``

2 years agoRollup merge of #95166 - Urgau:check-cfg-values-unstable-book, r=petrochenkov
Matthias Krüger [Mon, 21 Mar 2022 18:48:34 +0000 (19:48 +0100)]
Rollup merge of #95166 - Urgau:check-cfg-values-unstable-book, r=petrochenkov

Update the unstable book with the new `values()` form of check-cfg

Forgot to update the unstable book in https://github.com/rust-lang/rust/pull/94362

r? ``@petrochenkov``

2 years agoRollup merge of #95129 - GuillaumeGomez:rm-source-sidebar-animation, r=jsha
Matthias Krüger [Mon, 21 Mar 2022 18:48:33 +0000 (19:48 +0100)]
Rollup merge of #95129 - GuillaumeGomez:rm-source-sidebar-animation, r=jsha

Remove animation on source sidebar

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

Didn't upload a demo considering how simple it is to test in a browser. :)

r? ``@jsha``

2 years agoRollup merge of #95116 - bjorn3:cg_clif_test_fixes, r=Dylan-DPC
Matthias Krüger [Mon, 21 Mar 2022 18:48:32 +0000 (19:48 +0100)]
Rollup merge of #95116 - bjorn3:cg_clif_test_fixes, r=Dylan-DPC

Add needs-* directives to many tests

These are necessary to ignore tests that need features unsupported by cg_clif.

2 years agoRollup merge of #95085 - ouz-a:master5, r=jackh726
Matthias Krüger [Mon, 21 Mar 2022 18:48:31 +0000 (19:48 +0100)]
Rollup merge of #95085 - ouz-a:master5, r=jackh726

Return err instead of ICE

Having `escaping_bound_vars` results in ICE when trying to create `ty::Binder::dummy`, to avoid it we return err like the line above. I think this requires a more sophisticated fix, I would love to investigate if mentorship is available 🤓

Fixes #95023 and #85350

2 years agoRollup merge of #95074 - TaKO8Ki:use-format-args-capture-and-remove-unnecessary-nesti...
Matthias Krüger [Mon, 21 Mar 2022 18:48:30 +0000 (19:48 +0100)]
Rollup merge of #95074 - TaKO8Ki:use-format-args-capture-and-remove-unnecessary-nesting-in-rustc-passes, r=lcnr

Refactor: use `format-args-capture` and remove unnecessary nested if blocks in some parts of `rust_passes`

2 years agoAdd needs-asm-support directive to tests where necessary
bjorn3 [Sat, 19 Mar 2022 15:50:24 +0000 (16:50 +0100)]
Add needs-asm-support directive to tests where necessary

2 years agoReturn err instead of ICE
ouz-a [Fri, 18 Mar 2022 19:04:01 +0000 (22:04 +0300)]
Return err instead of ICE

2 years agomove `adt_const_params` to its own tracking issue
lcnr [Mon, 21 Mar 2022 15:33:15 +0000 (16:33 +0100)]
move `adt_const_params`  to its own tracking issue

2 years agoAuto merge of #95169 - Smittyvb:union-test-ub, r=bjorn3
bors [Mon, 21 Mar 2022 15:17:08 +0000 (15:17 +0000)]
Auto merge of #95169 - Smittyvb:union-test-ub, r=bjorn3

Don't run UB in test suite

This splits `ui/unsafe/union.rs` to make it so only the non-UB parts are run. It also means we can do more testing of the location of error messages (which are a bit different with the THIR unsafety checker). `union-modification.rs` has no UB (according to Miri), and `union.rs` has errors (but would have UB if not for those errors).

Closes #95075.
r? `@bjorn3`

2 years agouse `format-args-capture` and remove unnecessary nested if blocks in some parts of...
Takayuki Maeda [Fri, 18 Mar 2022 13:48:21 +0000 (22:48 +0900)]
use `format-args-capture` and remove unnecessary nested if blocks in some parts of rustc_passes

break before the `&&`

Update compiler/rustc_passes/src/check_const.rs

Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2 years agoMove pthread locks to own module.
Mara Bos [Thu, 17 Mar 2022 11:28:31 +0000 (12:28 +0100)]
Move pthread locks to own module.

2 years agoDon't run UB in test suite
Smitty [Mon, 21 Mar 2022 13:32:26 +0000 (09:32 -0400)]
Don't run UB in test suite

This splits ui/unsafe/union.rs to make it so only the non-UB parts are
run. It also means we can do more testing of the location of error
messages.

2 years agoUpdate unstable book with the new `values()` form for check-cfg
Loïc BRANSTETT [Mon, 21 Mar 2022 11:59:46 +0000 (12:59 +0100)]
Update unstable book with the new `values()` form for check-cfg

2 years agoTidy up
Deadbeef [Mon, 21 Mar 2022 06:07:09 +0000 (17:07 +1100)]
Tidy up

2 years agoRename `~const Drop` to `~const Destruct`
Deadbeef [Mon, 21 Mar 2022 05:52:41 +0000 (16:52 +1100)]
Rename `~const Drop` to `~const Destruct`

2 years agoAdd `Destructible` for replacing `~const Drop`
Deadbeef [Sun, 13 Mar 2022 04:04:01 +0000 (15:04 +1100)]
Add `Destructible` for replacing `~const Drop`

2 years agoDisable early otherwise branch MIR opt
Jakob Degen [Mon, 21 Mar 2022 02:43:31 +0000 (22:43 -0400)]
Disable early otherwise branch MIR opt

2 years agoAuto merge of #95104 - compiler-errors:remove-ascription, r=davidtwco
bors [Mon, 21 Mar 2022 02:29:55 +0000 (02:29 +0000)]
Auto merge of #95104 - compiler-errors:remove-ascription, r=davidtwco

suggest removing type ascription in bad parsing position

Not sure how to test this with the non-nightly suggestion. Didn't add a new UI test because it already manifests in an existing UI test.

Fixes #95014

2 years agoAuto merge of #95156 - audunhalland:fix-rustc_const_eval_transform-comments, r=Dylan-DPC
bors [Mon, 21 Mar 2022 00:14:29 +0000 (00:14 +0000)]
Auto merge of #95156 - audunhalland:fix-rustc_const_eval_transform-comments, r=Dylan-DPC

fix two comments referring to moved code (now rustc_mir_transform::generator)

This caused me some confusion when trying to find the related code.

2 years agoMove items into `TtParser` as `Vec`s.
Nicholas Nethercote [Fri, 18 Mar 2022 22:53:41 +0000 (09:53 +1100)]
Move items into `TtParser` as `Vec`s.

By putting them in `TtParser`, we can reuse them for every rule in a
macro. With that done, they can be `SmallVec` instead of `Vec`, and this
is a performance win because these vectors are hot and `SmallVec`
operations are a bit slower due to always needing an "inline or heap?"
check.

2 years agoRemove `MatcherPosHandle`.
Nicholas Nethercote [Fri, 18 Mar 2022 21:56:24 +0000 (08:56 +1100)]
Remove `MatcherPosHandle`.

This type was a small performance win for `html5ever`, which uses a
macro with hundreds of very simple rules that don't contain any
metavariables. But this type is complicated (extra lifetimes) and
perf-neutral for macros that do have metavariables.

This commit removes `MatcherPosHandle`, simplifying things a lot. This
increases the allocation rate for `html5ever` and similar cases a bit,
but makes things easier for follow-up changes that will improve
performance more than what we lost here.

2 years agoAdd a testcase.
Dan Gohman [Sun, 20 Mar 2022 22:54:03 +0000 (15:54 -0700)]
Add a testcase.

2 years agoPreserve the Windows `GetLastError` error in `HandleOrInvalid`.
Dan Gohman [Sun, 20 Mar 2022 22:37:31 +0000 (15:37 -0700)]
Preserve the Windows `GetLastError` error in `HandleOrInvalid`.

In the `TryFrom<HandleOrInvalid> for OwnedHandle` and
`TryFrom<HandleOrNull> for OwnedHandle` implemenations, `forget` the
owned handle on the error path, to avoid calling `CloseHandle` on an
invalid handle. It's harmless, except that it may overwrite the
thread's `GetLastError` error.

2 years agofix two comments referring to moved code (rustc_mir_transform::generator)
Audun Halland [Sun, 20 Mar 2022 22:31:04 +0000 (23:31 +0100)]
fix two comments referring to moved code (rustc_mir_transform::generator)