Commit Graph

11912 Commits

Author SHA1 Message Date
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
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
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
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
bors
64137f0b15 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`
2022-03-22 16:24:50 +00:00
Takayuki Maeda
62ded071d5 cancel a not emitted error after parsing const generic args 2022-03-22 16:06:56 +09:00
Frank King
f28d8b13df suggest constraining param for unary ops when missing trait impl 2022-03-22 12:17:30 +08:00
bors
2d15732f6e 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
2022-03-22 03:08:01 +00:00
Ralf Jung
b92a60586a rename LocalState::Uninitialized to Unallocated 2022-03-21 22:48:11 -04:00
bors
cf8531064e 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
2022-03-22 00:26:06 +00:00
Nicholas Nethercote
f8f1d3f00b Split TokenCursor::{next,next_desugared} into inlined and non-inlined halves. 2022-03-22 11:05:54 +11:00
Nicholas Nethercote
4e700a023c 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.
2022-03-22 11:01:53 +11:00
Caio
74e7313e0e Fix generated tokens hygiene 2022-03-21 19:45:55 -03:00
Matthias Krüger
44200a91ba
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``
2022-03-21 19:48:35 +01:00
Matthias Krüger
e41e510c7f
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
2022-03-21 19:48:31 +01:00
Matthias Krüger
e3557e244e
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`
2022-03-21 19:48:30 +01:00
ouz-a
be566f1185 Return err instead of ICE 2022-03-21 19:56:23 +03:00
lcnr
e8890aad62 move adt_const_params to its own tracking issue 2022-03-21 16:33:42 +01:00
Takayuki Maeda
726206696e 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>
2022-03-22 00:02:18 +09:00
Jakob Degen
a2f3a17362 Disable early otherwise branch MIR opt 2022-03-20 23:25:59 -04:00
bors
051d1176b7 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
2022-03-21 02:29:55 +00:00
bors
eded76b6f1 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.
2022-03-21 00:14:29 +00:00
Nicholas Nethercote
754dc8e66f Move items into TtParser as Vecs.
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.
2022-03-21 10:09:24 +11:00
Nicholas Nethercote
cedb787f6e 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.
2022-03-21 10:08:29 +11:00
Audun Halland
cd762d8694 fix two comments referring to moved code (rustc_mir_transform::generator) 2022-03-20 23:31:04 +01:00
Matthias Krüger
e33a4819df
Rollup merge of #95145 - ChayimFriedman2:patch-1, r=Dylan-DPC
Fix typo interator->iterator
2022-03-20 20:42:46 +01:00
Matthias Krüger
63da51db93
Rollup merge of #95135 - TaKO8Ki:fix-not-emitted-unmatched-angle-bracket-error, r=Dylan-DPC
Fix a not emitted unmatched angle bracket error

closes #95128
2022-03-20 20:42:45 +01:00
Chayim Refael Friedman
159961fb28
Fix typo interator->iterator 2022-03-20 20:52:22 +02:00
bors
4767ccec93 Auto merge of #95142 - bjorn3:sync_cg_clif-2022-03-20, r=bjorn3
Sync rustc_codegen_cranelift

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2022-03-20 16:29:16 +00:00
bjorn3
ef4ce72919 Merge commit '370c397ec9169809e5ad270079712e0043514240' into sync_cg_clif-2022-03-20 2022-03-20 16:55:21 +01:00
bors
9bd53718e2 Auto merge of #95071 - RalfJung:arbitrary-self-dyn, r=oli-obk
Miri: implement arbitrary-self dyn receivers

Roughly follows the [codegen logic](851fcc7a54/compiler/rustc_codegen_ssa/src/mir/block.rs (L809)).

Fixes https://github.com/rust-lang/miri/issues/1038
r? `@oli-obk` Cc `@eddyb`
2022-03-20 13:48:23 +00:00
Takayuki Maeda
5c8aaedef6 fix a not emitted unmatched angle bracket error 2022-03-20 22:39:15 +09:00
Matthias Krüger
355d87807f
Rollup merge of #95108 - scottmcm:more-in-target-display, r=Dylan-DPC
Give more details in `Display` for `hir::Target`

Made because I was making a code change and got a very confusing "should be applied to a method, not a method" error.

```
error[E0718]: `into_try_type` language item must be applied to a method
   --> library\core\src\ops\try_trait.rs:352:32
    |
352 |     #[cfg_attr(not(bootstrap), lang = "into_try_type")]
    |                                ^^^^^^^^^^^^^^^^^^^^^^ attribute should be applied to a method, not a method
```

With this change the error is more actionable

