Commit Graph

1548 Commits

Author SHA1 Message Date
León Orell Valerian Liehr
38bd7a0fcb
Add #[rustc_dump_{predicates,item_bounds}] 2024-06-22 06:34:09 +02:00
fee1-dead
be3b5663ae
Rollup merge of #126668 - fmease:rm-rustc_dump_program_clauses-attrs, r=fee1-dead
Remove now NOP attrs `#[rustc_dump{,_env}_program_clauses]`

Likely NOP since #113303.

r? `@fee1-dead`
2024-06-19 22:51:03 +08:00
León Orell Valerian Liehr
c894ece8fe
Remove now NOP attrs #[rustc_dump{,_env}_program_clauses] 2024-06-19 09:19:09 +02:00
许杰友 Jieyou Xu (Joe)
8eb2e5f4c8
Rollup merge of #125293 - dingxiangfei2009:tail-expr-temp-lifetime, r=estebank,davidtwco
Place tail expression behind terminating scope

This PR implements #123739 so that we can do further experiments in nightly.

A little rewrite has been applied to `for await` lowering. It was previously `unsafe { Pin::unchecked_new(into_async_iter(..)) }`. Under the edition 2024 rule, however, `into_async_iter` gets dropped at the end of the `unsafe` block. This presumably the first Edition 2024 migration rule goes by hoisting `into_async_iter(..)` into `match` one level above, so it now looks like the following.
```rust
match into_async_iter($iter_expr) {
  ref mut iter => match unsafe { Pin::unchecked_new(iter) } {
    ...
  }
}
```
2024-06-19 01:51:38 +01:00
Ding Xiang Fei
0f8c3f7882
tail expression behind terminating scope 2024-06-18 04:14:43 +08:00
Vadim Petrochenkov
91d05ba557 [perf] More span update benchmarking 2024-06-17 16:26:56 +03:00
bors
6b65c30f8e Auto merge of #126543 - petrochenkov:upctxt4, r=cjgillot
rustc_span: Optimize more hygiene operations using `Span::map_ctxt`

I missed these in https://github.com/rust-lang/rust/pull/125017.
2024-06-16 23:34:12 +00:00
Vadim Petrochenkov
14da80c372 rustc_span: Minor improvements
Introduce `{IndexNewtype,SyntaxContext}::from_u16` for convenience because small indices are sometimes encoded as `u16`.
Use `SpanData::span` instead of `Span::new` where appropriate.
Add a clarifying comment about decoding span parents.
2024-06-16 14:08:25 +03:00
Vadim Petrochenkov
c6c1c992e2 rustc_span: Optimize more hygiene operations using Span::map_ctxt 2024-06-16 13:30:43 +03:00
Matthias Krüger
5fac57284e
Rollup merge of #125829 - petrochenkov:upctxt2, r=michaelwoerister
rustc_span: Add conveniences for working with span formats

This is the refactoring part of https://github.com/rust-lang/rust/pull/125017.
2024-06-15 14:40:47 +02:00
bors
f8e5660532 Auto merge of #118958 - c410-f3r:concat-again, r=petrochenkov
Add a new concat metavar expr

Revival of #111930

Giving it another try now that #117050 was merged.

With the new rules, meta-variable expressions must be referenced with a dollar sign (`$`) and this can cause misunderstands with `$concat`.

```rust
macro_rules! foo {
    ( $bar:ident ) => {
        const ${concat(VAR, bar)}: i32 = 1;
    };
}

// Will produce `VARbar` instead of `VAR_123`
foo!(_123);
```

In other words, forgetting the dollar symbol can produce undesired outputs.

cc #29599
cc https://github.com/rust-lang/rust/issues/124225
2024-06-14 16:41:39 +00:00
Caio
4b82afb40c Add a new concat metavar expr 2024-06-13 22:12:26 -03:00
Vadim Petrochenkov
220f3ec99f rustc_span: Remove transmutes from span encoding 2024-06-13 20:12:50 +03:00
Vadim Petrochenkov
6fea953267 rustc_span: By-value interface for ctxt update 2024-06-13 19:29:24 +03:00
Vadim Petrochenkov
4440f50996 rustc_span: Add conveniences for working with span formats 2024-06-13 19:29:24 +03:00
Michael Goulet
d3812ac95f LangItem-ify Coroutine trait in solvers 2024-06-13 09:34:28 -04:00
Vadim Petrochenkov
d5dd2d8284 rustc_span: Optimize syntax context updates in spans 2024-06-10 02:20:16 +03:00
Ralf Jung
eb584a23bf offset_of: allow (unstably) taking the offset of slice tail fields 2024-06-08 18:17:55 +02:00
carbotaniuman
67f5dd1ef1 Parse unsafe attributes 2024-06-06 20:26:27 -05:00
bors
2d28b6384e Auto merge of #124482 - spastorino:unsafe-extern-blocks, r=oli-obk
Unsafe extern blocks

