fix: add CoroutineClosure to diagnostic match arms across compiler#492
Open
SebTardif wants to merge 133 commits into
Open
fix: add CoroutineClosure to diagnostic match arms across compiler#492SebTardif wants to merge 133 commits into
SebTardif wants to merge 133 commits into
Conversation
The current Linux driver treats every sendmsg call as a separate record. That is, it behaves as though MSG_EOR is always set. But that might not be true forever. And the current FreeBSD driver does _not_ do that, so setting MSG_EOR is important for portability.
* Handle generic reborrow in expression-use adjustment walking * Require generic reborrow to be terminal in adjustment walks
Co-authored-by: Alice Ryhl <aliceryhl@google.com>
Co-authored-by: Alice Ryhl <aliceryhl@google.com>
Co-authored-by: Kevin Reid <kpreid@switchb.org>
Co-authored-by: Kevin Reid <kpreid@switchb.org>
LLVM 23 recently changed SimplifyCFG to avoid integer lookup tables, and that perturbed these two tests in ways that look harmless to me.
Co-authored-by: Alice Ryhl <aliceryhl@google.com>
When a `for` loop is missing its `in`, the parser suggested inserting one based only on the token after the pattern. A malformed binding such as `for i i in 0..10` was therefore "corrected" to `for i in i in 0..10`, which does not parse. Only suggest inserting `in` when the loop header does not already contain one before the body.
Document the built-in `must_use` attribute in the standard library using the `#[doc(attribute = "...")]` mechanism, following the existing `keyword_docs.rs` pattern.
When passing multiple `-Zsanitizer` flags to the compiler (e.g., `-Zsanitizer=address -Zsanitizer=shadow-call-stack`), the options parser was overwriting the previous values in `target_modifiers` instead of accumulating them. This resulted in only the last sanitizer being recorded in the crate metadata's target modifiers, even though the frontend correctly enabled all of them. The only way to provide multiple sanitizers was to combine them into a comma-separated list passed to a single `-Zsanitizer=` flag, but this does not fit well into the GN build system where different targets may pass different combinations of sanitizer flags. Consequently, this caused spurious "incompatible target modifiers" ABI mismatch errors when linking against dependencies compiled with accumulated flags (e.g., `-Zsanitizer=address,shadow-call-stack`). Fix this by entry-modifying the `target_modifiers` map to accumulate the sanitizers as a comma-separated list when the option is `sanitizer`. Also add a codegen test verifying that both CFI and SafeStack attributes/metadata are present when enabled together via multiple flags. Test: ./x.py test tests/codegen-llvm/sanitizer/multiple-sanitizers.rs
To get a `LintVec` for a lint pass we sometimes use `get_lints` and sometimes use `lint_vec`. It would be nice to only have one, but doing that is tricky. In the meantime, this commit makes the naming more consistent. - By always using the name `get_lints` for the methods that take `self`. - By always using the name `lint_vec` for the methods that have no parameters.
These are both types that impl `LintPass` but in a degenerate way: only the `lint_vec` method is ever used. This commit changes them to just be a `lint_vec` function in an appropriately-named module. The commit also removes the use of `HardwiredLints` in `late_lint_crate`, which had no effect because all the `HardwiredLints::check_*` methods were no-ops.
…unwrap, r=petrochenkov,oli-obk Replace `unwrap` with `expect` in `get_module_children` # Objective I ran into an ICE I ran into while developing rust-lang/rust-clippy#17252 that stems from `rustc_metadata::rmeta::decoder::CrateMetadata::get_module_children` calling `unwrap`. The local value `non_reexports` can be `None` when the passed in `DefIndex` is for a non-module-like item. The documentation for `get_module_children` *implies* that it must only be called with module-like item indices, however the use of `unwrap` makes diagnosing the ICE trickier than it has to be. Additionally, this behaviour is not documented on `TyCtxt::module_children`. ## Solution - Switched from an `Option::unwrap` to a `Option::expect` - Added panic documentation to `get_module_children` - Replicated documentation for `TyCtxt::module_children` --- ## Notes * No AI tooling of any kind was used during the creation of this PR. * Please see [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/122651-general/topic/.E2.9C.94.20.60rustc.60.20ICE.20from.20.60TyCtxt.3A.3Amodule_children.60/with/603700184) for some discussion. * Please see this [failed Clippy CI run](https://github.com/rust-lang/rust-clippy/actions/runs/27596428127/job/81587609898#step:5:1) for an example of the ICE caused.
…ee1-dead Reject `impl const Trait` since the right syntax is `const impl Trait` now I also let some smaller rustfmting of ui tests through, as rustfmt immediately formats `impl const Trait` to `const impl Trait`. This is also the reason I expect that this change will break very little nightly users, so we don't even need to add some helpful diagnostic. r? @fee1-dead
…orrow-source-unsafety, r=dingxiangfei2009 Fix reborrow source expression visits Fixes rust-lang#158033
Bump thin-vec to 0.2.18 to address RUSTSEC-2026-0103 thin-vec versions before 0.2.16 have a use-after-free / double-free in `IntoIter::drop` and `ThinVec::clear` when an element's `Drop` panics ([RUSTSEC-2026-0103](https://rustsec.org/advisories/RUSTSEC-2026-0103)). This bumps the requirement in the compiler crates from `0.2.15` to `0.2.18` and updates `Cargo.lock` accordingly, moving past the affected range.
…rrors, r=Darksonn Document transient connection errors from TcpListener::accept `TcpListener::accept` can return an error that belongs to a single incoming connection, not to the listener, for example a connection aborted by the peer before it could be accepted (`ConnectionAborted`). The listener stays usable, so a server looping over connections usually wants to log the error and keep accepting rather than treat it as fatal. This was not documented, and the `incoming` example treated every error as a failed connection. This implements the libs-team decision in rust-lang#142557: document these transient errors instead of changing `accept` to retry them, since retrying would hide errors that some callers want to observe. Changes: - Add an `# Errors` section to `accept` describing this behavior, without listing specific error codes since some may be more permanent than others. - Note that `Interrupted` errors are retried internally on Unix. - Add the same pointer to `incoming` and `into_incoming`, which are `accept` in a loop. Addresses rust-lang#142557. r? rust-lang/libs
…llaumeGomez rustdoc-json-types: Replace bincode dev-dependency with postcard bincode is flagged as unmaintained by [RUSTSEC-2025-0141](https://rustsec.org/advisories/RUSTSEC-2025-0141), and the advisory covers the entire crate with no patched version available. The only use in `rustdoc-json-types` was the binary serde roundtrip in the type tests. [postcard](https://crates.io/crates/postcard) is a maintained serde-based binary serialization format that covers the same roundtrip testing need. bincode is still pulled in transitively by the miri subtree (via `ipc-channel`), which needs to be [addressed upstream](rust-lang/miri#5115). ### Related - rust-lang/miri#5115
renovate: Loosen dashboard approval and adopt recommended config Follow-up tweaks to the Renovate config now that the GitHub Actions setup has proven stable. - GitHub Actions updates no longer need Dependency Dashboard approval. The gate was added while we dialed in the config, and the `github-actions` manager now works well enough for those PRs to open on their own. Everything else still requires approval. - Monthly lock file maintenance is now enabled. It stays behind dashboard approval for the time being. - The config extends [`config:recommended`](https://docs.renovatebot.com/presets-config/#configrecommended), which brings changelog links, sensible grouping, `replacements` and `workarounds`. That makes the previously explicit `dependencyDashboard: true` redundant, so it's gone. - Config migration PRs are enabled so Renovate can keep the config up to date as options get deprecated.
…o-no-opt, r=lqd codegen_ssa: no dbginfo for scalable vec local w/ `-O0` LLVM uses GlobalISel with `-O0` that doesn't support scalable vectors. It normally falls back to SDAG which does support scalable vectors, but there's a bug that means that isn't happening for debuginfo - so temporarily don't emit debuginfo for scalable vector locals when there are no optimisations until that bug is fixed. cc llvm/llvm-project#204585 cc rust-lang/stdarch#2160 r? @lqd
… r=Urgau Fix invalid "jump-to-def" doc link generation when an item has a `derive` proc-macro Fixes rust-lang#158050. The problem is that the proc-macros might generate an impl block `impl $(trait)? for Item` where `Item` then has its span pointing to the current item, overwriting its intra-doc link (hopefully this explanation makes sense ^^'). In short, the proc-macro generates an impl block, the `for Item` makes the code enter `visit_qpath` which in turn calls `handle_path` which will take the span of the last segment of the path (so `Item` here) and use it in the link def "span map". r? @Urgau
…llaumeGomez Rollup of 12 pull requests Successful merges: - rust-lang#156795 (Handle generic reborrow in expression-use adjustment walking) - rust-lang#157694 (Enhance documentation on wake call memory ordering) - rust-lang#157935 (Make `proc_macro::ConversionErrorKind` non exhaustive) - rust-lang#158002 (Replace `unwrap` with `expect` in `get_module_children`) - rust-lang#158009 (Reject `impl const Trait` since the right syntax is `const impl Trait` now) - rust-lang#158034 (Fix reborrow source expression visits) - rust-lang#158072 (Bump thin-vec to 0.2.18 to address RUSTSEC-2026-0103) - rust-lang#158074 (Document transient connection errors from TcpListener::accept) - rust-lang#158077 (rustdoc-json-types: Replace bincode dev-dependency with postcard) - rust-lang#158086 (renovate: Loosen dashboard approval and adopt recommended config) - rust-lang#158088 (codegen_ssa: no dbginfo for scalable vec local w/ `-O0`) - rust-lang#158089 (Fix invalid "jump-to-def" doc link generation when an item has a `derive` proc-macro)
There's no need to jump through all the hoops of `set` when we are creating a new `OnceLock` from scratch.
…no-range-check, r=petrochenkov `RegionValues`: disable unnecessary range check Currently, when adding liveness points to region values in the `RegionValues` struct, the locations of the points are checked for ranges. This is unnecessarily cautious because they always are in range by construction. The docstring for the method used in the checks suggests that it was designed for underlying bit sets that currently aren't used for this. This adds documentation (including debug assertions) to make this clearer and removes the checks, which should have a strictly positive impact on performance.
Initialize directly in `From<T> for OnceLock<T>` There's no need to jump through all the hoops of `set` when we are creating a new `OnceLock` from scratch.
It only has two impls, both of which are tuples, which is ugly. An enum is much simpler and clearer. Also, `EarlyContextAndPass` doesn't need to be public.
Rollup of 2 pull requests Successful merges: - rust-lang#158026 (`RegionValues`: disable unnecessary range check) - rust-lang#158101 (Initialize directly in `From<T> for OnceLock<T>`)
Add `#[rustc_dump_generics]` attribute Added a rustc attribute to dump the generic parameters of a given item to the compiler output.
This means you can now use remote-test-client/remote-test-server with targets that contain a '.' in the name. See rust-lang#158090
…=jhpratt `impl [const] Default for BTreeMap` Tracking issue: rust-lang#143894.
Codegen ctors in Runtime mir phase https://github.com/rust-lang/rust/pull/156141/changes#diff-f18405dedc545b19aa3ee04cd08b17e1e0fa1b5876e46c6b445eaaa7e54618eaR421 (part of rust-lang#156141) The mir of constructors used to be generated in MirPhase::Built, but are only used during codegen. That means they'd have a weird MirPhase, since all other items have MirPhase::Runtime during codegen. This PR still generates ctor mir in MirPhase::Built, but then immediately does a phase change to Runtime after running no passes. Fixes rust-lang#158037 <summary> Old description of another, worse way to solve this <details> starts using `TypingMode::PostTypeckUntilBorrowck` during mir building with the next solver. This is the right typing mode, and the typing mode contains a list of opaque types. However, previously, we instead just used `TypingMode::Typeck` with an empty list of opaques. That is the wrong typing mode, but it also meant we collected opaque types of slightly fewer things. Now that we do collect their opaque types, we're doing so for items that we've never gathered opaque types for before and get an ICE. There are no tests associated with this change. @lqd tried to reproduce it, but it seems surprisingly hard except by bootstrapping rustc itself. This change makes `RUSTFLAGS_NOT_BOOTSTRAP=-Znext-solver x build compiler --stage 2` work, which I verified locally. See [#t-infra/announcements > Next solver / polonius alpha pre-stabilization CI job](https://rust-lang.zulipchat.com/#narrow/channel/533458-t-infra.2Fannouncements/topic/Next.20solver.20.2F.20polonius.20alpha.20pre-stabilization.20CI.20job/with/602503884) for work towards making bootstraps with the next solver a CI job. </details> </summary> r? @oli-obk
…ss35 Stabilize `substr_range` and `subslice_range` Closes rust-lang#126769 [Stabilization Report](rust-lang#126769 (comment))
…o-enum, r=Urgau Change `EarlyCheckNode` from a trait to an enum. It only has two impls, both of which are tuples, which is ugly. An enum is much simpler and clearer. Also, `EarlyContextAndPass` doesn't need to be public. r? @Urgau
…, r=Kobzol Convert '.' to '_' in bootstrap envify This means you can now use remote-test-client/remote-test-server with targets that contain a '.' in the name. See rust-lang#158090 r? @Kobzol
…nathanBrouwer Rollup of 5 pull requests Successful merges: - rust-lang#157878 (`impl [const] Default for BTreeMap`) - rust-lang#158040 (Codegen ctors in Runtime mir phase) - rust-lang#141266 (Stabilize `substr_range` and `subslice_range`) - rust-lang#158109 (Change `EarlyCheckNode` from a trait to an enum.) - rust-lang#158118 (Convert '.' to '_' in bootstrap envify)
Add CoroutineClosure handling to 6 diagnostic code paths so async closures get the same quality error messages as regular closures: - explain_borrow: show 'closure' instead of raw type for destructors - region_errors: recognize async FnMut closures in is_closure_fn_mut - hir_ty_lowering/errors: point at async closure span for bound failures - fn_ctxt/checks: show 'callable defined here' and match call sites - method/suggest: point at async closure for method bound failures - infer/mod: classify CoroutineClosure as Closure in TyCategory Fixes #490 Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #490
Adds
ty::CoroutineClosurehandling to 6 diagnostic code paths so async closures get the same quality error messages as regular closures:FnMutclosures inis_closure_fn_mutCoroutineClosureasClosureinTyCategoryTwo sites in
infer/mod.rs(lines 1782, 1849) are not included because they require different signature extraction forCoroutineClosurevsClosure. The dangling lint indangling.rsis also excluded for the same reason. These remain tracked in #490.