```
error[E0718]: `into_try_type` language item must be applied to a required trait method
   --> library\core\src\ops\try_trait.rs:352:32
    |
352 |     #[cfg_attr(not(bootstrap), lang = "into_try_type")]
    |                                ^^^^^^^^^^^^^^^^^^^^^^ attribute should be applied to a required trait method, not a provided trait method
```
2022-03-20 09:15:00 +01:00
Matthias Krüger
db374bd440
Rollup merge of #94948 - jhpratt:rustc_deprecated, r=Dylan-DPC
Fix diagnostics for `#![feature(deprecated_suggestion)]`

Follow up from #94635, where I missed a couple things.
2022-03-20 09:14:59 +01:00
Michael Howell
306dcd6efa diagnostics: do not give Option::as_ref suggestion for complex match
Fixes #82528
2022-03-19 15:54:30 -07:00
Scott McMurray
1338a45d98 Give more details in Display for hir::Target
Made because I was making a code change and got a very confusing "should be applied to a method, not a method" error.

```
error[E0718]: `into_try_type` language item must be applied to a method
   --> library\core\src\ops\try_trait.rs:352:32
    |
352 |     #[cfg_attr(not(bootstrap), lang = "into_try_type")]
    |                                ^^^^^^^^^^^^^^^^^^^^^^ attribute should be applied to a method, not a method
```
2022-03-19 02:03:37 -07:00
Michael Goulet
3516a16eeb suggest removing type ascription in bad position 2022-03-18 21:22:26 -07:00
Nicholas Nethercote
10644e0789 Remove an impossible code path.
Doc comments cannot appear in a matcher.
2022-03-19 09:44:47 +11:00
Nicholas Nethercote
39810a85da Add TtParser::macro_name.
Instead of passing it into `parse_tt`.
2022-03-19 09:44:44 +11:00
Nicholas Nethercote
354bd1071c Rename bb_items_ambiguity_error as ambiguity_error.
Because it involves `next_items` as well as `bb_items`.
2022-03-19 08:04:06 +11:00
Matthias Krüger
c27192041a
Rollup merge of #94993 - GrishaVar:too-many-hashes-test, r=Dylan-DPC
Add test for >65535 hashes in lexing raw string
2022-03-18 21:50:48 +01:00
Matthias Krüger
d15006ceca
Rollup merge of #94295 - Urgau:cfg-always-eval-all-predicate, r=petrochenkov
Always evaluate all cfg predicate in all() and any()

This pull-request adjust the handling of the `all()` and `any()` to always evaluate every cfg predicate because not doing so result in accepting incorrect `cfg`:

```rust
#[cfg(any(unix, foo::bar))] // Should error on foo::bar, but does not on unix platform (but does on non unix platform)
fn foo1() {}

#[cfg(all(foo, foo::bar))] // Should error on foo::bar, but does not
fn foo2() {}

#[cfg(all(foo::bar, foo))] // Correctly error on foo::bar
fn foo3() {}

#[cfg(any(foo::bar, foo))] // Correctly error on foo::bar
fn foo4() {}
```
This pull-request take the side to directly turn it into a hard error instead of having a future incompatibility lint because the combination to get this incorrect behavior is unusual and highly probable that some code have this without noticing.

A [search](https://cs.github.com/?scopeName=All+repos&scope=&q=lang%3Arust+%2Fany%5C%28%5Ba-zA-Z%5D%2C+%5Ba-zA-Z%5D%2B%3A%3A%5Ba-zA-Z%5D%2B%2F) on Github reveal no such instance nevertheless a Crater run should probably be done before merging this.

This was discover in https://github.com/rust-lang/rust/pull/94175 when trying to lint on the second predicate. Also note that this seems to have being introduce with Rust 1.27.0: https://rust.godbolt.org/z/KnfqKv15f.

r? `@petrochenkov`
2022-03-18 21:50:46 +01:00
Nicholas Nethercote
d21b4f30c1 Introduce TtParser.
It currently has no state, just the three methods `parse_tt`,
`parse_tt_inner`, and `bb_items_ambiguity_error`.

This commit is large but trivial, and mostly consists of changes to the
indentation of those methods. Subsequent commits will do more.
2022-03-19 07:47:22 +11:00
bors
1bfe40d11c Auto merge of #95068 - TaKO8Ki:use-create-snapshot-for-diagnostic, r=davidtwco
Use `Parser.create_snapshot_for_diagnostic` instead of `Parser.clone()`

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 `self.clone()` to avoid duplicate unclosed delims errors being emitted when the `Parser` is dropped.
2022-03-18 14:50:29 +00:00