This implements RFC 3484.

Tracking issue #123743 and RFC https://github.com/rust-lang/rfcs/pull/3484

This is better reviewed commit by commit.
2024-06-06 08:14:58 +00:00
Matthias Krüger
79bb336b9c
Rollup merge of #125921 - Zalathar:buckets, r=oli-obk
coverage: Carve out hole spans in a separate early pass

When extracting spans from MIR for use in coverage instrumentation, we sometimes need to identify *hole spans* (currently just closures), and carve up the other spans so that they don't overlap with holes.

This PR simplifies the main coverage-span-refiner by extracting the hole-carving process into a separate early pass. That pass produces a series of independent buckets, and we run the span-refiner on each bucket separately.

There is almost no difference in the resulting mappings, other than in some edge cases involving macros.
2024-06-05 18:21:11 +02:00
Santiago Pastorino
0380321e78
Add unsafe_extern_blocks feature flag 2024-06-05 09:35:57 -03:00
Santiago Pastorino
2a377122dd
Handle safety keyword for extern block inner items 2024-06-04 14:19:42 -03:00
Zalathar
df96cba432 Add Span::trim_end
This is the counterpart of `Span::trim_start`.
2024-06-04 13:11:45 +10:00
Zalathar
e609c9b254 Add unit tests for Span::trim_start 2024-06-04 13:11:45 +10:00
Vadim Petrochenkov
8530285f4e rustc_span: Inline some hot functions 2024-06-03 01:01:18 +03:00
bors
99cb42c296 Auto merge of #124662 - zetanumbers:needs_async_drop, r=oli-obk
Implement `needs_async_drop` in rustc and optimize async drop glue

This PR expands on #121801 and implements `Ty::needs_async_drop` which works almost exactly the same as `Ty::needs_drop`, which is needed for #123948.

Also made compiler's async drop code to look more like compiler's regular drop code, which enabled me to write an optimization where types which do not use `AsyncDrop` can simply forward async drop glue to `drop_in_place`. This made size of the async block from the [async_drop test](67980dd6fb/tests/ui/async-await/async-drop.rs) to decrease by 12%.
2024-05-31 10:12:24 +00:00
bors
91c0823ee6 Auto merge of #124636 - tbu-:pr_env_unsafe, r=petrochenkov
Make `std::env::{set_var, remove_var}` unsafe in edition 2024

Allow calling these functions without `unsafe` blocks in editions up until 2021, but don't trigger the `unused_unsafe` lint for `unsafe` blocks containing these functions.

Fixes #27970.
Fixes #90308.
CC #124866.
2024-05-30 12:17:06 +00:00
Tobias Bucher
5d8f9b4dc1 Make std::env::{set_var, remove_var} unsafe in edition 2024
Allow calling these functions without `unsafe` blocks in editions up
until 2021, but don't trigger the `unused_unsafe` lint for `unsafe`
blocks containing these functions.

Fixes #27970.
Fixes #90308.
CC #124866.
2024-05-29 23:42:27 +02:00
Michael Goulet
a03ba7fd2d Add lang item for AsyncFnKindHelper::Upvars 2024-05-29 14:28:53 -04:00
Michael Goulet
a9c7e024c0 Add lang item for Future::Output 2024-05-29 14:22:56 -04:00
Michael Goulet
7f11d6f4bf Add lang items for AsyncFn's associated types 2024-05-29 14:09:19 -04:00
Daria Sukhonina
7cdd95e1a6 Optimize async drop glue for some old types 2024-05-29 12:56:59 +03:00
Scott McMurray
7150839552 Add custom mir support for PtrMetadata 2024-05-28 09:28:51 -07:00
Scott McMurray
459ce3f6bb Add an intrinsic for ptr::metadata 2024-05-28 09:28:51 -07:00
Nicholas Nethercote
e60c1916e0 Remove #[macro_use] extern crate tracing from rustc_span`.
Because explicit macro imports are better than implicit macro imports.
2024-05-22 16:03:48 +10:00
Nicholas Nethercote
220f3ab825 Add a useful comment.
For something that wasn't obvious to me.
2024-05-22 16:03:48 +10:00
bors
6715446db6 Auto merge of #125358 - matthiaskrgr:rollup-mx841tg, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #124570 (Miscellaneous cleanups)
 - #124772 (Refactor documentation for Apple targets)
 - #125011 (Add opt-for-size core lib feature flag)
 - #125218 (Migrate `run-make/no-intermediate-extras` to new `rmake.rs`)
 - #125225 (Use functions from `crt_externs.h` on iOS/tvOS/watchOS/visionOS)
 - #125266 (compiler: add simd_ctpop intrinsic)
 - #125348 (Small fixes to `std::path::absolute` docs)

Failed merges:

 - #125296 (Fix `unexpected_cfgs` lint on std)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-21 12:50:09 +00:00
