about summary refs log tree commit diff
path: root/compiler/rustc_span
AgeCommit message (Collapse)AuthorLines
2024-06-08offset_of: allow (unstably) taking the offset of slice tail fieldsRalf Jung-0/+1
2024-06-06Parse unsafe attributescarbotaniuman-0/+1
2024-06-06Auto merge of #124482 - spastorino:unsafe-extern-blocks, r=oli-obkbors-0/+2
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-05Rollup merge of #125921 - Zalathar:buckets, r=oli-obkMatthias Krüger-0/+64
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-05Add unsafe_extern_blocks feature flagSantiago Pastorino-0/+1
2024-06-04Handle safety keyword for extern block inner itemsSantiago Pastorino-0/+1
2024-06-04Add `Span::trim_end`Zalathar-0/+26
This is the counterpart of `Span::trim_start`.
2024-06-04Add unit tests for `Span::trim_start`Zalathar-0/+38
2024-06-03rustc_span: Inline some hot functionsVadim Petrochenkov-0/+2
2024-05-31Auto merge of #124662 - zetanumbers:needs_async_drop, r=oli-obkbors-0/+1
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](https://github.com/zetanumbers/rust/blob/67980dd6fb11917d23d01a19c2cf4cfc3978aac8/tests/ui/async-await/async-drop.rs) to decrease by 12%.
2024-05-30Auto merge of #124636 - tbu-:pr_env_unsafe, r=petrochenkovbors-0/+1
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-29Make `std::env::{set_var, remove_var}` unsafe in edition 2024Tobias Bucher-0/+1
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-29Add lang item for AsyncFnKindHelper::UpvarsMichael Goulet-0/+1
2024-05-29Add lang item for Future::OutputMichael Goulet-1/+1
2024-05-29Add lang items for AsyncFn's associated typesMichael Goulet-0/+3
2024-05-29Optimize async drop glue for some old typesDaria Sukhonina-0/+1
2024-05-28Add custom mir support for `PtrMetadata`Scott McMurray-0/+1
2024-05-28Add an intrinsic for `ptr::metadata`Scott McMurray-0/+1
2024-05-22Remove `#[macro_use]` extern crate tracing` from `rustc_span`.Nicholas Nethercote-3/+3
Because explicit macro imports are better than implicit macro imports.
2024-05-22Add a useful comment.Nicholas Nethercote-0/+3
For something that wasn't obvious to me.
2024-05-21Auto merge of #125358 - matthiaskrgr:rollup-mx841tg, r=matthiaskrgrbors-0/+1
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-21Rollup merge of #125266 - workingjubilee:stream-plastic-love, r=RalfJung,nikicMatthias Krüger-0/+1
compiler: add simd_ctpop intrinsic Fairly straightforward addition. cc `@rust-lang/opsem` new (extremely boring) intrinsic
2024-05-20Implement BOXED_SLICE_INTO_ITERMichael Goulet-1/+1
2024-05-20Rollup merge of #125314 - jdonszelmann:global-registration-feature-gate, ↵Matthias Krüger-0/+1
r=pnkfelix Add an experimental feature gate for global registration See #125119 for the tracking issue.
2024-05-18compiler: add simd_ctpop intrinsicJubilee Young-0/+1
2024-05-14create a feature gatejdonszelmann-0/+1
2024-05-13Add expr_2021 nonterminal and feature flagEric Holk-0/+2
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-06Auto merge of #124747 - MasterAwesome:master, r=davidtwcobors-0/+1
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-03Rollup merge of #124480 - Enselic:on-broken-pipe, r=jieyouxuMichael Goulet-1/+0
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-02Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...`Martin Nordholts-1/+0
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-01Rollup merge of #124542 - CBSpeir:diagnostic-item-enumerate-method, r=scottmcmMatthias Krüger-0/+1
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-04-29Add diagnostic item for std::iter::Iterator::enumerateChristopher B. Speir-0/+1
2024-04-29Remove `extern crate rustc_macros` from numerous crates.Nicholas Nethercote-8/+6
2024-04-25debuginfo: Stabilize `-Z debug-macros`, `-Z collapse-macro-debuginfo` and ↵Vadim Petrochenkov-23/+15
`#[collapse_debuginfo]` `-Z debug-macros` is "stabilized" by enabling it by default and removing. `-Z collapse-macro-debuginfo` is stabilized as `-C collapse-macro-debuginfo`. It now supports all typical boolean values (`parse_opt_bool`) in addition to just yes/no. Default value of `collapse_debuginfo` was changed from `false` to `external` (i.e. collapsed if external, not collapsed if local). `#[collapse_debuginfo]` attribute without a value is no longer supported to avoid guessing the default.
2024-04-25Rollup merge of #124322 - whosehang:master, r=NilstriebMatthias Krüger-1/+1
chore: fix some typos in comments
2024-04-24chore: fix some typos in commentswhosehang-1/+1
Signed-off-by: whosehang <whosehang@outlook.com>
2024-04-23Put the RFC behind a feature gate `result_ffi_guarantees`Arvind Mukund-0/+1
2024-04-23Add diagnostic item for std::iter::EnumerateChristopher B. Speir-0/+1
2024-04-23Rollup merge of #123993 - compiler-errors:coroutine-obl, r=lcnrLeón Orell Valerian Liehr-1/+1
Do `check_coroutine_obligations` once per typeck root We only need to do `check_coroutine_obligations` once per typeck root, especially since the new solver can't really (easily) associate which obligations correspond to which coroutines. This requires us to move the checks for sized coroutine fields into `mir_coroutine_witnesses`, but that's fine imo. r? lcnr
2024-04-23Rollup merge of #123050 - RalfJung:panic_str, r=m-ou-seMatthias Krüger-1/+1
panic_str only exists for the migration to 2021 panic macros The only caller is `expect_failed`, which is already a cold inline(never) function, so inlining into that function should be fine. (And indeed `panic_str` was `#[inline]` anyway.) The existence of panic_str risks someone calling it when they should call `panic` instead, and I can't see a reason why this footgun should exist. I also extended the comment in `panic` to explain why it needs a `'static` string -- I know I've wondered about this in the past and it took me quite a while to understand.
2024-04-23Auto merge of #121801 - zetanumbers:async_drop_glue, r=oli-obkbors-0/+12
Add simple async drop glue generation This is a prototype of the async drop glue generation for some simple types. Async drop glue is intended to behave very similar to the regular drop glue except for being asynchronous. Currently it does not execute synchronous drops but only calls user implementations of `AsyncDrop::async_drop` associative function and awaits the returned future. It is not complete as it only recurses into arrays, slices, tuples, and structs and does not have same sensible restrictions as the old `Drop` trait implementation like having the same bounds as the type definition, while code assumes their existence (requires a future work). This current design uses a workaround as it does not create any custom async destructor state machine types for ADTs, but instead uses types defined in the std library called future combinators (deferred_async_drop, chain, ready_unit). Also I recommend reading my [explainer](https://zetanumbers.github.io/book/async-drop-design.html). This is a part of the [MCP: Low level components for async drop](https://github.com/rust-lang/compiler-team/issues/727) work. Feature completeness: - [x] `AsyncDrop` trait - [ ] `async_drop_in_place_raw`/async drop glue generation support for - [x] Trivially destructible types (integers, bools, floats, string slices, pointers, references, etc.) - [x] Arrays and slices (array pointer is unsized into slice pointer) - [x] ADTs (enums, structs, unions) - [x] tuple-like types (tuples, closures) - [ ] Dynamic types (`dyn Trait`, see explainer's [proposed design](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#async-drop-glue-for-dyn-trait)) - [ ] coroutines (https://github.com/rust-lang/rust/pull/123948) - [x] Async drop glue includes sync drop glue code - [x] Cleanup branch generation for `async_drop_in_place_raw` - [ ] Union rejects non-trivially async destructible fields - [ ] `AsyncDrop` implementation requires same bounds as type definition - [ ] Skip trivially destructible fields (optimization) - [ ] New [`TyKind::AdtAsyncDestructor`](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#adt-async-destructor-types) and get rid of combinators - [ ] [Synchronously undroppable types](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#exclusively-async-drop) - [ ] Automatic async drop at the end of the scope in async context
2024-04-21Add an intrinsic that lowers to AggregateKind::RawPtrScott McMurray-0/+1
2024-04-19Stop sorting `Span`s' `SyntaxContext`, as that is incompatible with incrementalOli Scherer-32/+16
2024-04-16Rollup merge of #123512 - Jules-Bertholet:ref-pat-eat-one-layer-2024, ↵Guillaume Gomez-0/+1
r=Nadrieril Match ergonomics 2024: Implement eat-one-layer r? `@Nadrieril` cc #123076 `@rustbot` label A-edition-2024 A-patterns
2024-04-16Rollup merge of #122811 - nnethercote:mv-SourceMap-init, r=WaffleLapkinGuillaume Gomez-43/+36
Move `SourceMap` initialization So it happens at the same time as `SessionGlobals` initialization, rather than shortly afterward. r? `@WaffleLapkin`
2024-04-16Add simple async drop glue generationzetanumbers-0/+12
Explainer: https://zetanumbers.github.io/book/async-drop-design.html https://github.com/rust-lang/rust/pull/121801
2024-04-16Rollup merge of #123535 - Jules-Bertholet:mut_dont_reset_binding_mode_2024, ↵Matthias Krüger-0/+1
r=Nadrieril Match ergonomics 2024: `mut` doesn't reset binding mode r? ``@Nadrieril`` cc https://github.com/rust-lang/rust/issues/123076 ``@rustbot`` label A-edition-2024 A-patterns
2024-04-15Match ergonomics 2024: Implement eat-one-layerJules Bertholet-0/+1
2024-04-15Rename feature gateJules Bertholet-1/+1
2024-04-15Match ergonomics 2024: `mut` doesn't reset binding modeJules Bertholet-0/+1