Commit Graph

164945 Commits

Author SHA1 Message Date
bors
6970f88db3 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`
2022-03-24 01:43:21 +00:00
bors
37b55c8a0c 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
2022-03-23 23:02:17 +00:00
Matthias Krüger
fab7a6a9fd
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`
2022-03-23 22:13:26 +01:00
Matthias Krüger
1f346bd6a5
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
2022-03-23 22:13:25 +01:00
Matthias Krüger
23ef234bf7
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. 🎉

r? `@oli-obk`
2022-03-23 22:13:24 +01:00
Matthias Krüger
0c79c862f0
Rollup merge of #95069 - GuillaumeGomez:auto-traits-rustdoc, r=oli-obk
Fix auto traits in rustdoc

Fixes #90324.

cc `@matthewjasper`
r? `@Aaron1011`
2022-03-23 22:13:23 +01:00
Matthias Krüger
af19a50a26
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?
2022-03-23 22:13:22 +01:00
bors
9f4dc0b4db 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`
2022-03-23 20:18:53 +00:00
The 8472
29e29ce65d fix some links, clarify documentation based on review feedback 2022-03-23 20:57:49 +01:00
Josh Stone
cbe2216709 Update to LLVM 14.0.0 final 2022-03-23 11:42:13 -07:00
bors
547369d3d8 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
2022-03-23 16:53:47 +00:00
bors
9280445570 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.
2022-03-23 14:04:38 +00:00
Takayuki Maeda
925857d8dc stop emitting E0026 for struct enums with underscores 2022-03-23 22:54:02 +09:00
bors
c99b42cf14 Auto merge of #95235 - asquared31415:ptr_eq_typo, r=Dylan-DPC
Fix `core::ptr::guaranteed_eq` and `guaranteed_ne` docs typo
2022-03-23 11:21:04 +00:00
bors
cd2da4da37 Auto merge of #95232 - lnicola:rust-analyzer-2022-03-23, r=lnicola
⬆️ rust-analyzer

r? `@ghost`
2022-03-23 08:54:31 +00:00
asquared31415
0b81628aba ptr::guaranteed_eq doc typo 2022-03-23 04:51:59 -04:00
Laurențiu Nicola
29ebe5c38c ⬆️ rust-analyzer 2022-03-23 08:24:14 +02:00
bors
36748cf814 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.
2022-03-23 06:01:48 +00:00
bors
7b0bf9efc9 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
2022-03-23 03:31:20 +00:00
Michael Goulet
bdb4b1e923 remove [async output] from impl Future 2022-03-22 19:41:34 -07:00
Ralf Jung
a76e5b1882 bless 32bit 2022-03-22 22:19:50 -04:00
Dylan DPC
2f24923ab3
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`.
2022-03-23 03:05:34 +01:00
Dylan DPC
e1f2d354a7
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 45bf1ed1a1 ("rustc: Allow changing the default allocator").

    Note that commit d620ae1070 ("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.
2022-03-23 03:05:33 +01:00
Dylan DPC
0254928213
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`](cd11905716/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.
2022-03-23 03:05:32 +01:00
Dylan DPC
25acd9331e
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.
2022-03-23 03:05:31 +01:00
Dylan DPC
0e86cabdce
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`
2022-03-23 03:05:28 +01:00
Dylan DPC
67d6cc6ef3
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.
2022-03-23 03:05:28 +01:00
Jubilee Young
6c19dc9a86 Fixup aarch64 smoke test 2022-03-22 18:33:07 -07:00
Michael Goulet
c8cbd3d03c better errors when a Copy impl is not coherent 2022-03-22 18:15:29 -07:00
bors
2b50739b49 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
2022-03-23 00:50:33 +00:00
Ralf Jung
f93a146433 interpret/memory: simplify check_and_deref_ptr 2022-03-22 20:19:30 -04:00
Ralf Jung
8a1f928b8e interpret/validity: improve clarity 2022-03-22 19:03:12 -04:00
Jubilee Young
8fa4ae8b2d Test SVE2 includes NEON and not vice versa
Required by https://github.com/rust-lang/rust/issues/95122
2022-03-22 15:31:30 -07:00
Michael Howell
3729b17b7e 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
2022-03-22 15:29:07 -07:00
Jubilee Young
7d6415c291 Test NEON compiles
Required by https://github.com/rust-lang/rust/issues/95002
2022-03-22 15:20:07 -07:00
Jubilee Young
990c297ffb 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>
2022-03-22 15:20:01 -07:00
Jubilee Young
b807d5970b 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.
2022-03-22 15:14:33 -07:00
bors
a4a5e79814 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`
2022-03-22 21:46:57 +00:00
bjorn3
4af755baf5 Limit test_variadic_fnptr to unix 2022-03-22 22:27:13 +01:00
Miguel Ojeda
0d12a30673 Modernize alloc-no-oom-handling test
- The edition should be 2021 to avoid warnings.

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

    Note that commit d620ae1070 ("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>
2022-03-22 22:00:19 +01:00
Nicholas Nethercote
31df680789 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}`.
2022-03-23 07:13:31 +11:00
bors
5f37001055 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
2022-03-22 19:06:04 +00:00
Dylan DPC
2aca599325
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`
2022-03-22 19:07:37 +01:00
Dylan DPC
5d3dfb446f
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
2022-03-22 19:07:36 +01:00
Dylan DPC
0e80a7ab59
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.
2022-03-22 19:07:35 +01:00
Dylan DPC
0e59ad4ce3
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`
2022-03-22 19:07:34 +01:00
Dylan DPC
7c38093951
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`
2022-03-22 19:07:33 +01:00
Andre Bogus
1fb43f6662 add perf side effect docs to Iterator::cloned() 2022-03-22 19:07:23 +01:00
Mara Bos
733153f2e5 Move std::sys::{mutex, condvar, rwlock} to std::sys::locks. 2022-03-22 18:19:47 +01:00
Takayuki Maeda
b86a1d1c07 replace this.clone() with this.create_snapshot_for_diagnostic() 2022-03-23 01:26:34 +09:00