Matthias Krüger
fd975f75fa
Rollup merge of #125266 - workingjubilee:stream-plastic-love, r=RalfJung,nikic
compiler: add simd_ctpop intrinsic

Fairly straightforward addition.

cc `@rust-lang/opsem` new (extremely boring) intrinsic
2024-05-21 12:47:06 +02:00
Michael Goulet
a502e7ac1d Implement BOXED_SLICE_INTO_ITER 2024-05-20 19:21:30 -04:00
Matthias Krüger
a79737c3f0
Rollup merge of #125314 - jdonszelmann:global-registration-feature-gate, r=pnkfelix
Add an experimental feature gate for global registration

See #125119 for the tracking issue.
2024-05-20 18:13:49 +02:00
Jubilee Young
1914c722b5 compiler: add simd_ctpop intrinsic 2024-05-18 18:11:20 -07:00
jdonszelmann
42119ff45c
create a feature gate 2024-05-14 16:11:26 +02:00
Eric Holk
ef6478ba5f
Add expr_2021 nonterminal and feature flag
This commit adds a new nonterminal `expr_2021` in macro patterns, and
`expr_fragment_specifier_2024` feature flag. For now, `expr` and
`expr_2021` are treated the same, but in future PRs we will update
`expr` to match to new grammar.

Co-authored-by: Vincezo Palazzo <vincenzopalazzodev@gmail.com>
2024-05-13 11:27:26 -07:00
bors
80420a693f Auto merge of #124747 - MasterAwesome:master, r=davidtwco
Support Result<T, E> across FFI when niche optimization can be used (v2)

This PR is identical to #122253, which was approved and merged but then removed from master by a force-push due to a [CI bug](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/ci.20broken.3F).

r? ghost

Original PR description:

---

Allow allow enums like `Result<T, E>` to be used across FFI if the T/E can be niche optimized and the non-niche-optimized type is FFI safe.

Implementation of https://github.com/rust-lang/rfcs/pull/3391
Tracking issue: https://github.com/rust-lang/rust/issues/110503

Additional ABI and codegen tests were added in https://github.com/rust-lang/rust/pull/115372
2024-05-06 00:55:49 +00:00
Michael Goulet
9dfd527c6f
Rollup merge of #124480 - Enselic:on-broken-pipe, r=jieyouxu
Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...`

In the stabilization [attempt](https://github.com/rust-lang/rust/pull/120832) of `#[unix_sigpipe = "sig_dfl"]`, a concern was [raised ](https://github.com/rust-lang/rust/pull/120832#issuecomment-2007394609) related to using a language attribute for the feature: Long term, we want `fn lang_start()` to be definable by any crate, not just libstd. Having a special language attribute in that case becomes awkward.

So as a first step towards the next stabilization attempt, this PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag `-Zon-broken-pipe=...` to remove that concern, since now the language is not "contaminated" by this feature.

Another point was [also raised](https://github.com/rust-lang/rust/pull/120832#issuecomment-1987023484), namely that the ui should not leak **how** it does things, but rather what the **end effect** is. The new flag uses the proposed naming. This is of course something that can be iterated on further before stabilization.

Tracking issue: https://github.com/rust-lang/rust/issues/97889
2024-05-03 23:34:22 -04:00
Martin Nordholts
cde0cde151 Change SIGPIPE ui from #[unix_sigpipe = "..."] to -Zon-broken-pipe=...
In the stabilization attempt of `#[unix_sigpipe = "sig_dfl"]`, a concern
was raised related to using a language attribute for the feature: Long
term, we want `fn lang_start()` to be definable by any crate, not just
libstd. Having a special language attribute in that case becomes
awkward.

So as a first step towards towards the next stabilization attempt, this
PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag
`-Zon-broken-pipe=...` to remove that concern, since now the language
is not "contaminated" by this feature.

Another point was also raised, namely that the ui should not leak
**how** it does things, but rather what the **end effect** is. The new
flag uses the proposed naming. This is of course something that can be
iterated on further before stabilization.
2024-05-02 19:48:29 +02:00
Matthias Krüger
38cbad9d26
Rollup merge of #124542 - CBSpeir:diagnostic-item-enumerate-method, r=scottmcm
Add diagnostic item for `std::iter::Iterator::enumerate`

Adds a diagnostic item for the `std::iter:Iterator::enumerate` trait method. This change, along with PR https://github.com/rust-lang/rust/pull/124308, will be used by the clippy `unused_enumerate_index` lint to move away from paths to using diagnostic items.

see: https://github.com/rust-lang/rust-clippy/issues/5393
2024-05-01 20:05:26 +02:00
Christopher B. Speir
c8079e9390 Add diagnostic item for std::iter::Iterator::enumerate 2024-04-29 17:36:31 -05:00
Nicholas Nethercote
4814fd0a4b Remove extern crate rustc_macros from numerous crates. 2024-04-29 10:21:54 +10:00