about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2023-12-08Rename some more coro_kind -> coroutine_kindMichael Goulet-8/+9
2023-12-08More nitsMichael Goulet-4/+4
2023-12-08Introduce closure_id method on CoroutineKindMichael Goulet-24/+24
2023-12-08Auto merge of #118420 - compiler-errors:async-gen, r=eholkbors-355/+1118
Introduce support for `async gen` blocks I'm delighted to demonstrate that `async gen` block are not very difficult to support. They're simply coroutines that yield `Poll<Option<T>>` and return `()`. **This PR is WIP and in draft mode for now** -- I'm mostly putting it up to show folks that it's possible. This PR needs a lang-team experiment associated with it or possible an RFC, since I don't think it falls under the jurisdiction of the `gen` RFC that was recently authored by oli (https://github.com/rust-lang/rfcs/pull/3513, https://github.com/rust-lang/rust/issues/117078). ### Technical note on the pre-generator-transform yield type: The reason that the underlying coroutines yield `Poll<Option<T>>` and not `Poll<T>` (which would make more sense, IMO, for the pre-transformed coroutine), is because the `TransformVisitor` that is used to turn coroutines into built-in state machine functions would have to destructure and reconstruct the latter into the former, which requires at least inserting a new basic block (for a `switchInt` terminator, to match on the `Poll` discriminant). This does mean that the desugaring (at the `rustc_ast_lowering` level) of `async gen` blocks is a bit more involved. However, since we already need to intercept both `.await` and `yield` operators, I don't consider it much of a technical burden. r? `@ghost`
2023-12-08Add testsMichael Goulet-19/+148
2023-12-08HACK: constrain yield type in check_fn so that projection is successful even ↵Michael Goulet-3/+23
with no yield
2023-12-08Make some matches exhaustive to avoid bugs, fix toolsMichael Goulet-46/+72
2023-12-08Support async gen fnMichael Goulet-104/+115
2023-12-08coro_kind -> coroutine_kindMichael Goulet-75/+100
2023-12-08Implement `async gen` blocksMichael Goulet-54/+563
2023-12-08Rework coroutine transform to be more flexible in preparation for async ↵Michael Goulet-80/+123
generators
2023-12-08Auto merge of #118527 - Nadrieril:never_patterns_parse, r=compiler-errorsbors-236/+772
never_patterns: Parse match arms with no body Never patterns are meant to signal unreachable cases, and thus don't take bodies: ```rust let ptr: *const Option<!> = ...; match *ptr { None => { foo(); } Some(!), } ``` This PR makes rustc accept the above, and enforces that an arm has a body xor is a never pattern. This affects parsing of match arms even with the feature off, so this is delicate. (Plus this is my first non-trivial change to the parser). ~~The last commit is optional; it introduces a bit of churn to allow the new suggestions to be machine-applicable. There may be a better solution? I'm not sure.~~ EDIT: I removed that commit r? `@compiler-errors`
2023-12-08Auto merge of #118689 - compiler-errors:const-drop, r=fee1-deadbors-67/+57
Fix const drop checking Fixes confirmation of `~const Destruct` and const drops. r? fee1-dead
2023-12-08Auto merge of #118668 - fmease:resolve-assoc-item-bindings-by-namespace, ↵bors-416/+598
r=compiler-errors Resolve associated item bindings by namespace This is the 3rd commit split off from #118360 with tests reblessed (they no longer contain duplicated diags which were caused by 4c0addc80af4666f26d7ad51fe34a0e2dd0b8b74) & slightly adapted (removed supertraits from a UI test, cc #118040). > * Resolve all assoc item bindings (type, const, fn (feature `return_type_notation`)) by namespace instead of trying to resolve a type first (in the non-RTN case) and falling back to consts afterwards. This is consistent with RTN. E.g., for `Tr<K = {…}>` we now always try to look up assoc consts (this extends to supertrait bounds). This gets rid of assoc tys shadowing assoc consts in assoc item bindings which is undesirable & inconsistent (types and consts live in different namespaces after all) > * Consolidate the resolution of assoc {ty, const} bindings and RTN (dedup, better diags for RTN) > * Fix assoc consts being labeled as assoc *types* in several diagnostics > * Make a bunch of diagnostics translatable Fixes #112560 (error → pass). As discussed r? `@compiler-errors` --- **Addendum**: What I call “associated item bindings” are commonly referred to as “type bindings” for historical reasons. Nowadays, “type bindings” include assoc type bindings, assoc const bindings and RTN (return type notation) which is why I prefer not to use this outdated term.
2023-12-08Auto merge of #118732 - matthiaskrgr:rollup-ub9pgjm, r=matthiaskrgrbors-192/+214
Rollup of 8 pull requests Successful merges: - #118505 (Elaborate on ip_addr bit conversion endianness) - #118581 (OnceLock: Add note about drop and statics) - #118677 ([rustdoc] Fix display of features) - #118690 (coverage: Avoid unnecessary macros in unit tests) - #118693 (Tell MirUsedCollector that the pointer alignment checks calls its panic symbol) - #118695 (coverage: Merge refined spans in a separate final pass) - #118709 (fix jobserver GLOBAL_CLIENT_CHECKED uninitialized before use) - #118722 (rustdoc: remove unused parameter `reversed` from onEach(Lazy)) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-08Rollup merge of #118722 - notriddle:notriddle/dom-opt-3, r=GuillaumeGomezMatthias Krüger-19/+6
rustdoc: remove unused parameter `reversed` from onEach(Lazy) This feature was added in edec5807ac5ba90cbc0c61a5ec7b80f29e1eea33 to support JavaScript-based toggles that were later replaced with HTML `<details>`.
2023-12-08Rollup merge of #118709 - oksbsb:fix-job-server, r=SparrowLiiMatthias Krüger-16/+19
fix jobserver GLOBAL_CLIENT_CHECKED uninitialized before use override #118589, resolve merge conflict `@petrochenkov` `@SparrowLii` Thanks!
2023-12-08Rollup merge of #118695 - Zalathar:push-refined, r=davidtwcoMatthias Krüger-50/+37
coverage: Merge refined spans in a separate final pass Pulling this merge step out of `push_refined_span` and into a separate pass lets us push directly to `refined_spans` instead of calling a helper method. Because the compiler can now see partial borrows of `refined_spans`, we can remove some extra code that was jumping through hoops to satisfy the borrow checker. --- ``@rustbot`` label +A-code-coverage
2023-12-08Rollup merge of #118693 - saethlin:alignment-check-symbol-reachable, r=bjorn3Matthias Krüger-0/+3
Tell MirUsedCollector that the pointer alignment checks calls its panic symbol Fixes https://github.com/rust-lang/rust/pull/118683 (not an issue, but that PR is a basically a bug report) When we had `panic_immediate_abort` start adding `#[inline]` to this panic function, builds started breaking because we failed to write up the MIR assert terminator to the correct panic shim. Things happened to work before by pure luck because without this feature enabled, the function we're inserting calls to is `#[inline(never)]` so we always generated code for it. r? bjorn3
2023-12-08Rollup merge of #118690 - Zalathar:test-macros, r=cjgillotMatthias Krüger-80/+33
coverage: Avoid unnecessary macros in unit tests These macros don't provide enough value to justify their complexity, when they can just as easily be functions instead. --- `@rustbot` label +A-code-coverage
2023-12-08Rollup merge of #118677 - GuillaumeGomez:doc_cfg-display, r=notriddleMatthias Krüger-9/+43
[rustdoc] Fix display of features Fixes https://github.com/rust-lang/rust/issues/118615. It now looks like this: ![image](https://github.com/rust-lang/rust/assets/3050060/6e77204e-0706-44a3-89ae-2dbd1934ebbc) We can't use flex without breaking the flow, meaning we can't vertically align items as we want. Because of that, the `min-height` was problematic as it rendered weirdly and therefore needed to be removed. r? `@notriddle`
2023-12-08Rollup merge of #118581 - ianrrees:add-drop-note-to-once_lock, r=workingjubileeMatthias Krüger-14/+25
OnceLock: Add note about drop and statics Hi! Just a minor documentation addition, I've attempted to build docs locally but ran in to issues, so am not 100% sure this change will render correctly.
2023-12-08Rollup merge of #118505 - CLEckhardt:update_ip_addr_bits_docs, r=cuviperMatthias Krüger-4/+48
Elaborate on ip_addr bit conversion endianness Adds explanation of how endianness is handled when converting `Ipv4Addr` and `Ipv6Addr` to and from bits. This is intended to unblock stabilization of the affected methods. Addresses #113744
2023-12-08Auto merge of #118301 - weihanglo:rustfix-doc, r=albertlarsan68bors-5/+4
docs: publish nightly doc for `rustfix` `rustfix `has migrated into rust-lang/cargo in <https://github.com/rust-lang/cargo/issues/13005>. We now can publish nightly doc for it.
2023-12-08Auto merge of #118725 - lcnr:normalizes-to-projection-split-3, r=BoxyUwUbors-189/+310
split `NormalizesTo` out of `Projection` 3 third attempt at #112658. Rebasing #116262 is very annoying, so I am doing it again from scratch. We should now be able to merge it without regressing anything as we handle occurs check failures involving aliases correctly since #117088. see https://hackmd.io/ktEL8knTSYmtdfrMMnA-Hg fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/1 r? `@compiler-errors`
2023-12-081. fix jobserver GLOBAL_CLIENT_CHECKED uninitialized before useoksbsb-16/+19
2. jobserver::initialize_checked should call before build_session, still should use EarlyErrorHandler, so revert stderr change in #118635
2023-12-08update fixmelcnr-4/+3
2023-12-08add regression testslcnr-0/+43
2023-12-08implement and use `NormalizesTo`lcnr-125/+135
2023-12-08Auto merge of #118442 - tmiasko:fuel-inc, r=lqdbors-11/+22
-Zfuel is incompatible with incremental compilation
2023-12-08Fuel is incompatible with incremental compilationTomasz Miąsko-1/+16
2023-12-07Auto merge of #118723 - matthiaskrgr:rollup-409e9u1, r=matthiaskrgrbors-97/+310
Rollup of 6 pull requests Successful merges: - #116420 (discard invalid spans in external blocks) - #118686 (Only check principal trait ref for object safety) - #118688 (Add method to get type of an Rvalue in StableMIR) - #118707 (Ping GuillaumeGomez for changes in rustc_codegen_gcc) - #118712 (targets: remove not-added {i386,i486}-unknown-linux-gnu) - #118719 (CFI: Add char to CFI integer normalization) Failed merges: - #117586 (Uplift the (new solver) canonicalizer into `rustc_next_trait_solver`) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-07Inline check_thread_count implementationTomasz Miąsko-11/+7
2023-12-07Resolve assoc item bindings by namespaceLeón Orell Valerian Liehr-416/+598
If a const is expected, resolve a const. If a type is expected, resolve a type. Don't try to resolve a type first falling back to consts.
2023-12-08OnceLock: Rework example, statics aren't droppedIan Rees-14/+25
2023-12-07Rollup merge of #118719 - rcvalle:rust-cfi-normalize-integers-118032, ↵Matthias Krüger-63/+29
r=compiler-errors CFI: Add char to CFI integer normalization Adds char to CFI integer normalization to conform to #118032 for cross-language CFI support.
2023-12-07Rollup merge of #118712 - davidtwco:targets-remove-i386-i486, r=compiler-errorsMatthias Krüger-16/+0
targets: remove not-added {i386,i486}-unknown-linux-gnu These files were added to the repository but never wired up so they could be used - and that was a few years ago without anyone noticing - so let's remove these, they can be re-added if someone wants them. cc #80662 r? ```@pnkfelix``` (familiar with the tier policy and Wesley is on vacation)
2023-12-07Rollup merge of #118707 - GuillaumeGomez:ping-cg_gcc, r=antoyoMatthias Krüger-1/+1
Ping GuillaumeGomez for changes in rustc_codegen_gcc Since I work on it and also added its testsuite into rustc's CI, I'd like to know if there are changes.
2023-12-07Rollup merge of #118688 - celinval:smir-rvalue-ty, r=compiler-errorsMatthias Krüger-5/+202
Add method to get type of an Rvalue in StableMIR Provide a method to StableMIR users to retrieve the type of an Rvalue operation. There were two possible implementation: 1. Create the logic inside stable_mir to process the type according to the Rvalue semantics, which duplicates the logic of `rustc_middle::mir::Rvalue::ty()`. 2. Implement the Rvalue translation from StableMIR back to internal representation, invoke the `rustc_middle::mir::Rvalue::ty()`, and translate the return value to StableMIR. I chose the first one for now since the duplication was fairly small, and the option 2 would require way more work to translate everything back to rustc internal representation. If we eventually add those translations, we could easily swap to the option 2. ```@compiler-errors``` / ```@ouz-a``` Please let me know if you have any strong opinion here. r? ```@compiler-errors```
2023-12-07Rollup merge of #118686 - compiler-errors:object-safety, r=lcnrMatthias Krüger-10/+7
Only check principal trait ref for object safety It should make things a bit faster, in case we end up registering a bunch of object safety preds. r? ```@ghost```
2023-12-07Rollup merge of #116420 - bvanjoi:fix-116203, r=NilstriebMatthias Krüger-2/+71
discard invalid spans in external blocks Fixes #116203 This PR has discarded the invalid `const_span`, thereby making the format more neat. r? ``@Nilstrieb``
2023-12-07Auto merge of #118568 - DianQK:no-builtins-symbols, r=pnkfelixbors-4/+30
Avoid adding builtin functions to `symbols.o` We found performance regressions in #113923. The problem seems to be that `--gc-sections` does not remove these symbols. I tested that lld removes these symbols, but ld and gold do not. I found that `used` adds symbols to `symbols.o` at https://github.com/rust-lang/rust/blob/3e202ead604be31f4c1a5798a296953d3159da7e/compiler/rustc_codegen_ssa/src/back/linker.rs#L1786-L1791. The PR removes builtin functions. Note that under LTO, ld still preserves these symbols. (lld will still remove them.) The first commit also fixes #118559. But I think the second commit also makes sense.
2023-12-07rustdoc: remove unused parameter `reversed` from onEach(Lazy)Michael Howell-19/+6
This feature was added in edec5807ac5ba90cbc0c61a5ec7b80f29e1eea33 to support JavaScript-based toggles that were later replaced with HTML `<details>`.
2023-12-07CFI: Add char to CFI integer normalizationRamon de C Valle-63/+29
Adds char to CFI integer normalization to conform to #118032 for cross-language CFI support.
2023-12-07Auto merge of #118324 - RalfJung:ctfe-read-only-pointers, r=saethlinbors-462/+784
compile-time evaluation: detect writes through immutable pointers This has two motivations: - it unblocks https://github.com/rust-lang/rust/pull/116745 (and therefore takes a big step towards `const_mut_refs` stabilization), because we can now detect if the memory that we find in `const` can be interned as "immutable" - it would detect the UB that was uncovered in https://github.com/rust-lang/rust/pull/117905, which was caused by accidental stabilization of `copy` functions in `const` that can only be called with UB When UB is detected, we emit a future-compat warn-by-default lint. This is not a breaking change, so completely in line with [the const-UB RFC](https://rust-lang.github.io/rfcs/3016-const-ub.html), meaning we don't need t-lang FCP here. I made the lint immediately show up for dependencies since it is nearly impossible to even trigger this lint without `const_mut_refs` -- the accidentally stabilized `copy` functions are the only way this can happen, so the crates that popped up in #117905 are the only causes of such UB (in the code that crater covers), and the three cases of UB that we know about have all been fixed in their respective crates already. The way this is implemented is by making use of the fact that our interpreter is already generic over the notion of provenance. For CTFE we now use the new `CtfeProvenance` type which is conceptually an `AllocId` plus a boolean `immutable` flag (but packed for a more efficient representation). This means we can mark a pointer as immutable when it is created as a shared reference. The flag will be propagated to all pointers derived from this one. We can then check the immutable flag on each write to reject writes through immutable pointers. I just hope perf works out.
2023-12-07add unused `NormalizesTo` predicatelcnr-64/+128
2023-12-07avoid marking as immutable what is already immutableRalf Jung-6/+16
this has been demonstrated to help performance
2023-12-07also print 'immutable' flagRalf Jung-138/+139
2023-12-07compile-time evaluation: emit a lint when a write through an immutable ↵Ralf Jung-185/+380
pointer occurs
2023-12-07ctfe interpreter: extend provenance so that it can track whether a pointer ↵Ralf Jung-145/+261
is immutable