Eagerly normalize in generalize#151746
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
… r=<try> Eagerly normalize in generalize
This comment has been minimized.
This comment has been minimized.
|
💔 Test for 92bb985 failed: CI. Failed job:
|
fun, we've got some jank in serde which we don't have in our ui test suite |
5bd20bb to
d0cdaae
Compare
This comment has been minimized.
This comment has been minimized.
d0cdaae to
fb5d5cf
Compare
This comment has been minimized.
This comment has been minimized.
fb5d5cf to
d96cab0
Compare
This comment has been minimized.
This comment has been minimized.
d96cab0 to
5611a89
Compare
|
changes to the core type system cc @lcnr |
|
@lcnr I think this fixes all issues we had. Only one test really regressed, some got a bunch better. Fixed the span on the one test we discussed. |
5611a89 to
3f90d08
Compare
This comment has been minimized.
This comment has been minimized.
|
@GuillaumeGomez is this another flaky test? |
29ae136 to
1adea68
Compare
|
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. |
| span: Span, | ||
| alias: ty::AliasTy<'tcx>, | ||
| ) -> Ty<'tcx> { | ||
| let infcx = unsafe { |
There was a problem hiding this comment.
do you want to encapsulate these transmute in inhernet functions on InferCtxt and add a safety comment there?
| @@ -12,7 +13,6 @@ impl Trait for u32 {} | |||
| fn hello() -> Box<impl Trait> { | |||
| if true { | |||
| let x = hello(); | |||
| //[next]~^ ERROR: the size for values of type `dyn Trait` cannot be known at compilation time | |||
| let y: Box<dyn Trait> = x; | |||
| } | |||
There was a problem hiding this comment.
hmm, I don't fully get that 🤔
What does "implicitly contains the + Sized bound" mean? For coerce to consider that Sized bound, it has to be in the root fulfillment context I think?
How does that Sized bound get there. I am also surprised that x has to be equal to the return type of hello() instead of a subtype, how does that happen? ✨
1adea68 to
60e068f
Compare
| /// Treat aliases as potentially normalizable. | ||
| /// | ||
| /// This is the default state that generalization starts in, unless we're treating aliases as rigid. | ||
| /// It also means we're not currently inside an alias, since then we change the state to | ||
| /// `IncompletelyRelateAliasArgs` | ||
| Default, | ||
| /// We enter this state when we're generalizing the arguments of a potentially normalizeable alias. | ||
| /// | ||
| /// The behavior here is different between the old and the new solver: | ||
| /// | ||
| /// In the old solver, the difference between this and `Default` is needed to | ||
| /// correctly handle `<T as Bar<<?0 as Foo>::Assoc>::Assoc == ?0`. | ||
| /// That equality can hold by either normalizing the outer or the inner associated type. | ||
| /// In the old solver, we always structurally relate aliases, | ||
| /// however, when we encounter an occurs check failure, we propagate the failure to the outermost alias, | ||
| /// for which we then emit a Projection goal. | ||
| /// | ||
| /// In the new solver, we rarely get into this state. | ||
| /// When we encounter aliases we instead attempt to normalize them, and treat them as rigid using `ShallowStructurallyRelate`. | ||
| /// Only when an alias is higher-ranked, we continue with similar logic to the old solver, | ||
| /// except now we also explicitly relate the type and consts in the arguments of aliases while in this mode. | ||
| /// | ||
| /// FIXME: Because we relate the type and consts in the arguments of aliases while in this mode, | ||
| /// this is "incomplete". | ||
| IncompletelyRelateAliasArgs, | ||
| /// During generalization, when we encounter aliases, | ||
| /// we will first attempt to normalize them when we're using the next trait solver. | ||
| /// We can now treat the normalized alias as rigid, but only for "one layer", hence shallow. | ||
| /// New aliases encountered inside the arguments of the outer alias should once again be related as normal. | ||
| ShallowStructurallyRelateAliases, | ||
| /// Treat aliases as rigid when relating them. | ||
| /// | ||
| /// This corresponds to `relation.structurally_relate_aliases()`. | ||
| StructurallyRelateAliases, |
There was a problem hiding this comment.
| /// Treat aliases as potentially normalizable. | |
| /// | |
| /// This is the default state that generalization starts in, unless we're treating aliases as rigid. | |
| /// It also means we're not currently inside an alias, since then we change the state to | |
| /// `IncompletelyRelateAliasArgs` | |
| Default, | |
| /// We enter this state when we're generalizing the arguments of a potentially normalizeable alias. | |
| /// | |
| /// The behavior here is different between the old and the new solver: | |
| /// | |
| /// In the old solver, the difference between this and `Default` is needed to | |
| /// correctly handle `<T as Bar<<?0 as Foo>::Assoc>::Assoc == ?0`. | |
| /// That equality can hold by either normalizing the outer or the inner associated type. | |
| /// In the old solver, we always structurally relate aliases, | |
| /// however, when we encounter an occurs check failure, we propagate the failure to the outermost alias, | |
| /// for which we then emit a Projection goal. | |
| /// | |
| /// In the new solver, we rarely get into this state. | |
| /// When we encounter aliases we instead attempt to normalize them, and treat them as rigid using `ShallowStructurallyRelate`. | |
| /// Only when an alias is higher-ranked, we continue with similar logic to the old solver, | |
| /// except now we also explicitly relate the type and consts in the arguments of aliases while in this mode. | |
| /// | |
| /// FIXME: Because we relate the type and consts in the arguments of aliases while in this mode, | |
| /// this is "incomplete". | |
| IncompletelyRelateAliasArgs, | |
| /// During generalization, when we encounter aliases, | |
| /// we will first attempt to normalize them when we're using the next trait solver. | |
| /// We can now treat the normalized alias as rigid, but only for "one layer", hence shallow. | |
| /// New aliases encountered inside the arguments of the outer alias should once again be related as normal. | |
| ShallowStructurallyRelateAliases, | |
| /// Treat aliases as rigid when relating them. | |
| /// | |
| /// This corresponds to `relation.structurally_relate_aliases()`. | |
| StructurallyRelateAliases, | |
| /// Treat aliases as potentially normalizable. | |
| /// | |
| /// This is the default state that generalization starts in, unless we're | |
| /// treating aliases as rigid. It also means we're not currently inside an | |
| /// alias, since then we change the state to `IncompletelyRelateAliasArgs`. | |
| Default, | |
| /// We enter this state when we're generalizing the arguments of a | |
| /// potentially normalizeable alias. | |
| /// | |
| /// The behavior here is different between the old and the new solver: | |
| /// | |
| /// In the old solver, the difference between this and `Default` is needed to | |
| /// correctly handle `<T as Bar<<?0 as Foo>::Assoc>::Assoc == ?0`. That | |
| /// equality can hold by either normalizing the outer or the inner | |
| /// associated type. In the old solver, we always structurally relate | |
| /// aliases. If we we encounter an occurs check failure, we propagate the | |
| /// failure to the outermost alias, for which we then emit a `Projection` | |
| /// goal instead. | |
| /// | |
| /// In the new solver, we rarely get into this state. | |
| /// When we encounter aliases we instead attempt to normalize them, and treat | |
| /// them as rigid using `ShallowStructurallyRelate`. Only when an alias has | |
| /// escaping bound variables do we continue with similar logic to the old | |
| /// solver, except now we also explicitly relate the type and consts in the | |
| /// arguments of aliases while in this mode. | |
| /// | |
| /// FIXME: Because we relate the type and consts in the arguments of aliases | |
| /// while in this mode, this is incomplete. | |
| IncompletelyRelateAliasArgs, | |
| /// During generalization, when we encounter aliases, we will first attempt | |
| /// to normalize them when we're using the next trait solver. We can now | |
| /// treat the normalized alias as rigid, but only for "one layer", hence | |
| /// shallow. New aliases encountered inside the arguments of the outer alias | |
| /// should once again be related as normal. | |
| ShallowStructurallyRelateAliases, | |
| /// Treat aliases as rigid when relating them. | |
| /// | |
| /// This corresponds to `relation.structurally_relate_aliases()`. | |
| StructurallyRelateAliases, |
60e068f to
d665c0b
Compare
|
@bors r=lcnr |
This comment has been minimized.
This comment has been minimized.
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 bfc05d6 (parent) -> ac7f9ec (this PR) Test differencesShow 8 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 ac7f9ec7da74d37fd28667c86bf117a39ba5b02a --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 (ac7f9ec): 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.7%, secondary -0.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary -1.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 485.797s -> 485.09s (-0.15%) |
View all comments
r? @lcnr
cc: rust-lang/trait-system-refactor-initiative#262