about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-05-21Rollup merge of #141267 - dianne:fix-141265, r=oli-obkMatthias Krüger-1/+3
only resolve top-level guard patterns' guards once We resolve guard patterns' guards in `resolve_pattern_inner`, so to avoid resolving them multiple times, we must avoid doing so earlier. To accomplish this, `LateResolutionVisitor::visit_pat` contains a case for guard patterns that avoids visiting their guards while walking patterns. This PR fixes #141265, which was due to `visit::walk_pat` being used instead; this meant guards at the top level of a pattern would be visited twice. e.g. it would ICE on `for x if x in [] {}`, but not `for (x if x) in [] {}`. `visit_pat` was already used for the guard pattern in the second example, on account of the top-level pattern being parens.
2025-05-21Auto merge of #140386 - oli-obk:match-on-lang-item-kind, r=compiler-errorsbors-85/+91
Match on lang item kind instead of using an if/else chain Similar to how the new solver does this. Just noticed while I was adding a new entry to the chain 😆
2025-05-21Async drop fix for 'broken mir in AsyncDropGlue, place has deref as a later ↵Andrew Zhogin-8/+13
projection' (#140975)
2025-05-21When AsyncDrop impl is empty, sync drop generated in elaborator (Fixes #140974)Andrew Zhogin-1/+23
2025-05-21eagerly check nested obligations when coercing fndefslcnr-3/+31
2025-05-21Use DeepRejectCtxt in assemble_inherent_candidates_from_paramMichael Goulet-12/+12
2025-05-21Rollup merge of #141318 - nnethercote:fix-140884, r=compiler-errorsMatthias Krüger-1/+2
Avoid creating an empty identifer in `Symbol::to_ident_string`. Because that causes an assertion failure in debug builds. Fixes #140884. r? `@oli-obk`
2025-05-21Rollup merge of #141317 - dianne:continue-liveness-ice-fix, r=compiler-errorsMatthias Krüger-14/+33
typeck: catch `continue`s pointing to blocks This taints the typeck results with errors if a `continue` is found not pointing to a loop. A few things were going wrong here. First, since this wasn't caught in typeck, we'd end up building the THIR and then running liveness lints on ill-formed HIR. Since liveness assumes all `continue`s point to loops, it wasn't setting a live node for the `continue`'s destination. There was a fallback for if it couldn't retrieve that live node, but it was faulty; it would create a new live node to represent an erroneous state after the analysis's RWU table had already been built. This would ICE if the new live node was used in operations, such as merging results from the arms of a match. I've removed this error-recovery since it was buggy, and we should really catch bad labels before liveness. I've also replaced an outdated comment about when liveness lints are run. At this point, I think the call to `check_liveness` could be moved elsewhere, but if it can be run when the typeck results are tainted by errors, it'll need some slight refactoring so it can bail out in that case. In lieu of that, I've added an assert. Fixes #113379 Fixes #121623
2025-05-21Rollup merge of #141284 - compiler-errors:query-nit, r=oli-obkMatthias Krüger-0/+1
Allow trailing comma after argument in query definition Don't catastrophically fail the query macro if you put a comma after your query key! r? oli-obk
2025-05-21Rollup merge of #141213 - xizheyin:issue-141136, r=nnethercoteMatthias Krüger-6/+18
Suggest use "{}", self.x instead of {self.x} when resolve x as field of `self` Fixes #141136 Changes can be seen in the second commit: https://github.com/rust-lang/rust/commit/9de7fff0d8ab72fb57dea6255fc10fe35219db72 r? compiler
2025-05-21Do not eagerly fold consts in normalize_param_env_or_error if new solverMichael Goulet-3/+1
2025-05-21Avoid creating an empty identifer in `Symbol::to_ident_string`.Nicholas Nethercote-1/+2
Because that causes an assertion failure in debug builds. Fixes #140884.
2025-05-21Downgrade the confident of suggestion `available field in format string` and ↵xizheyin-10/+4
optimize expression Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-21Update UI testsMarcelo Domínguez-4/+3
2025-05-21Initial naive implementation using `Symbols` to represent autodiff modes ↵Marcelo Domínguez-8/+22
(`Forward`, `Reverse`) Since the mode is no longer part of `meta_item`, we must insert it manually (otherwise macro expansion with `#[rustc_autodiff]` won't work). This can be revised later if a more structured representation becomes necessary (using enums, annotated structs, etc). Some tests are currently failing. I'll address them next.
2025-05-21Disable autodiff bootstrappingMarcelo Domínguez-9/+1
2025-05-21Rollup merge of #141308 - spastorino:fix-rpitit-error-reporting-ice, ↵Matthias Krüger-10/+13
r=nnethercote Do not call name() on rpitit assoc_item Fixes #141143 r? `@nnethercote`
2025-05-21Auto merge of #127721 - bvanjoi:issue-124273, r=petrochenkovbors-32/+115
collect doc alias as tips during resolution Close #124273 Collect the symbol in the doc alias attributes and provide a tip when a match is found. r? `@estebank`
2025-05-20typeck: catch `continue`s pointing to blocksdianne-14/+33
This taints the typeck results with errors if a `continue` is found not pointing to a loop, which fixes an ICE. A few things were going wrong here. First, since this wasn't caught in typeck, we'd end up building the THIR and then running liveness lints on ill-formed HIR. Since liveness assumes all `continue`s point to loops, it wasn't setting a live node for the `continue`'s destination. However, the fallback for this was faulty; it would create a new live node to represent the erroneous state after the analysis's RWU table had already been built. This would ICE if the new live node was used in operations, such as merging results from the arms of a match. I've removed this error-recovery since it was buggy, and we should really catch bad labels before liveness. I've also replaced an outdated comment about when liveness lints are run. At this point, I think the call to `check_liveness` could be moved elsewhere, but if it can be run when the typeck results are tainted by errors, it'll need some slight refactoring so it can bail out in that case. In lieu of that, I've added an assertion.
2025-05-20Auto merge of #141305 - matthiaskrgr:rollup-l6nwaht, r=matthiaskrgrbors-0/+25
Rollup of 7 pull requests Successful merges: - #140972 (Add TRACING_ENABLED to Machine and add enter_trace_span!()) - #141282 (`core_float_math`: Move functions to `math` module) - #141288 (Get rid of unnecessary `BufDisplay` abstraction) - #141289 (use `Self` alias in self types rather than manually substituting it) - #141291 (link tracking issue in explicit-extern-abis.md) - #141294 (triagebot: ping me if rustdoc js is modified) - #141303 (Fix pagetoc inactive color in rustc book) r? `@ghost` `@rustbot` modify labels: rollup
2025-05-20Rename `cfg_match!` to `cfg_select!`Trevor Gross-6/+6
At [1] it was pointed out that `cfg_match!` syntax does not actually align well with match syntax, which is a possible source of confusion. The comment points out that usage is instead more similar to ecosystem `select!` macros. Rename `cfg_match!` to `cfg_select!` to match this. Tracking issue: https://github.com/rust-lang/rust/issues/115585 [1]: https://github.com/rust-lang/rust/issues/115585#issuecomment-2346307605
2025-05-20Do not call name() on rpitit assoc_itemSantiago Pastorino-10/+13
2025-05-20Rollup merge of #140972 - Stypox:machine-tracing-flag, r=RalfJungMatthias Krüger-0/+25
Add TRACING_ENABLED to Machine and add enter_trace_span!() This PR adds the necessary infrastructure to make it possible to do tracing calls from within `rustc_const_eval` when running Miri, while making sure they don't impact the performance of normal compiler execution. This is done by adding a `const` boolean to `Machine`, false by default, but that will be set to true in Miri only. The tracing macro `enter_trace_span!()` checks if it is true before doing anything, and since the value of a `const` is known at compile time, if it it false it the whole tracing call should be optimized out. I will soon open further PRs to add tracing macro calls similar to this one, so that afterwards it will be possible to learn more about Miri's time spent in the various interpretation steps: ```rs let _guard = enter_trace_span!(M, "eval_statement", "{:?}", stmt); ``` r? `@RalfJung`
2025-05-21Rename `MetaItemParser::path_without_args` as `MetaItemParser::path`.Nicholas Nethercote-13/+13
And avoid the clone.
2025-05-21Remove `MetaItemParser::{path,deconstruct}`.Nicholas Nethercote-15/+7
They're equivalent, and `path` is unused, and `deconstruct` has only one call site outside of `path`.
2025-05-21Remove `MetaItemParser::{word,word_without_args,path_is}`.Nicholas Nethercote-23/+0
They are unused.
2025-05-21Remove an unnecessary lifetime.Nicholas Nethercote-1/+1
2025-05-21collect doc alias as tips during resolutionbohan-32/+115
2025-05-20Add enter_trace_span!() that checks if tracing is enabledStypox-0/+19
2025-05-20Rollup merge of #141285 - compiler-errors:tick, r=lcnrMatthias Krüger-1/+1
Add tick to `RePlaceholder` debug output Present when debug printing canonical queries r? lcnr
2025-05-20Rollup merge of #141279 - nnethercote:lower_to_hir, r=compiler-errorsMatthias Krüger-38/+26
`lower_to_hir` cleanups Some minor cleanups I made when reading this code. r? `@Nadrieril`
2025-05-20Rollup merge of #141275 - dianne:gather-guard-pat-locals-once, r=compiler-errorsMatthias Krüger-1/+6
`gather_locals`: only visit guard pattern guards when checking the guard When checking a pattern with guards in it, `GatherLocalsVisitor` will visit both the pattern (when type-checking the let, arm, or param containing it) and local declarations in the guard expression (when checking the guard itself). This keeps it from visiting the guard when visiting the pattern, since otherwise it would gather locals from the guard twice, which would lead to a delayed bug: "evaluated expression more than once". Tracking issue for guard patterns: #129967
2025-05-20Rollup merge of #141253 - ↵Matthias Krüger-1/+1
azhogin:azhogin/async-drop-feature-inconsistency-warning, r=oli-obk Warning added when dependency crate has async drop types, and the feature is disabled In continue of https://github.com/rust-lang/rust/pull/141031. When dependency crate has non-empty `adt_async_destructor` table in metadata, and `async_drop` feature is disabled for local crate, warning will be emitted. Test `dependency-dropped` has two revisions - with and without feature enabled. With feature enabled, async drop for dropee is executed ("Async drop" printed). Without the feature enabled, sync drop is executed ("Sync drop" printed) and warning is emitted. Warning example: ``` warning: found async drop types in dependecy `async_drop_dep`, but async_drop feature is disabled for `dependency_dropped` --> $DIR/dependency-dropped.rs:7:1 | LL | #![cfg_attr(with_feature, feature(async_drop))] | ^ | = help: if async drop type will be dropped in a crate without `feature(async_drop)`, sync Drop will be used ```
2025-05-20Rollup merge of #141236 - jagunter:issue-140823, r=compiler-errorsMatthias Krüger-6/+8
Resolved issue with mismatched types triggering ICE in certain scenarios ## Background The function `annotate_mut_binding_to_immutable_binding` called in `emit_coerce_suggestions` performs a type comparison between the `expected` and `found` types from `ExpectedFound` in the `TypeError`. This can fail if the `found` type contains a region variable that's been rolled back. ## What is being changed? This updates `annotate_mut_binding_to_immutable_binding` to use `expr_ty` and `expected` from the parent function instead of the types from the `TypeError`. This sidesteps the issue of using `found` from `TypeError` which may leak lingering inference region variables. This does change the diagnostic behavior to _only_ support cases where the expected outermost type is `&T`, but that seems to be the intended functionality. Also fixed the example in the `annotate_mut_binding_to_immutable_binding` rustdocs. r? rust-lang/types Fixes #140823
2025-05-20Split `autodiff` into `autodiff_forward` and `autodiff_reverse`Marcelo Domínguez-16/+33
Pending fix. ``` error: cannot find a built-in macro with name `autodiff_forward` --> library\core\src\macros\mod.rs:1542:5 | 1542 | / pub macro autodiff_forward($item:item) { 1543 | | /* compiler built-in */ 1544 | | } | |_____^ error: cannot find a built-in macro with name `autodiff_reverse` --> library\core\src\macros\mod.rs:1549:5 | 1549 | / pub macro autodiff_reverse($item:item) { 1550 | | /* compiler built-in */ 1551 | | } | |_____^ error: could not compile `core` (lib) due to 2 previous errors ```
2025-05-20Querify coroutine_hidden_typesMichael Goulet-41/+67
2025-05-20Add tick to RePlaceholder debug outputMichael Goulet-1/+1
2025-05-20Allow trailing comma after argument in query definitionMichael Goulet-0/+1
2025-05-20Revert "Fix stack overflow in exhaustiveness due to recursive HIR opaque ↵Michael Goulet-35/+5
type values" This reverts commit b08e9c2a60f4dbab4bdaa733727947b3395de329.
2025-05-20Just error on recursive opaque ty in HIR typeckMichael Goulet-3/+67
2025-05-19`gather_locals`: only visit guard pattern guards when checking the guarddianne-1/+6
When checking a pattern with guards in it, `GatherLocalsVisitor` will visit both the pattern (when type-checking the let, arm, or param containing it) and the guard expression (when checking the guard itself). This keeps it from visiting the guard when visiting the pattern, since otherwise it would gather locals from the guard twice, which would lead to a delayed bug: "evaluated expression more than once".
2025-05-20Inline and remove `lower_*` methods.Nicholas Nethercote-28/+18
They are all short and have a single call site.
2025-05-20Hoist `ItemLowerer` out of a loop.Nicholas Nethercote-7/+7
2025-05-20Remove unused return value from `lower_node`.Nicholas Nethercote-3/+1
2025-05-20Rollup merge of #141261 - RalfJung:current_dll_path, r=NoratriebStuart Cook-1/+1
current_dll_path: fix mistake in assertion message Follow-up to https://github.com/rust-lang/rust/pull/141239 r? `@Noratrieb`
2025-05-20Remove `MetaItemListParser::all_{word,path}_list`, which are unused.Nicholas Nethercote-14/+0
2025-05-19only resolve top-level guard patterns' guards oncedianne-1/+3
We resolve guard patterns' guards in `resolve_pattern_inner`, so to avoid resolving them multiple times, we must avoid doing so earlier. To accomplish this, `LateResolutionVisitor::visit_pat` contains a case for guard patterns that avoids visiting their guards while walking patterns. This fixes an ICE due to `visit::walk_pat` being used instead, which meant guards at the top level of a pattern would be visited twice.
2025-05-20Avoid `rustc_span::` qualifiers.Nicholas Nethercote-17/+16
In several files they are entirely unnecessary, with the relevant names already imported. And in a few I have added the necessary `use` item.
2025-05-20Fix up some comments.Nicholas Nethercote-16/+15
Some are too long (> 100 chars), some are too short, some are missing full stops, some are missing upper-case letters at the start of sentences.
2025-05-20Simplify `Accepts`.Nicholas Nethercote-10/+7
There only needs to be one `Fn` per symbol, not multiple.