Repository navigation
Conversation
|
Some changes occurred in match checking cc @Nadrieril Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
Thanks for the pull request, and welcome! The Rust Project has assigned @folkertdev (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks. Please see the contribution instructions and our LLM policy for more information. Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Signed-off-by: kimhappy <[email protected]>
Signed-off-by: kimhappy <[email protected]>
Signed-off-by: kimhappy <[email protected]>
Signed-off-by: kimhappy <[email protected]>
Signed-off-by: kimhappy <[email protected]>
Signed-off-by: kimhappy <[email protected]>
Signed-off-by: kimhappy <[email protected]>
Signed-off-by: kimhappy <[email protected]>
Signed-off-by: kimhappy <[email protected]>
Signed-off-by: kimhappy <[email protected]>
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Signed-off-by: kimhappy <[email protected]>
|
☔ The latest upstream changes (presumably #166674) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
Some feature checks only look at the current crate's features, even when the item comes from a dependency. This causes ICEs, spurious errors, and one unsound acceptance.
This PR records each crate's enabled language features in its metadata. The checks now also look at the crate that defines the item.
Background
While investigating #166244, I found that a downstream crate ignores an upstream crate's
gca_const_items. I then looked for similar cases and fixed each one.Problems
Each case has a regression test.
gca_const_itemsSend, ...) on upstreamgca!types are ambiguous (Next solver: auto-trait goal is ambiguous for an upstream type using gca!, unless the downstream crate enables gca_const_items #166244).gca!value in an expression ICEs withdoes not have a "mir_for_ctfe"([ICE]: DefId(20:3 ~ up[3832]::N) does not have a "mir_for_ctfe" #166409).gca!value.-Znext-solver=globally.generic_const_exprswhereclauses like[(); N + 1]:fail with E0275 overflow (generic_const_exprs well formed requirement break on crate bondary #145069).ConstEquate without a feature gateassertion.coroutine_clone: Callingclone()on an upstreamimpl Coroutine + CloneICEs, because no builtinClonecandidate is assembled.move_trait(next solver): The fast path treats an upstreamimpl !Movetype asMove, so it wrongly satisfiesT: Move.ergonomic_clones: When an upstream generic function using.useis monomorphized or inlined downstream, it callsClone::cloneinstead of copyingCopytypes.with_negative_coherence: Implementing an upstream#[rustc_strict_coherence]trait errors with"strict coherence needs negative coherence".Solution
A check now uses the features enabled in the current crate or in the crate that defines the item. Downstream crates that enable a feature and use upstream items work as before.
Enabled features are recorded the same way as
specialization_enabled_in(CrateNum):CrateRoot::enabled_lang_features: Stores the language features a crate enables.enabled_lang_features_in(CrateNum) -> &FxIndexSet<Symbol>: Queries to read them.TyCtxt::lang_feature_enabled_in(CrateNum, Symbol): Checks whether one crate enables a feature.TyCtxt::features_for(DefId) -> ItemFeatures: Features enabled in the current crate or in the crate definingdef_id.Interner::features_forandinherent::ItemFeatures: The same for code using the interner, like the next solver.Exceptions:
generic_const_exprs: A goal can mix consts from several crates, soty::gce_applies_tochecks whether a value mentions a const from a crate with the feature.move_trait: ADTs use their own crate's features. Tuples, arrays, slices and pattern types never take the fast path, so their components are checked instead.ergonomic_clones:.useCalls are optimized whenever the MIR has one, regardless of crate features.with_negative_coherence: Only#[rustc_strict_coherence]uses the trait's crate.OverlapMode::WithNegativestill uses only the current crate, socoreenabling the feature doesn't change coherence everywhere (tests/ui/coherence/negative-coherence-foreign-trait.rs).Fixes #166244
Fixes #145069
Fixes #166409