-
Notifications
You must be signed in to change notification settings - Fork 13.9k
hir_analysis: add missing sizedness bounds #142712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hir_analysis: add missing sizedness bounds #142712
Conversation
|
rustbot has assigned @petrochenkov. Use |
|
HIR ty lowering was modified cc @fmease |
This comment has been minimized.
This comment has been minimized.
|
Wasn't expecting that failure, looking into it. |
|
A smaller example of one of the failing crates (which happens with a stage two build): #![crate_type = "lib"]
use std::marker::PhantomData;
pub trait ZeroMapKV<'a> {
type Container;
}
pub trait ZeroFrom<'zf, C: ?Sized> {}
pub struct ZeroMap<'a, K: ZeroMapKV<'a>>(PhantomData<&'a K>);
impl<'zf, 's, K> ZeroFrom<'zf, ZeroMap<'s, K>> for ZeroMap<'zf, K>
where
K: for<'b> ZeroMapKV<'b>,
<K as ZeroMapKV<'zf>>::Container: ZeroFrom<'zf, <K as ZeroMapKV<'s>>::Container>,
{
} |
|
r? types |
|
I'd like to think about this... Can you remind me, is |
Yes, it is |
|
I think this highlights a problematic interaction with trait aliases, and I'm tempted to say that trait aliases should have their behavior reworked to stop expanding into their bounds in FOr now, I think it's inconsistent to not add |
60d5044 to
7684842
Compare
Changed to this, thanks. Still hitting the stage two failure, though I've added a UI test with my reproduction so that will fail first, not had much progress on working out what's going wrong with it. |
This comment has been minimized.
This comment has been minimized.
7684842 to
eac7da1
Compare
|
See discussion on Zulip (#t-types > relaxing associated type bounds @ 💬) for background behind the last commit's changes. |
|
@bors try |
…nds, r=<try> hir_analysis: add missing sizedness bounds Default sizedness bounds were not being added to `explicit_super_predicates_of` and `explicit_implied_predicates_of` which meant that a trait bound added to a associated type projection would be missing the implied predicate of the default sizedness supertrait of that trait. An unexpected consequence of this change was that the check for multiple principals was now finding an additional `MetaSized` principal when eagerly expanding trait aliases - this required modifying lowering to no longer add default bounds to trait aliases.
|
☀️ Try build successful - checks-actions |
|
@craterbot check |
fde350a to
3901931
Compare
…, r=lcnr prefer alias candidates for sizedness + auto trait goals Fixes rust-lang/rust#143992 - abd07dec44437554520453f929c2b12d4eb8b11e: Reverts rust-lang/rust#144016 so that `MetaSized` bounds are checked properly, and updates all the tests accordingly, including making `tests/ui/sized-hierarchy/incomplete-inference-issue-143992.rs` fail when it shouldn't - 90e61db9745f53d9aef21e3ebce0df19cc1389d7: Prefer alias candidates over parameter environment candidates for sizedness, auto and default traits. `tests/ui/sized-hierarchy/incomplete-inference-issue-143992.rs` passes again, but `tests/ui/generic-associated-types/issue-93262.rs` starts failing when it shouldn't - e412062171925d0b40fdbeb5765c45087bdf0fe7: No longer require that predicates of aliases hold in well-formedness checking of the alias. `tests/ui/generic-associated-types/issue-93262.rs` passes again Each commit updates all the tests to their new output so it should be easy enough to see what the impact of each change individually is. After all of the changes, tests that pass when they didn't before or vice versa: - `tests/ui/extern/extern-types-size_of_val.rs` - Previously passing, but only because of rust-lang/rust#144016, now correctly errors - `tests/ui/sized-hierarchy/incomplete-inference-issue-143992.rs` - Previously failing on next solver, only because rust-lang/rust#144016 only applied to the old solver, passing now with 90e61db9745f53d9aef21e3ebce0df19cc1389d7 - `tests/ui/sized-hierarchy/overflow.rs` - Previously passing, but only because of rust-lang/rust#144016, now correctly errors - `tests/ui/generic-associated-types/issue-92096.rs` - Previously passing, due to e412062171925d0b40fdbeb5765c45087bdf0fe7 - Fails to prove `C::Connecting<'placeholder>: Send` which is required when proving that the generator is `Send`. This is an instance of rust-lang/rust#110338. - `tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution-opaque-type.rs` - Previously passing, now failing in the next solver, due to 03e0fdab6196e81b44356f42f03b6a0a224cf451 - Expected that this test now fails as ambigious, see [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/144729-t-types/topic/sizedness.20bounds.20in.20explicit_implied_predicates_of.20.28.23142712.29/near/526987384) This had a crater run in rust-lang/rust#142712 (comment) alongside some other changes. r? `@lcnr` cc rust-lang/rust#142712 (this extracts part of that change)
This comment was marked as resolved.
This comment was marked as resolved.
3901931 to
c4cf6ba
Compare
This comment has been minimized.
This comment has been minimized.
c4cf6ba to
4440b69
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final nits, then r=me
Default sizedness bounds were not being added to `explicit_super_predicates_of` and `explicit_implied_predicates_of` which meant that a trait bound added to a associated type projection would be missing the implied predicate of the default sizedness supertrait of that trait. An unexpected consequence of this change was that the check for multiple principals was now finding an additional `MetaSized` principal when eagerly expanding trait aliases. Instead of special-casing trait aliases as different from traits and not adding a `MetaSized` supertrait to trait aliases, filter out `MetaSized` when lowering `dyn Trait`.
4440b69 to
82a4049
Compare
|
This PR was rebased onto a different master 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. |
|
@bors r=lcnr |
|
☀️ Test successful - checks-actions |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 2aaa62b (parent) -> f435972 (this PR) Test differencesShow 10 test diffsStage 1
Stage 2
Additionally, 4 doctest diffs were found. These are ignored, as they are noisy. Job group index
Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard f435972085b697a1ece8ee6a1ac76efff8d1df7b --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (f435972): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowOur benchmarks found a performance regression caused by this PR. Next Steps:
@rustbot label: +perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 0.4%, secondary -0.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.4%, secondary 2.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.3%, secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 475.049s -> 474.979s (-0.01%) |
Depends on #144064
Default sizedness bounds were not being added to
explicit_super_predicates_ofandexplicit_implied_predicates_ofwhich meant that a trait bound added to a associated type projection would be missing the implied predicate of the default sizedness supertrait of that trait.An unexpected consequence of this change was that the check for multiple principals was now finding an additional
MetaSizedprincipal when eagerly expanding trait aliases - which is fixed by skippingMetaSizedwhen elaborating trait aliases in loweringdyn TraitAlias.