about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2023-12-08Support bare unit structs in destructuring assignmentsMichael Goulet-0/+2
2023-12-08use magenta instead of bold for highlightingjyn-1/+1
according to a poll of gay people in my phone, purple is the most popular color to use for highlighting | color | percentage | | ---------- | ---------- | | bold white | 6% | | blue | 14% | | cyan | 26% | | purple | 37% | | magenta | 17% | unfortunately, purple is not supported by 16-color terminals, which rustc apparently wants to support for some reason. until we require support for full 256-color terms (e.g. by doing the same feature detection as we currently do for urls), we can't use it. instead, i have collapsed the purple votes into magenta on the theory that they're close, and also because magenta is pretty.
2023-12-08Simplify and comment the special-casing for Windows colorsjyn-10/+10
2023-12-08Auto merge of #118420 - compiler-errors:async-gen, r=eholkbors-319/+929
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-08Make it not depend on nightly conditionallyMichael Goulet-1/+7
2023-12-08FeedbackMichael Goulet-229/+205
- Take more things by self, not &self - Clone more things - Rework namespacing so we can use `ty::` in the canonicalizer
2023-12-08Uplift canonicalizer into new trait solver crateMichael Goulet-272/+498
2023-12-08Add testsMichael Goulet-9/+16
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-45/+68
2023-12-08Support async gen fnMichael Goulet-91/+108
2023-12-08coro_kind -> coroutine_kindMichael Goulet-55/+71
2023-12-08Implement `async gen` blocksMichael Goulet-54/+538
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-183/+320
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-08privacy: visit trait def id of projectionsDavid Wood-6/+7
A refactoring in #117076 changed the `DefIdVisitorSkeleton` to avoid calling `visit_projection_ty` for `ty::Projection` aliases, and instead just iterate over the args - this makes sense, as `visit_projection_ty` will indirectly visit all of the same args, but in doing so, will also create a `TraitRef` containing the trait's `DefId`, which also gets visited. The trait's `DefId` isn't visited when we only visit the arguments without separating them into `TraitRef` and own args first. Signed-off-by: David Wood <david@davidtw.co>
2023-12-08only return true in `fallback_types' if fallback has occurredlcnr-11/+10
2023-12-08Auto merge of #118689 - compiler-errors:const-drop, r=fee1-deadbors-33/+54
Fix const drop checking Fixes confirmation of `~const Destruct` and const drops. r? fee1-dead
2023-12-08cleanup type variable storagelcnr-97/+43
2023-12-08update target feature following LLVM API changeKrasimir Georgiev-1/+5
LLVM commit https://github.com/llvm/llvm-project/commit/e81796671890b59c110f8e41adc7ca26f8484d20 renamed the `unaligned-scalar-mem` target feature to `fast-unaligned-access`.
2023-12-08coverage: Add `#[track_caller]` to the span generator's unwrap methodsZalathar-14/+12
This should make it easier to investigate unwrap failures in bug reports.
2023-12-08coverage: Simplify the heuristic for ignoring `async fn` return spansZalathar-17/+14
2023-12-08coverage: Use `SpanMarker` to mark the full condition of `if !`Zalathar-0/+5
When MIR is built for an if-not expression, the `!` part of the condition doesn't correspond to any MIR statement, so coverage instrumentation normally can't see it. We can fix that by deliberately injecting a dummy statement whose sole purpose is to associate that span with its enclosing block.
2023-12-08coverage: Use `SpanMarker` to mark `continue` expressions.Zalathar-16/+8
This replaces the previous workaround, which was to inject a dummy `Assign` statement.
2023-12-08coverage: Add `CoverageKind::SpanMarker` for including extra spans in MIRZalathar-3/+36
There are cases where coverage instrumentation wants to show a span for some syntax element, but there is no MIR node that naturally carries that span, so the instrumentor can't see it. MIR building can now use this new kind of coverage statement to deliberately include those spans in MIR, attached to a dummy statement that has no other effect.
2023-12-08Auto merge of #118668 - fmease:resolve-assoc-item-bindings-by-namespace, ↵bors-335/+399
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-08temporarily revert "ice on ambguity in mir typeck"Ali MJ Al-Nasrawy-12/+4
Reverts #116530
2023-12-08Rollup merge of #118709 - oksbsb:fix-job-server, r=SparrowLiiMatthias Krüger-12/+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-75/+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-07recurse into refs when comparing tys for diagnosticsjyn-42/+52
2023-12-08Auto merge of #118725 - lcnr:normalizes-to-projection-split-3, r=BoxyUwUbors-178/+253
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-12/+19
2. jobserver::initialize_checked should call before build_session, still should use EarlyErrorHandler, so revert stderr change in #118635
2023-12-07Enable stack probes on aarch64 for LLVM 18Josh Stone-28/+63
2023-12-08update fixmelcnr-4/+3
2023-12-07Add tests to allocation methods and fix is_null()Celina G. Val-2/+24
2023-12-07Fix conversion to StaticDef and add testCelina G. Val-2/+2
2023-12-07Add instance evaluation and methods to read allocCelina G. Val-22/+294
The instance evaluation is needed to handle intrinsics such as `type_id` and `type_name`. Since we now use Allocation to represent all evaluated constants, provide a few methods to help process the data inside an allocation.
2023-12-08implement and use `NormalizesTo`lcnr-114/+121
2023-12-08Auto merge of #118442 - tmiasko:fuel-inc, r=lqdbors-11/+11
-Zfuel is incompatible with incremental compilation
2023-12-08Fuel is incompatible with incremental compilationTomasz Miąsko-1/+5
2023-12-08Tweak `GenKillAnalysis`.Nicholas Nethercote-21/+24
`GenKillAnalysis` has five methods that take a transfer function arg: - `statement_effect` - `before_statement_effect` - `terminator_effect` - `before_terminator_effect` - `call_return_effect` All the transfer function args have type `&mut impl GenKill<Self::Idx>`, except for `terminator_effect`, which takes the simpler `Self::Domain`. But only the first two need to be `impl GenKill`. The other three can all be `Self::Domain`, just like `Analysis`. So this commit changes the last two to take `Self::Domain`, making `GenKillAnalysis` and `Analysis` more similar. (Another idea would be to make all these methods `impl GenKill`. But that doesn't work: `MaybeInitializedPlaces::terminator_effect` requires the arg be `Self::Domain` so that `self_is_unwind_dead(place, state)` can be called on it.)
2023-12-08Remove `BorrowckAnalyses`.Nicholas Nethercote-28/+18
This results in two non-generic types being used: `BorrowckResults` and `BorrowckFlowState`. It's a net reduction in lines of code, and a little easier to read.
2023-12-07Auto merge of #118723 - matthiaskrgr:rollup-409e9u1, r=matthiaskrgrbors-39/+222
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-335/+399
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-08Remove `impl_visitable!`.Nicholas Nethercote-67/+64
It is used just once. With it removed, the relevant code is a little boilerplate-y but much easier to read, and is the same length. Overall I think it's an improvement.
2023-12-08Remove unused arguments from `ResultsVisitor::visit_block_{start,end}`.Nicholas Nethercote-34/+8
2023-12-07Rollup merge of #118719 - rcvalle:rust-cfi-normalize-integers-118032, ↵Matthias Krüger-6/+9
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.