Skip to content

use ProjectionPredicate instead of AliasRelate#158606

Open
khyperia wants to merge 6 commits into
rust-lang:mainfrom
khyperia:yeet-aliasrelate
Open

use ProjectionPredicate instead of AliasRelate#158606
khyperia wants to merge 6 commits into
rust-lang:mainfrom
khyperia:yeet-aliasrelate

Conversation

@khyperia

@khyperia khyperia commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

View all comments

part of #155345

this PR is split into three commits:

  • refactoring super_combine_{tys,consts}, should not change behavior at all, just reorganizing code
  • convert to use ProjectionPredicate instead of AliasRelate in super_combine_tys and generalization (this is the important change for this PR)
  • deleting the now-dead AliasRelate predicate

r? @lcnr

@rustbot

rustbot commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

changes to inspect_obligations.rs

cc @lcnr

changes to the core type system

cc @lcnr

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a, @makai410

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jun 30, 2026
fn test<T: Foo1<Assoc1 = <T as Foo2>::Assoc2> + Foo2<Assoc2 = <T as Foo1>::Assoc1>>() {
needs_bar::<T::Assoc1>();
//~^ ERROR: the trait bound `<T as Foo2>::Assoc2: Bar` is not satisfied
//~| ERROR: the size for values of type `<T as Foo2>::Assoc2` cannot be known at compilation time

@khyperia khyperia Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure about this one, to be honest. It makes sense why it can't prove Sized, it's divergent, but I don't know why printing a failure to prove sized was suppressed before, why recursive-self-normalization.rs does still not print this (which is direct recursion rather than a 2-cycle), or if the fact this is printing an error now is indicative of an underlying issue.

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error might be related #155388? I personally wouldn't worry too much about emitting a new error here. Our error reporting logic is quite brittle with changes like this

@rust-log-analyzer

This comment has been minimized.

}
coercion.obligations.extend(ocx.into_pending_obligations());
continue;
}

@lcnr lcnr Jun 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fun, this was dead code before 😁

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha yeah, saw this when I was deleting it and I was like "uuuh wait, why... AliasRelate in the old solver?? huh??" :P

| ty::PredicateKind::NormalizesTo(_) => VisibleForLeakCheck::No,
ty::PredicateKind::AliasRelate(_, _, _) => VisibleForLeakCheck::Yes,
};
let vis = VisibleForLeakCheck::No;

@lcnr lcnr Jun 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can inline that further 😁

View changes since the review

Comment thread compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs
@rust-log-analyzer

This comment has been minimized.

@BoxyUwU BoxyUwU self-assigned this Jun 30, 2026
Comment on lines +118 to +120
/// However, in case the just-normalized `term` contains further aliases, we
/// emit nested `ProjectionPredicate` goals to normalize it further, which
/// are eagerly evaluated and may fail.

@lcnr lcnr Jul 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so i think the reason we get errors here is that term has not been just-normalized.

Because any alias we try to normalize when adding goals we should also have tried to normalize earlier. I would expect that by adding a normalize call to places where we currently don't normalize explicitly before calling this fn we'd stop panicking here.

However, I don't necessary want to expect that stuff is already normalized in this function, so not ICEing if the equate fails is still fine🤔

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right yeah, like, it's been "partially" normalized? e.g. <SomeStruct as std::ptr::Pointee>::Metadata --> <TailOfThatStruct as std::ptr::Pointee>::Metadata is a partial step in the progress of the entire expression being normalized (it's been "just-normalized" in that sense), but, TailOfThatStruct here has not been further normalized

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we normalized the original alias, but fetching an assoc type from an impl/or a struct field gives you a separate unnormalized type

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, pushed a rephrasing! I thiiink I've addressed all feedback now.

@khyperia khyperia force-pushed the yeet-aliasrelate branch from 47e4f26 to 551a033 Compare July 1, 2026 09:09
@rust-log-analyzer

This comment has been minimized.

@khyperia khyperia force-pushed the yeet-aliasrelate branch 2 times, most recently from 203f3b2 to 9b818d1 Compare July 2, 2026 05:10
@lcnr

lcnr commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

small feedback wrt to tests, I'd prefer to go

//@ flags n stuff

// comments

source

in UI tests because that makes it easier for me to notice flags where putting them in the middle always takes me a second to figure out

after that r=me

@bors delegate+

@rust-bors

rust-bors Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

✌️ @khyperia, you can now approve this pull request!

If @lcnr told you to "r=me" after making some further change, then please make that change and post @bors r=lcnr.

View changes since this delegation.

@khyperia khyperia force-pushed the yeet-aliasrelate branch from 9b818d1 to c77583e Compare July 2, 2026 10:32
@khyperia

khyperia commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@bors r=lcnr

@rust-bors

rust-bors Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

📌 Commit c77583e has been approved by lcnr

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 1000. This pull request will be tested once the tree is reopened.

@rust-bors rust-bors Bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jul 2, 2026
@rust-bors rust-bors Bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 2, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 2, 2026
use ProjectionPredicate instead of AliasRelate

part of rust-lang#155345

this PR is split into three commits:

- refactoring `super_combine_{tys,consts}`, should not change behavior at all, just reorganizing code
- convert to use ProjectionPredicate instead of AliasRelate in super_combine_tys and generalization (this is the important change for this PR)
- deleting the now-dead AliasRelate predicate

r? @lcnr
rust-bors Bot pushed a commit that referenced this pull request Jul 3, 2026
…uwer

Rollup of 22 pull requests

Successful merges:

 - #155429 (Support `u128`/`i128` c-variadic arguments)
 - #158100 (Emit retags in codegen to support BorrowSanitizer (part 4))
 - #158494 (Improve E0277 diagnostics for conditionally implemented traits)
 - #158606 (use ProjectionPredicate instead of AliasRelate)
 - #158627 (Simplify option-iterator flattening in the compiler)
 - #158658 (Update LLVM submodule)
 - #158665 (Revert "Remove redundant dyn-compatibility check.")
 - #158021 (Remove old MinGW workaround)
 - #158473 (Add `riscv32imfc-unknown-none-elf` bare-metal target)
 - #158549 (process::exec: using appropriate exit code on vxworks.)
 - #158585 (Improve diagnostic for too many super keywords)
 - #158637 (hir_ty_lowering: avoid self type lookup for inherent aliases)
 - #158651 (ptr doc: reduce use of unsafe block to where needed)
 - #158669 (Remove `src/tools/test-float-parse/Cargo.lock`)
 - #158674 (library: Polish transmute's `split_at_stdlib` example)
 - #158677 (Add extra splat tests)
 - #158680 (Avoid ICE for `NonZero<char>` in improper_ctypes)
 - #158681 (Remove unnecessary `Hash` derives from MIR types)
 - #158682 (Avoid delayed bug for disabled on_type_error arguments)
 - #158684 (Add missing generic test coverage for ```#[splat]```)
 - #158687 (Streamline `MacEager`)
 - #158688 (Cleanup attribute docs and add links to other mentioned attributes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants