Refactor is_opsem_inhabited#159625
Conversation
|
|
There was a problem hiding this comment.
Okay yeah that is less confusing than my closure nest. :)
@rustbot author
| @@ -251,107 +248,125 @@ fn inhabited_predicate_type<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> InhabitedP | |||
|
|
|||
| /// Recurse over a type to determine whether it is inhabited on the opsem level. | |||
| /// See `is_opsem_inhabited` above for the spec of what we compute. | |||
There was a problem hiding this comment.
This comment does not really make sense on a type IMO. It should probably go on the ty method, with another brief comment here explaining the point of this type.
There was a problem hiding this comment.
Tweaked the comment. I think the method is self documenting enough after renaming it?
There was a problem hiding this comment.
The type doesn't compute anything though.
I'd suggest renaming to OpsemInhabitedCtx and then having the docs be something like
/// Context for computing whether a type is inhabited on the opsem level.
| } | ||
|
|
||
| #[derive(Default)] | ||
| struct OpsemInhabitedInQuery { |
There was a problem hiding this comment.
What's this type for? Needs a doc comment either here or at the in_query field.
Or you can avoid this type entirely by making stop_at_ref a field of OpsemInhabited (which will also simplify some code a bit) and then just having seen: Option<FxHashSet> in OpsemInhabited.
There was a problem hiding this comment.
Added comments. I wanted the structure to be explicit about in-query vs. not-in-query modalities. OTOH I think the fact that only ty::Adt triggers the query is an implementation detail that could be tweaked. For example ty::Tuple could also trigger the query.
There was a problem hiding this comment.
🤷 I still think this would be simpler with stop_at_ref in the main ctx type and without a second type, and I don't see what this has to do with tuples triggering or not triggering the query, but I don't care strong enough to block the PR over it.
There was a problem hiding this comment.
Yeah I guess I over-engineered it. I flattened it.
|
Reminder, once the PR becomes ready for a review, use |
|
r? me |
1d6f449 to
5d6890f
Compare
5d6890f to
d9d430a
Compare
|
@rustbot ready |
| let seen = self.seen.as_mut().unwrap(); | ||
| // Remove the type again so that we allow it to appear on other branches. | ||
| if new_adt { | ||
| seen.remove(&adt_def.did()); |
There was a problem hiding this comment.
| let seen = self.seen.as_mut().unwrap(); | |
| // Remove the type again so that we allow it to appear on other branches. | |
| if new_adt { | |
| seen.remove(&adt_def.did()); | |
| // Remove the type again so that we allow it to appear on other branches. | |
| if new_adt { | |
| self.seen.as_mut().unwrap().remove(&adt_def.did()); |
Or if you want a let-binding, move it inside the if, since it is only needed there.
d9d430a to
7f2417b
Compare
|
@bors r+ rollup |
…r, r=RalfJung Refactor is_opsem_inhabited Refactor of rust-lang#156977 Introduce a struct to generally simplify the recursion. r? WaffleLapkin cc @RalfJung
…r, r=RalfJung Refactor is_opsem_inhabited Refactor of rust-lang#156977 Introduce a struct to generally simplify the recursion. r? WaffleLapkin cc @RalfJung
…r, r=RalfJung Refactor is_opsem_inhabited Refactor of rust-lang#156977 Introduce a struct to generally simplify the recursion. r? WaffleLapkin cc @RalfJung
Rollup of 12 pull requests Successful merges: - #159582 (Sync from portable simd 2026 07 20) - #158890 (Fix splat v0 mangling) - #159411 ([rustdoc] Correctly handle output options with --show-coverage) - #159647 (Remove `early_exit` closures) - #159656 (define a `Simd` type in `minicore`) - #156474 (Add paths for linked associated items) - #159211 (Fix debuginfo argument when invoking LLBC linker) - #159527 (Bring runtime symbols statics on par with foreign functions) - #159625 (Refactor is_opsem_inhabited) - #159652 (Remove `cfg(not(no_global_oom_handling))` from the `Drop` impl of `UniqueArcUninit`) - #159657 (Remove the blanket `#![cfg_attr(test, allow(unused))]` from bootstrap ) - #159663 (Add layout cycle hang regression test)
…r, r=RalfJung Refactor is_opsem_inhabited Refactor of rust-lang#156977 Introduce a struct to generally simplify the recursion. r? WaffleLapkin cc @RalfJung
Rollup of 13 pull requests Successful merges: - #159582 (Sync from portable simd 2026 07 20) - #158890 (Fix splat v0 mangling) - #159614 (debuginfo generation for unsafe binders) - #159647 (Remove `early_exit` closures) - #159656 (define a `Simd` type in `minicore`) - #156474 (Add paths for linked associated items) - #159211 (Fix debuginfo argument when invoking LLBC linker) - #159527 (Bring runtime symbols statics on par with foreign functions) - #159625 (Refactor is_opsem_inhabited) - #159629 (Add more splat rust-call regression tests) - #159652 (Remove `cfg(not(no_global_oom_handling))` from the `Drop` impl of `UniqueArcUninit`) - #159657 (Remove the blanket `#![cfg_attr(test, allow(unused))]` from bootstrap ) - #159663 (Add layout cycle hang regression test)
Rollup of 13 pull requests Successful merges: - #159582 (Sync from portable simd 2026 07 20) - #158890 (Fix splat v0 mangling) - #159614 (debuginfo generation for unsafe binders) - #159647 (Remove `early_exit` closures) - #159656 (define a `Simd` type in `minicore`) - #156474 (Add paths for linked associated items) - #159211 (Fix debuginfo argument when invoking LLBC linker) - #159527 (Bring runtime symbols statics on par with foreign functions) - #159625 (Refactor is_opsem_inhabited) - #159629 (Add more splat rust-call regression tests) - #159652 (Remove `cfg(not(no_global_oom_handling))` from the `Drop` impl of `UniqueArcUninit`) - #159657 (Remove the blanket `#![cfg_attr(test, allow(unused))]` from bootstrap ) - #159663 (Add layout cycle hang regression test)
View all comments
Refactor of #156977
Introduce a struct to generally simplify the recursion.
r? WaffleLapkin
cc @RalfJung